Skip to content

[Bug]: Tool name duplication in agent tool execution #5417

@TycoonCoder

Description

@TycoonCoder

Bug Description

When the agent calls any tool (e.g., write_file), the tool name gets duplicated in the execution layer (e.g., write_filewrite_file). This causes "tool does not exist" errors. The duplication grows exponentially with each failed attempt.

Steps to Reproduce

Enable "reasoning" setting
Set tool visibility to "new"
Have agent call any tool (e.g., write_file)
Observe error: Tool 'write_filewrite_file' does not exist

Expected Behavior

Tool should execute with correct name (e.g., write_file)

Actual Behavior

Tool name is duplicated/triplicated/exponential growth (write_filewrite_file, then write_filewrite_filewrite_filewrite_file, etc.)

Affected Component

Other

Messaging Platform (if gateway-related)

No response

Operating System

Debian 12

Python Version

3.11.2

Hermes Version

v0.7.0 (2026.4.3)

Relevant Logs / Traceback

Root Cause Analysis (optional)

The combination of "reasoning" enabled + "new" tool visibility causes the model's reasoning output (which contains tool names like "write_file") to be incorrectly fed back into the tool call parsing. Each retry compounds the duplication. This is likely in how the gateway processes reasoning output alongside tool calls when using the new visibility format.

Proposed Fix (optional)

Ensure reasoning output is not included or re-parsed when extracting tool names for execution. Isolate the actual tool call JSON from reasoning text in the gateway layer.

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

    sweeper:implemented-on-mainSweeper: behavior already present on current maintype/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