REQ-LOOP-005: Opt-in thinking-budget gating with nudge then a hard cut that carries the run’s real output

← Requirements

What it requires

  1. Given budget_mode off (default) and a tool-call-free spiral, When the loop runs, Then no nudge or hard cut occurs.
  2. Given budget_mode tokens with a small limit, When the model emits tool-call-free generations, Then a nudge message appears first and a hard cut with terminal_reason "budget_exhausted_thinking" follows.
  3. Given a run whose turns produced real content, When the hard cut fires, Then the last assistant message contains that content AND the cut annotation, and metadata["cap_carried_content"] == "true".
  4. Given a run whose every turn was whitespace, When the hard cut fires, Then the last assistant message says no substantive output was produced and metadata["cap_carried_content"] == "false".
  5. Given a relay-tier lead whose single delegate is hard-cut by the thinking budget, When the child loop ends, Then the relayed summary is tagged "[partial" AND contains the child's own output, and the ON_DELEGATE_COMPLETE payload still reports success=false, the target tier, and result_kind="delegation_failed".
  6. Given a successful tool call, When the budget is charged, Then the counters and the nudge latch reset.
  7. Given a rejected-duplicate tool call, When the budget is charged, Then the counters do NOT reset.
tier
NOT_RUN

Where it lives

  • src/core5

See it on the map

How it is met

implemented byresults (92 tests)budget_units_consumedcharge_thinking_budgetfinish_with_carried_outputhard_cut_budgetnudge_budget_completion92 absent92 tests, a summary by result: every test is in the tests table below

Show on the map

Implemented by

Tests (92)

Reached through calls

92 tests: 92 absent

testresultlinked byimplementers exercisedcalls away
Basic response contains no special tokensabsentinferred5 of 54
Batch generation worksabsentinferred5 of 54
Budget-exhausted forced complete sets terminal_reason metadataabsentinferred5 of 54
Circuit breaker limits tool calls per turnabsentinferred5 of 54
Compaction fires when context exceeds thresholdabsentinferred5 of 54
Compaction triggers at thresholdabsentinferred5 of 54
Context accumulates across turnsabsentinferred5 of 54
Context anchors persist across runsabsentinferred5 of 54
Delegation directive triggers child loopabsentinferred5 of 54
Delegation wiring fires on_delegation_start callbackabsentinferred5 of 54
Dynamic identity creation and generation through engine loopabsentinferred5 of 54
Empty response handled gracefullyabsentinferred5 of 54
Engine state transitions include PLANNING and EXECUTINGabsentinferred5 of 54
Finish reason length continues loopabsentinferred5 of 54
Generate is called exactly once per iterationabsentinferred5 of 54
Hooks fire in correct order during a generation cycleabsentinferred5 of 54
Interrupt stops loopabsentinferred5 of 54
MCP authorization denial propagates through engineabsentinferred5 of 54
Max iterations stops loopabsentinferred5 of 54
Metrics accurate after runabsentinferred5 of 54
Multi-turn engine calls retain contextabsentinferred5 of 54
Root conversation created at run() init when storage wired (gh#48)absentinferred5 of 54
Route callback is invoked for tier selectionabsentinferred5 of 54
Routing fires on_tier_selected callbackabsentinferred5 of 54
Single iteration completesabsentinferred5 of 54
Single-turn engine loop produces coherent responseabsentinferred5 of 54
State transitions IDLE->PLANNING->EXECUTING->COMPLETEabsentinferred5 of 54
Streaming generation worksabsentinferred5 of 54
Streaming interrupt propagates to backend cancel chain absentinferred5 of 54
Tier routing fires callbackabsentinferred5 of 54
Tool call cycle: generate, parse, execute, generateabsentinferred5 of 54
Tool call cycle: generate, parse, execute, regenerateabsentinferred5 of 54
True end-to-end: real prompts, real engine, real modelabsentinferred5 of 54
a context-overflow refusal fails the turn instead of retrying itabsentinferred5 of 54
auto_chain child sets COMPLETE at depth > 0absentinferred5 of 54
auto_chain does not fire without configabsentinferred5 of 54
auto_chain root fires tier change at depth 0absentinferred5 of 54
budget_exhausted child is relayed partial to lead (E2)absentinferred5 of 54
delegation guards reject depth/cycle/repeat/pipeline-depthabsentinferred5 of 54
delegation snapshot + per-tier metrics accumulationabsentinferred5 of 54
gh#105: constitutional validator's toolless render must NOT clobber absentinferred5 of 54
gh#111: a delegation whose child produces raw UTF-8 content does not absentinferred5 of 54
gh#111: a tool call whose arg carries raw UTF-8 is preserved, not absentinferred5 of 54
gh#111: raw UTF-8 in backend-cleaned content is sanitized before it absentinferred5 of 54
gh#119: delegation auto-complete folds child summary into lead's absentinferred5 of 54
gh#121: zero-tool-call correction names tier's actual toolsabsentinferred5 of 54
gh#123 part 1: zero-tool-call counter resets after genuine tool call progressabsentinferred5 of 54
gh#123 part 2: zero-tool-call ceiling is per-tier configurableabsentinferred5 of 54
gh#123 part 3: prose-only nudge turn does NOT set failure_reason in metadataabsentinferred5 of 54
gh#123 part 4: ChildContextInfo.max_consecutive_empty_turns_override wired through engineabsentinferred5 of 54
gh#158: two concurrent runs accumulate metrics safelyabsentinferred5 of 54
gh#160: an isolated delegation never writes the project, and absentinferred5 of 54
gh#162: a delegate seeded with context answers from the named absentinferred5 of 54
gh#162: resume by target picks that tier's latest delegationabsentinferred5 of 54
gh#169: a capped loop carries its last real content, annotatedabsentinferred5 of 54
gh#169: a capped loop that produced nothing stays distinguishableabsentinferred5 of 54
gh#169: the parent relay receives the capped child's real workabsentinferred5 of 54
gh#181: a hard cut with nothing substantive stays distinguishableabsentinferred5 of 54
gh#181: a thinking-budget hard cut carries the run's real contentabsentinferred5 of 54
gh#181: the parent relay receives the hard-cut child's real workabsentinferred5 of 54
gh#183: a fresh top-level run still clears a stale interruptabsentinferred5 of 54
gh#183: a tier's identity overrides reach a top-level runabsentinferred5 of 54
gh#209/#212: a turn that ends in ERROR records why, for the callerabsentinferred5 of 54
gh#77: entropic.complete is terminal when emitted with sibling pipelineabsentinferred5 of 54
gh#80: a tool call resets the budget windowabsentinferred5 of 54
gh#80: budget off (default) does not gate a tool-call-free spiralabsentinferred5 of 54
gh#80: tokens budget nudges then hard-cuts a tool-call-free spiralabsentinferred5 of 54
gh#81: interrupt during tool processing halts before pending dispatchabsentinferred5 of 54
gh#81: run_loop(inherit_interrupt=false) clears a stale interruptabsentinferred5 of 54
gh#81: run_loop(inherit_interrupt=true) preserves a pre-set interruptabsentinferred5 of 54
gh#84 combined: should_stop halts the loop when the duplicate absentinferred5 of 54
gh#84: a successful tool call DOES reset the budgetabsentinferred5 of 54
gh#84: rejected-duplicate tool calls do NOT reset the budgetabsentinferred5 of 54
gh#88 combined: process_tool_results defangs a meta {action} absentinferred5 of 54
gh#88: a gemma multi-turn session never accumulates a parrotable absentinferred5 of 54
hook dispatch: info / PRE_GENERATE cancel / POST_GENERATE rewrite / ON_ERRORabsentinferred5 of 54
last_loop_metrics populated after runabsentinferred5 of 54
max_iterations override caps loop before global limitabsentinferred5 of 54
misc accessors: pause / context_usage / idle / project_dirabsentinferred5 of 54
queue capacity / cap mutation / clear / observer / state slotabsentinferred5 of 54
resume_delegation failure paths surface typed errorsabsentinferred5 of 54
set_storage wiring covers init_session_conversation pathsabsentinferred5 of 54
should_auto_chain false when no locked tierabsentinferred5 of 54
v2.14.6: a lead that answers in prose is nudged, and its forced absentinferred5 of 54
v2.14.6: after a nudge, a tier that owes a tool call is forced to make oneabsentinferred5 of 54
v2.14.6: an empty turn is retried, never accepted as completeabsentinferred5 of 54
v2.14.6: the model's own tool call stays in the history it is shownabsentinferred5 of 54
v2.14.6: with thinking on, each loop turn ends in a real tool callabsentinferred5 of 54
validation_provider variants are all non-fatalabsentinferred5 of 54
zero-tool-call with explicit_completion halts within retry capabsentinferred5 of 54
gh#182: a model-supplied max_turns bounds the delegated childabsentinferred5 of 55
v2.14.6: after a prose answer is nudged, the forced retry may only absentinferred5 of 55