Skip to content

fix: stop repeated identical tool doom loops - #823

Closed
kshitijk4poor wants to merge 6 commits into
NousResearch:mainfrom
kshitijk4poor:fix/doom-loop-detection
Closed

fix: stop repeated identical tool doom loops#823
kshitijk4poor wants to merge 6 commits into
NousResearch:mainfrom
kshitijk4poor:fix/doom-loop-detection

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Detect and interrupt repeated identical tool calls to prevent doom loops.
  • Add recovery behavior that skips the repeated call and prompts the model to change approach or summarize.
  • Add regression coverage for repeated-call handling, CLI continue/stop paths, and per-turn state reset behavior.

Scope

Approach

  • Build a call signature from tool name + normalized argument hash.
  • Trigger protection after 3 identical consecutive calls.
  • Exempt long-running process polling/wait/log actions.
  • On trigger, inject an explicit recovery prompt to avoid repeating the same call.

Related

Validation

  • python -m pytest -o addopts='' tests/test_run_agent.py -q
  • python -m pytest -o addopts='' tests/test_run_agent.py -k "doom_loop or resets_doom_loop_state_each_turn" -q

@kshitijk4poor
kshitijk4poor force-pushed the fix/doom-loop-detection branch from 3f36f6b to 062ff4c Compare March 11, 2026 14:14
@teknium1

Copy link
Copy Markdown
Contributor

I think that things like read() look like identical tool calls and aren't and there's too many edge cases of when it may need to repeat the same tool over and over to really implement this. I'm going to close for now. Feel free to reopen if a new formulation of this needs reconsidering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Doom Loop Detection — Pause on Repeated Identical Tool Calls (inspired by Kilocode)

2 participants