release v0.0.205: resilient context management and launch kit - #239
Draft
justrach wants to merge 3 commits into
Draft
release v0.0.205: resilient context management and launch kit#239justrach wants to merge 3 commits into
justrach wants to merge 3 commits into
Conversation
… the local estimate The #193 pre-send gate (inputOverCompactThreshold) trusted only the local byte/4 estimate (fullInputEstimateTokens). On codex/.responses that estimate structurally under-counts retained encrypted-reasoning items — they're billed large server-side but are compact base64 handles locally — so on a long single turn the local estimate stayed under the threshold while the server had already reported ~511k via last_context_tokens (refreshed mid-turn by recordUsageResponses). The next resend was then rejected for "input exceeds the context window" before any compaction ran — the gate had the right answer in hand and ignored it. The mid-turn gate now also trips on last_context_tokens — the same accurate server meter the between-turns gates (mainloop.zig:683/734) already trust: if (self.last_context_tokens >= threshold) return true; Supporting changes: - The #193 test builds Agent = undefined, so the new last_context_tokens read was uninitialized-memory UB; explicitly zero it and add a meter-only case that trips the gate with an empty local history. - fullInputEstimateTokens now falls back to the bytes counted so far on a serialize failure (catch return d.fullCount()/4) instead of a spurious 0, so a failed serialize can't blind the pre-send gate and the #202 meter floor at once. zig build clean; 195/195 unit + 19/19 REPL tests green. Co-authored-by: Codegraff <blackfloofie@codegraff.com>
justrach
force-pushed
the
release/v0.0.205
branch
from
July 16, 2026 13:43
bf3277f to
2a5f944
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
The mid-turn compaction gate could rely on the local estimate while the server-reported context meter had already crossed the threshold. Chained Responses usage could also diverge from the full retained request, and a failed compaction summary needed stronger transactional isolation so partial mutations never escaped into session history.
Those paths had accumulated inside several 750 to 1,400-line modules, making transport, accounting, and recovery behavior harder to reason about. This release pairs server and local context measurements explicitly, isolates compaction mutations, adds end-to-end regression coverage, and separates the large modules by responsibility.
Impact
Validation
Relationship to existing work
This branch includes the server-meter fix currently proposed in #236. That PR remains open and overlaps this release PR until it is manually superseded.