fix(prompt-hook): cap the injection under Claude Code's 10k inline hook-output limit - #1695
Conversation
|
Confirmed the symptom and the fix on a live setup. The installed |
|
Measured this one end to end on a real repo (vite, indexed at 9,354 nodes / 27,778 edges) rather than a fixture. It holds up. The premise is documented, not inferred. From the Claude Code hooks reference:
So the old Measurement. I drove
Both arms are pinned at the ceiling on every prompt, which is the point — on a repo this size the budget is always the binding constraint, so the old value wasn't an occasional overflow, it was overflowing every time. The 223-char delta over No concerns. LGTM. |
Fixes #1694.
codegraph prompt-hookcapped its<codegraph_context>injection at 16,000 characters. Claude Code shows hook stdout inline only up to 10,000 characters; above that it persists the output totool-results/hook-<id>-stdout.txtand the model sees a 2 KB preview plus the path. So on any repo where explore filled the cap, the hook delivered a file reference instead of the context (measured in #1694: 9,871 characters inline, 10,031 persisted, on Claude Code 2.1.261).Change
MAX16000 → 9000 insrc/bin/codegraph.ts, with a comment naming the host limit. 9,000 leaves ~1,000 characters for the<codegraph_context>wrapper and theprojectPathnudge lines that are appended after the cap is applied.The existing "…(truncated; call codegraph_explore for the rest)" notice is unchanged, so a capped payload still tells the model where the rest is. The blast-radius list leads the explore output, so the part that survives the cap is the part the model acts on.
Not in this PR
An env var to set the cap per host. Happy to add one if you want other hosts to be able to raise it.