Skip to content

fix(run_agent): repair repeated tool names and duplicated JSON args#7159

Open
warrent9030-maker wants to merge 2 commits into
NousResearch:mainfrom
warrent9030-maker:fix/tool-call-repair
Open

fix(run_agent): repair repeated tool names and duplicated JSON args#7159
warrent9030-maker wants to merge 2 commits into
NousResearch:mainfrom
warrent9030-maker:fix/tool-call-repair

Conversation

@warrent9030-maker

Copy link
Copy Markdown

Summary

This PR adds conservative repair logic in run_agent.py for two malformed tool-call patterns observed in live runs:

  1. repeated tool names, e.g. skills_listskills_list
  2. repeated adjacent identical JSON argument payloads, e.g. {"a":1}{"a":1}

Fixes #6841

Why

These malformed payloads currently fall through to invalid-tool / invalid-JSON handling, which can cause unnecessary retries and failed tool execution.

Approach

  • collapse repeated tool names only when the repair is exact and unambiguous
  • collapse duplicated adjacent JSON objects only when all repeated payloads are identical
  • preserve existing failure behaviour for mismatched or unsafe inputs

Tests

Added regression coverage for:

  • repeated tool-name repair
  • duplicated JSON argument repair
  • mismatched duplicated JSON remaining invalid

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants