Skip to content

feat(core): detect repeated model tool rounds - #74

Open
LukasParke wants to merge 1 commit into
mattapperson:mainfrom
LukasParke:lukeparke/openrouter-doom-loop
Open

feat(core): detect repeated model tool rounds#74
LukasParke wants to merge 1 commit into
mattapperson:mainfrom
LukasParke:lukeparke/openrouter-doom-loop

Conversation

@LukasParke

Copy link
Copy Markdown
Collaborator

What

  • fingerprint completed tool rounds by canonicalized calls paired with results
  • abort after a configurable number of identical repeats (3 repeats / 4 total rounds by default)
  • reset the streak when a polling tool returns progressing output
  • emit {name}:doom_loop_detected before aborting
  • allow non-positive doomLoopIdenticalRounds to disable the guard

Why

A model repeating an identical call/result cycle can consume all 32 tool rounds. Comparing calls alone would incorrectly kill legitimate polling loops, so the guard includes each result by callId and only trips when both request and result remain identical.

This semantically ports fork/port/openrouter-fixes commits 3fc95caf and 33f44721 onto current main.

Test plan

  • 38 focused harness-result tests pass
  • 7 adversarial guard cases: stuck/evolving/constant polling, disable, custom threshold, parallel pairing, nested canonicalization
  • types/core typechecks
  • root lint
  • sentrux check .
  • source worker ran full root suite: 2,047 pass, 0 fail
  • clean-context Pi review; public disable docs corrected

Behavior change

Repeated identical tool-call/result rounds now abort before the global tool-round limit. Polling tools with changing results reset the streak; constant-result polling can raise or disable the threshold.

Port the result-aware configurable doom-loop guard from fork/port/openrouter-fixes commits 3fc95ca and 33f4472 onto current main.

Signed-off-by: Luke Parke <5702154+LukasParke@users.noreply.github.com>
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@LukasParke is attempting to deploy a commit to the Matt Apperson's projects Team on Vercel.

A member of the Team first needs to authorize it.

@LukasParke

Copy link
Copy Markdown
Collaborator Author

Agent: The code CI, DCO, and structural gate passed. Remaining red checks are external configuration: compat received an empty OPENROUTER_API_KEY, and Vercel requires upstream deployment authorization. I cannot remediate or rerun those checks without upstream repository access/secrets.

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.

1 participant