Skip to content

fix(prompt-hook): cap the injection under Claude Code's 10k inline hook-output limit - #1695

Open
bompus wants to merge 1 commit into
colbymchenry:mainfrom
bompus:fix/prompt-hook-cap-under-claude-inline-limit
Open

fix(prompt-hook): cap the injection under Claude Code's 10k inline hook-output limit#1695
bompus wants to merge 1 commit into
colbymchenry:mainfrom
bompus:fix/prompt-hook-cap-under-claude-inline-limit

Conversation

@bompus

@bompus bompus commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #1694.

codegraph prompt-hook capped 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 to tool-results/hook-<id>-stdout.txt and 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

  • MAX 16000 → 9000 in src/bin/codegraph.ts, with a comment naming the host limit. 9,000 leaves ~1,000 characters for the <codegraph_context> wrapper and the projectPath nudge lines that are appended after the cap is applied.
  • CHANGELOG entry under Unreleased › Fixes.

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.

@danusha2345

Copy link
Copy Markdown
Contributor

Confirmed the symptom and the fix on a live setup. The installed prompt-hook (1.6.0-era build, 787-file TS repo) returned 16,360 characters on ordinary prompts — every session got the persisted-file preview, exactly as #1694 describes. With this change merged into a local integration build of current main the same prompt returns 9,348 characters and lands inline. Full suite 252 files / 4349 passed with it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants