feat(pi): transcript body size cap helper - #7
Merged
Conversation
Adds a dependency-free utility to cap OwnedToolResult.body slices at a fixed byte budget with a trailing "...[truncated N bytes]" note. Future append-only session-persistence code can plug this in without touching transcript internals. Helper is pure-additive; no runtime path calls it yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
srdjan
added a commit
that referenced
this pull request
Jul 12, 2026
… caching, Sonnet default, exit codes Wave 1 of the expert-analysis recommendations (#1, #2, #4, #5, #8). #1 Make the retry loop information-complete. The `.run_veto` arm now records the model's draft as an `apply_edit` tool_use and closes it with the compiler verdict as a tool_result (session-unique id keyed on transcript index). On a failure the tool_result carries the diagnostic + SQL escalation and the compiler-authored repair block is persisted as a follow-up system_note, so the whole retry context lives in the transcript instead of a transient `extra_user_text` that a mid-repair tool call would erase. Drops `diag_history` re-accumulation; `.retry_draft` now sends only a short framing nudge. Adds a regression test proving the failed draft + diagnostic survive a tool interleave. #2 Raise the per-turn wall-clock timeout 60s -> 300s (the recorded convergence for complex handlers ran 80-96s) and drop the eval harness's `turn_timeout_ms=0` override so measurement and production share one options struct. #4 Add a rolling cache breakpoint on the last message block so the conversation prefix hits the prompt cache instead of re-paying full input price every roundtrip. #5 Flip the default model claude-haiku -> claude-sonnet-4-6 (the measured 7/7 first-draft baseline); Haiku stays available via `--model` and the harness's ZIGTTP_CODEGEN_MODEL knob. Docs updated. #8 Outcome-bearing `--print` exit codes: 0 applied/clean, 1 hard error, 2 veto-exhausted, 3 budget, 4 approval-denied. Documented in the user guide. Also lands the OpenAI honest-demotion doc note (#7, docs portion). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
srdjan
added a commit
that referenced
this pull request
Jul 12, 2026
#7) Marks the OpenAI expert backend experimental in `zigttp auth` help and the top-level credentials help (Anthropic is the measured, supported path). Fixes the late auto-compact on OpenAI: contextWindowTokens now returns gpt-4o-mini's true 128k window for the unregistered OpenAI default instead of the Anthropic-sized 200k assumption, so a long OpenAI session compacts before the real limit rather than dead-ending on a "prompt too long". No OpenAI models were added to the registry; full parity remains deferred. Docs already updated in the Wave 1 commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
capToolResultBody(allocator, body, max)inpackages/pi/src/transcript.zigso a future session-persistence worker can writeOwnedToolResult.bodyvalues to an append-only log without unbounded growth."...[truncated N bytes]"note. Falls back to a short fixed marker whenmaxis smaller than the suffix.Implementation notes
/Users/srdjans/.claude/plans/study-the-plan-provided-clever-wadler.md(Unit 4).body.lento avoid a search loop; the result may be up to a few bytes undermaxbut never over.Test plan
zig build test-expert-appzig build testzig buildtimeout 10 bash -c 'printf "help\nquit\n" | ./zig-out/bin/zigts expert'prints/verifyandRegistered tools:transcript.zig: under-cap, at-cap, and over-cap (verifies suffix and exact dropped-byte count)