feat(review): live token counts for claude and codex reviewers

main

Commit

peyton-alt2mo ago

Salvages the live-token slices from closed #1370 onto current main. Reviewer token totals previously appeared only at run completion: claude's parser emitted one Tokens event at the terminal result envelope, and codex's exec --json stdout only carries usage on turn.completed (a review is usually a single turn).

Claude: assistant envelopes carry a usage snapshot taken at the start of each turn — input/cache counts are real but output_tokens is a 1-8 token 'initial decision' stub. Emit input-only Tokens{In, Out: 0} per usage-carrying assistant envelope so consumers see context growth during the run; the result envelope still delivers the final {In, Out} aggregate. Emitting the misleading early output snapshot was rejected after capturing real claude stream-json.

Codex: tail the rollout transcript (located by thread.started's thread_id, same source codex's interactive UI reads) and emit cumulative Tokens per token_count event, deduped on movement. The parser stops the tailer and waits for it before closing the event channel. turn.completed now also emits Tokens per turn (multi-turn runs update at each boundary) with the previous post-loop emission kept as a defensive backstop.

Verified end-to-end via agent shims driving entire review: claude streaming envelopes with usage snapshots, and a codex shim writing rollout token_count lines picked up by the tailer, both to clean completion. Race-detector clean.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com Entire-Checkpoint: 01KWYC8H544S7DV9G0YSEQNV9H

Checkpoints

test(review): pin that codex $name skills survive the legacy repair + native invocation

Claude CodeFable 5
View session
Checkpoint 1