-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): per-turn tool-call circuit breaker — always-on cap + opt-in loop heuristics (#5234) #5279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): per-turn tool-call circuit breaker — always-on cap + opt-in loop heuristics (#5234) #5279
Changes from all commits
7ad5678
5e762af
5fe2046
0547a63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,12 @@ const LOOP_TYPE_LABELS: Record<LoopType, string> = { | |
| 'the model spent too many consecutive calls reading files without making progress', | ||
| [LoopType.ACTION_STAGNATION]: | ||
| 'the model kept calling the same tool without making progress', | ||
| [LoopType.GLOBAL_TOOL_CALL_DUPLICATE]: | ||
| 'the model repeated the same tool call across the turn, even when not back-to-back', | ||
| [LoopType.ALTERNATING_TOOL_CALL_PATTERN]: | ||
| 'the model alternated between the same two tool calls in a repeating pattern', | ||
| [LoopType.TURN_TOOL_CALL_CAP]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message here is correct, but the headless caller still needs to stop the current run, not just print the message. In the tmux headless smoke test, |
||
| 'the model exceeded the maximum number of tool calls allowed in a single turn', | ||
| }; | ||
|
|
||
| function emitLoopDetectedMessage( | ||
|
|
@@ -122,9 +128,13 @@ function emitLoopDetectedMessage( | |
| } | ||
| const reason = loopType ? LOOP_TYPE_LABELS[loopType] : undefined; | ||
| const detail = reason ? ` (${loopType}: ${reason})` : ''; | ||
| process.stderr.write( | ||
| `Loop detection halted the run${detail}. Set the \`model.skipLoopDetection\` setting to true to disable.\n`, | ||
| ); | ||
| // The turn cap runs before the skipLoopDetection gate, so that setting can't | ||
| // disable it — don't suggest it for TURN_TOOL_CALL_CAP. | ||
| const hint = | ||
| loopType === LoopType.TURN_TOOL_CALL_CAP | ||
| ? ' This is an always-on per-turn tool-call cap and cannot be disabled via `model.skipLoopDetection`.' | ||
| : ' Set the `model.skipLoopDetection` setting to true to disable.'; | ||
| process.stderr.write(`Loop detection halted the run${detail}.${hint}\n`); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.