Skip to content

feat(pi): transcript body size cap helper - #7

Merged
srdjan merged 1 commit into
mainfrom
worktree-agent-af90500d
Apr 19, 2026
Merged

feat(pi): transcript body size cap helper#7
srdjan merged 1 commit into
mainfrom
worktree-agent-af90500d

Conversation

@srdjan

@srdjan srdjan commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds capToolResultBody(allocator, body, max) in packages/pi/src/transcript.zig so a future session-persistence worker can write OwnedToolResult.body values to an append-only log without unbounded growth.
  • Helper always returns an allocator-owned slice for uniform ownership; truncation leaves a "...[truncated N bytes]" note. Falls back to a short fixed marker when max is smaller than the suffix.
  • Pure-additive: no existing struct or function changed, and no runtime path invokes the helper yet.

Implementation notes

  • Plan: /Users/srdjans/.claude/plans/study-the-plan-provided-clever-wadler.md (Unit 4).
  • Suffix width is sized off an upper bound of body.len to avoid a search loop; the result may be up to a few bytes under max but never over.

Test plan

  • zig build test-expert-app
  • zig build test
  • zig build
  • Smoke: timeout 10 bash -c 'printf "help\nquit\n" | ./zig-out/bin/zigts expert' prints /verify and Registered tools:
  • New unit tests in transcript.zig: under-cap, at-cap, and over-cap (verifies suffix and exact dropped-byte count)

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
srdjan merged commit bba7127 into main Apr 19, 2026
@srdjan
srdjan deleted the worktree-agent-af90500d branch April 19, 2026 23:32
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant