Skip to content

Hermes tool-calling pipeline can corrupt tool names and JSON arguments, causing generic tool-call failures #6841

@warrent9030-maker

Description

@warrent9030-maker

Summary

Hermes intermittently fails tool calls because malformed tool-call payloads reach the central validator in run_agent.py.

This is not limited to one tool. It affects the generic tool-call path and shows up across multiple tool names.

Symptoms

Observed duplicated tool names include:

  • skills_listskills_list
  • session_searchsession_search
  • skill_viewskill_view
  • web_searchweb_search
  • execute_codeexecute_code

Observed duplicated adjacent JSON argument payloads include:

  • {"category":"research"}{"category":"research"}
  • {"a":1}{"a":1}{"a":1}
  • {"name":"reddit-saas-idea-miner","file_path":""}{"name":"reddit-saas-idea-miner","file_path":""}{"name":"reddit-saas-idea-miner","file_path":""}

Typical errors include:

  • Model generated invalid tool call: skills_listskills_list
  • Tool 'skill_viewskill_view' does not exist. Available tools: ...
  • Error: Invalid JSON arguments. Extra data: ...

Impact

  • valid tools are rejected as invalid because their names are duplicated/mangled
  • valid argument objects are rejected because duplicated adjacent JSON objects form invalid JSON
  • Hermes can get stuck retrying/self-correcting instead of executing the intended tools
  • in chat surfaces this can leave the session looking wedged or endlessly “typing”

What I verified

Current upstream main on GitHub does not appear to contain the stronger duplicated-name / duplicated-JSON repair logic.

Verified against a fresh clone of:

  • https://github.com/NousResearch/hermes-agent.git

At the time checked:

  • main HEAD was 1789c2699afb00f84e70b15a4dbbb6092a357ad1

In that clean clone of run_agent.py:

  • _repair_tool_call(...) exists, but only with:
    • lowercase repair
    • hyphen/space to underscore normalisation
    • fuzzy match
  • the stronger helpers/markers were not present:
    • _repair_duplicated_json_args(...)
    • duplicated-name collapse for cases like skills_listskills_list
    • log marker: Auto-repaired duplicated JSON arguments

Root cause

The issue appears to be malformed tool-call data arriving at the generic validation path in:

  • run_agent.py

The tool registry itself is not the core problem:

  • affected tools existed in the loaded tool definitions
  • the failure was corruption of tool names / arguments before successful execution

Proposed fix

Add central defensive repair in run_agent.py for two confirmed corruption modes:

1. Repeated tool-name repair

Examples:

  • skills_listskills_list -> skills_list
  • skill_viewskill_view -> skill_view
  • session_searchsession_search -> session_search
  • web_searchweb_search -> web_search

2. Exact duplicated adjacent JSON-argument repair

Examples:

  • {"category":"research"}{"category":"research"} -> {"category":"research"}
  • {"a":1}{"a":1}{"a":1} -> {"a":1}

Repair should be conservative:

  • exact repeated payloads can be collapsed
  • mismatched payloads should still fail safely

Notes

This was reproducible in live use and not just in synthetic tests.

In addition to tool-call corruption, a stuck chat/typing state was also observed after a research run completed successfully in the session log, suggesting the bad tool-call/retry path may contribute to chat-facing sessions appearing wedged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions