Skip to content

fix: handle dict/list arguments in tool call validation#1114

Closed
Jah-yee wants to merge 1 commit intoNousResearch:mainfrom
Jah-yee:fix/dict-arguments-strip-error
Closed

fix: handle dict/list arguments in tool call validation#1114
Jah-yee wants to merge 1 commit intoNousResearch:mainfrom
Jah-yee:fix/dict-arguments-strip-error

Conversation

@Jah-yee
Copy link
Copy Markdown
Contributor

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

When using llama-server (llama.cpp) as an OpenAI-compatible backend, tool call arguments may be returned as a dict or list instead of a string. This causes AttributeError: 'dict' object has no attribute 'strip' at the tool call argument validation.

Fix

This fix normalizes dict/list arguments to JSON strings before the .strip() call, matching the existing pattern used elsewhere in the codebase (line ~1660).

Changes

  • Added type checking for tc.function.arguments before calling .strip()
  • Normalize dict to JSON string using json.dumps()
  • Normalize list to JSON string using json.dumps()
  • Fallback to str() for other types

Testing

This fix follows the same pattern already used at line ~1660 in run_agent.py.

Related

Fixes: #1071

When using llama-server (llama.cpp) as an OpenAI-compatible backend,
tool call arguments may be returned as a dict or list instead of a string.
This causes AttributeError: 'dict' object has no attribute 'strip' at the
tool call argument validation.

This fix normalizes dict/list arguments to JSON strings before the .strip()
call, matching the existing pattern used elsewhere in the codebase (line ~1660).

Fixes: NousResearch#1071
@Jah-yee Jah-yee closed this Mar 13, 2026
@Jah-yee Jah-yee deleted the fix/dict-arguments-strip-error branch March 13, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error during OpenAI-compatible API call #1: 'dict' object has no attribute 'strip'

1 participant