Skip to content

fix(agent): add recovery hints to tool loop warnings (#28256)#28592

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-3ad7d98a
May 19, 2026
Merged

fix(agent): add recovery hints to tool loop warnings (#28256)#28592
teknium1 merged 1 commit into
mainfrom
hermes/hermes-3ad7d98a

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #28256 by @ooovenenoso.

What: When the same tool fails repeatedly within a turn, the guardrail emitted only '{tool} has failed N times this turn. This looks like a loop; change approach before retrying.'. Some models took this as a signal to STOP using tools entirely and pivot to a text-only reply, which is the opposite of what we want — the agent should keep using tools but diagnose first.

How: Replace the warning with an action-oriented hint via _tool_failure_recovery_hint(). Common preamble keeps the loop-detection signal but explicitly tells the model to keep using tools and run a diagnostic first. Tool-specific branch for terminal suggests pwd && ls -la + absolute paths / different tools (read_file/write_file/patch); generic branch covers everything else. Tests added.

Original PR: #28256
Fixes #28204.

@teknium1 teknium1 merged commit d759a67 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-3ad7d98a branch May 19, 2026 07:12
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-3ad7d98a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8954 on HEAD, 8954 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4702 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@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 May 19, 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.

Gateway tool-use hardening: skill preload, loop-guard recovery, path resolution docs

3 participants