Skip to content

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

@Kaloszer

Description

@Kaloszer

Bug Description

When using llama-server (llama.cpp) as an OpenAI-compatible backend, hermes crashes with 'dict' object has no attribute 'strip' during tool call argument validation. The error retries and eventually fails again, and again.

Steps to Reproduce

Start llama-server with a tool-calling model:

llama-server -m Qwen3.5-27B-Q4_K_M.gguf -ngl 99 -c 262144 -np 1 -fa on --cache-type-k q4_0 --cache-type-v q4_0 --host 0.0.0.0 --port 8080

Configure hermes to use http://:8080/v1 as the API endpoint
Give the agent a task that triggers tool calls
Error occurs on every API call that returns tool calls

Expected Behavior

Hermes should respond

Actual Behavior

❌ Error during OpenAI-compatible API call #1: 'dict' object has no attribute 'strip'
�� Error during OpenAI-compatible API call #2: 'dict' object has no attribute 'strip'

The crash occurs at run_agent.py ~line 4280 where .strip() is called on tc.function.arguments which is a dict instead of a string.

Affected Component

Tools (terminal, file ops, web, code execution, etc.)

Messaging Platform (if gateway-related)

No response

Operating System

Windows 11 (llama-server) + Ubuntu/WSL2 (hermes-agent)

Python Version

3.11.15

Hermes Version

Hermes Agent v0.2.0 (2026.3.12)

Relevant Logs / Traceback

Exception in thread Thread-3 (run_agent):
  File "run_agent.py", line 4280, in run_conversation
    if not args or not args.strip():
AttributeError: 'dict' object has no attribute 'strip'

Root Cause Analysis (optional)

In run_agent.py ~line 4278-4280, tool call argument validation assumes tc.function.arguments is always a string:
pythonargs = tc.function.arguments
if not args or not args.strip(): # crashes when args is a dict
Per the OpenAI spec, function.arguments should be a JSON string, but llama-server sometimes returns it as a parsed dict. This is a known llama-server/Ollama behavior:

llama.cpp #14697
ollama-python #484
litellm #8313

Hermes already guards against the same issue for assistant_message.content at line ~4114 but function.arguments is unguarded.

Proposed Fix (optional)

Add dict/list normalization before the .strip() call, matching the existing pattern at line

~4114:

diff                    for tc in assistant_message.tool_calls:
                        args = tc.function.arguments
+                       if isinstance(args, (dict, list)):
+                           tc.function.arguments = json.dumps(args)
+                           continue
                        # Treat empty/whitespace strings as empty object
                        if not args or not 

After this patch Hermes agent runs fine for me.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions