feat(turn): halt a turn stuck repeating one identical tool call
Ports grok-build's action stationarity breaker. A polling loop looks like progress from inside the turn — every step succeeds — so nothing stops it and it burns the whole budget re-reading one file. Nudge at 8 identical batches, halt at 16, halt a pure no-op run at 4. Three defects were found and fixed before this landed, none of which the gates caught: - The check runs AFTER execute_tool_calls, not before. Before it, the assistant's tool_calls are recorded with no results, so pushing the nudge triggers repair_dangling_tool_calls: synthetic "cancelled by the user" results get spliced in, the real results land after a user message, and dedup misses them — the orphan tool_result shape that draws a provider 400. It is Ok-gated too, since one `?` inside can leave a call resultless. - `TurnOutcome::StationarityHalted` is its own variant grouped with Completed, not a reuse of Cancelled. As a cancellation it would report StopReason::Cancelled, fire the abort lifecycle, kill the turn's subagents, grow the goal harness back-off streak until three halts paused a running goal, and let completion-requirement recovery re-run the very turn halted for looping. - The no-op gate is size-based, not name-based. kigi registers the shell tool as `run_terminal_cmd` and renames it `run_terminal_command`, so matching on "bash" silently disabled the tighter ceiling while every test still passed.
This commit is contained in:
1 parent
a07d889ad9
commit
ac23ebc9a1
8 files changed
+429
-5
No files matched your search
@@ -29,6 +29,13 @@ pub enum PromptCompletionKind {
|
||||
MaxTurnsReached {
|
||||
limit: usize,
|
||||
},
|
||||
/// One tool call repeated past its ceiling. Reported as `EndTurn`:
|
||||
/// the turn ended, nobody interrupted it.
|
||||
StationarityHalted {
|
||||
tool_name: String,
|
||||
run_len: u32,
|
||||
true_noop: bool,
|
||||
},
|
||||
Rewound,
|
||||
/// A queued prompt was removed (or cleared) from the server-authoritative
|
||||
/// queue before it ever ran. Used to resolve the still-pending
|
||||
|
||||
Reference in new issue
Block a user