Skip to content

fix(pi): Cap output tokens for each skill review response - #583

Draft
gricha wants to merge 2 commits into
mainfrom
gricha/cap-analysis-output
Draft

gricha wants to merge 2 commits into
mainfrom
gricha/cap-analysis-output

Conversation

@gricha

@gricha gricha commented Nov 26, 2026

Copy link
Copy Markdown
Member

Skill reviews on Pi sent no max_tokens, so a runaway response kept generating until it hit the model's own output limit. Pi then reported output_limit, and the hunk failed with its output discarded. Production traces show 77 such responses over 14 days, each near 500k output tokens and running 45 to 50 minutes. Auxiliary calls already pass a cap through the same path (pi.ts, runPiPrompt); skill reviews did not.

This caps each skill review response at 64k output tokens. A hunk that hits it fails as before, just early. output_limit is not retried, so this does not add attempts.

Sizing: across 264 Grok 4.5 hunk reviews from security-review benchmark and PR runs, total output per hunk (all turns) had a median of 837 tokens, p99 of 10k, and a max of 17.7k. Whole-file corpus chunks averaged about 10.8k. 64k leaves room for long reasoning on one response while stopping a runaway about 8x sooner.

The new test asserts the cap reaches the model call. It fails without the change and passes with it.

Skill reviews sent no max_tokens, so a runaway response ran to the
model's own output limit before Pi reported output_limit and the hunk
failed. Production traces show such responses near 500k output tokens
after 45 to 50 minutes, with the work discarded.

Cap each response at 64k output tokens, the same mechanism auxiliary
calls already use. Normal reviews stay far below it: across 264 Grok
4.5 hunk reviews, total output per hunk peaked at about 18k tokens.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
warden-prod Ready Ready Preview Nov 26, 2026 3:51am UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – warden-prod — a28c23cc Deployed Nov 26, 2026 by vercel[bot]
Preview – warden — a28c23cc Deployed Nov 26, 2026 by vercel[bot]
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