prompt-hook: make the injection cap configurable and allow a nudge-only mode
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #2572 来自 @mitunmanav —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- c
调研方向
Start by locating where PROMPT_HOOK_INJECTION_MAX is defined and how the prompt hook selects its output tier; inspect the existing environment-variable handling and tests for the hook. Compare the two proposed approaches and check related issues #1282, #1694, #2184, #914, and #1279 before choosing scope. Done means users can configure a lower cap or select nudge-only output, with tests covering the default and behavior.
由索引模型根据 Issue 内容生成。
描述
Problem
PROMPT_HOOK_INJECTION_MAX is hardcoded (9,000 chars in 1.6.2, 16,000 before #1694). The only user-facing control is the kill-switch (CODEGRAPH_NO_PROMPT_HOOK=1), so the choice is all or nothing.
On Claude Code, hook output stays in the conversation and is re-read from cache on every later model call until the next compaction. A full-explore injection therefore costs its size multiplied by the number of calls that follow it, not just once.
What I measured
One long Claude Code session on Windows (v1.5.0, a TypeScript monorepo, prompts mostly in Spanish), counted from the session transcript:
| Metric | Value |
|---|---|
| Model calls | 2,256 |
| User prompts | 226 |
| prompt-hook injections | 119 |
| Compactions | 4 (about 450 calls per segment) |
In this session, a large share of the injections were not related to the prompt. For example, a prompt asking to read a blog post about token usage injected the source of unrelated UI components.
1.6.1 and 1.6.2 already remove three of the triggers I saw: <task-notification> (#1832), <agent-message> hand-backs (#2184) and everyday "como" (#1654). Thanks for those.
The new 9,000-char cap fixes #1694 by keeping the output inline. A side effect is that each full injection now enters the context whole. In 1.5.0, oversized output was persisted to a file and only a 2 KB preview reached the model. For users whose prompts often pass the gate, the total context cost per session can go up even as the number of injections goes down.
Proposal
Either of these would let users choose the trade-off without turning the hook off:
CODEGRAPH_PROMPT_HOOK_MAX_CHARS, defaulting to the current 9,000 and clamped to it, so users can lower the cap (for example to 3,000).CODEGRAPH_PROMPT_HOOK_MODE=nudge, which always uses the existing medium-tier output: a short list of matching symbols plus the "call codegraph_explore" line. The agent then pulls source only when it needs it.
Option 2 matches the hook's own design, where the agent writes the explore query. It also keeps the hook useful as a reminder to query the graph, which is the behavior that #914 and #1279 report as missing.
Related: #1282 (output budget for explore), #1694, #2184.
Environment
- codegraph 1.5.0 at the time of measurement, now 1.6.2
- Claude Code on Windows 11, Git Bash
- 主要语言
- C
- 星标
- 73.2k
- 派生
- 4.7k
- 平均合并
- 3 小时 31 分钟
- 30 天内合并 PR
- 546
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
colbymchenry/codegraph 的其他 Issue
-
A `../` entry in package.json `workspaces` makes a folder outside the project count as a workspace package, and a call gets linked to the wrong function可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
colbymchenry/codegraph#3093 ·
维护者通常 1 天内回复
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launch未关闭
难度 2/5 1-3 小时 新手友好度 86/100
colbymchenry/codegraph#3054 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
colbymchenry/codegraph#2974 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
colbymchenry/codegraph#2959 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
colbymchenry/codegraph#1900 · 2 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
查看 colbymchenry/codegraph 的全部 Issue
相似的 Issue
-
Status: Opened Type: Bug
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
severity: low
难度 2/5 1-3 小时 新手友好度 76/100
luainkernel/lunatik#2221 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
FriendsofECCE/ECCE#731 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
zephyrproject-rtos/zephyr#124160 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
davatorium/rofi#2347 ·