Expand description
Streaming response state and guardrails (P2 PR4 → zagens-core).
Structs§
Enums§
Constants§
- FAKE_
WRAPPER_ NOTICE - MAX_
CONTEXT_ CYCLE_ HANDOFFS - Max times an in-flight turn whose context overflows the model budget (and
can’t be brought back under it by emergency compaction within
MAX_CONTEXT_RECOVERY_ATTEMPTS) may roll a long-horizon cycle handoff instead of hard-failing the turn. A handoff swaps the bloated message buffer for a small<carry_forward>briefing seed plus preserved structured state, so the next step starts with room to spare. Kept tiny: if even a fresh briefing seed can’t fit, the task is genuinely too large and we fall back to the hard failure. - MAX_
IN_ TURN_ CYCLE_ ADVANCES - Max clean in-turn cycle advances at a per-step safe boundary. The cycle
threshold / long-horizon early-advance band is normally only evaluated
between turns; a long-horizon turn that loops many tool steps without
returning never reaches that boundary, so a turn crossing ~75% would only
get the hard-overflow emergency handoff (
MAX_CONTEXT_CYCLE_HANDOFFS), never a clean early refresh. Evaluating the gate after each completed tool step closes that gap. Each clean advance resets context to a small briefing seed (so the gate won’t immediately re-fire); this bound is the safety net against a pathological seed that itself stays over threshold. Generous — a genuinely long turn may legitimately refresh several times. - MAX_
LENGTH_ CONTINUATIONS - Max consecutive auto-continuations after the model hits the output
max_tokenscap (finish_reason=length) with no tool call to carry the turn. Bounds runaway cost / an infinite cut→continue loop while still letting a genuinely huge answer (or reasoning) finish across several rounds. Reset to 0 on any step that does not end in a length truncation. - MAX_
LOOP_ GUARD_ CONTINUATIONS - Max times a long-horizon turn whose
LoopGuardhalts (a tool failedFAILURE_HALT_THRESHOLDconsecutive times) may be granted a “change approach” continuation instead of silently ending the turn asCompleted. Kept small — a halt means the model is genuinely stuck, so we reset the failure counters and nudge it to switch strategy at most this many times before accepting the stop. - MAX_
STEP_ LIMIT_ CONTINUATIONS - Max times a long-horizon turn that exhausts its
max_stepsbudget may be granted another full step window to keep pursuing an incomplete task graph, instead of silently ending at the step cap (step-exhaustion early-stop). Each grant extends the budget by the originalmax_steps; bounded so a runaway task can’t loop forever (e.g. 3 → up to 4× the base step budget). - MAX_
STREAM_ ERRORS_ BEFORE_ FAIL - MAX_
STREAM_ RETRIES - Outer turn-step retries when a stream dies with no actionable content (#103).
- MAX_
TRANSPARENT_ STREAM_ RETRIES - STREAM_
CHUNK_ TIMEOUT_ SECS - STREAM_
MAX_ CONTENT_ BYTES - STREAM_
MAX_ DURATION_ SECS - TOOL_
CALL_ END_ MARKERS - TOOL_
CALL_ START_ MARKERS