Skip to content

feat(hooks): name the graph follow-up tools in every search augmentation - #2714

Merged
DeusData merged 1 commit into
mainfrom
feat/hooks-graph-follow-up-hint
Oct 20, 2026
Merged

DeusData merged 1 commit into
mainfrom
feat/hooks-graph-follow-up-hint

Conversation

@DeusData

Copy link
Copy Markdown
Owner

What changes

When an agent greps, globs or runs a shell search for a symbol the graph knows, the PreToolUse augmentation lists the matching symbols. It now closes with one line naming the graph tools for the usual next question:

[codebase-memory] For these symbols, trace_path lists callers and callees, get_code_snippet returns the exact source, and search_graph finds related symbols by name.
  • It's cbm's own statement. It sits on its own line after the untrusted symbol block and carries no repository-derived value. It's written as facts, as the Claude Code hooks docs ask of hook context.
  • Why this surface: the first signal of drift is the agent grepping. This places the pointer to the graph tool at that moment, in every session, not only at SessionStart (AI not using the MCP as much as it should #509, discussion Claude and Pi both refuse to use codebase-memory-mcp, at all #2025).
  • Safe append: the list loop's offset can run past its cap when a row is truncated, so appending at that offset could have written past the buffer. The line is appended at the string's real end, into room the allocation reserves for it.
  • Unchanged: searches without a hit, errors, and non-search events.

Proof on real output

Isolated cache, one-file repo, warm daemon, default deadline:

payload before after
PreToolUse Grep create_stripe_checkout 347 B, symbol list only 513 B, symbol list + follow-up line
PreToolUse Bash rg -n create_stripe_checkout . 347 B 513 B
PreToolUse Grep with no hit no output no output

Tests

  • New: cli_hook_augment_context_names_graph_follow_ups. It checks that the line follows the symbol list and contains no repository value.
  • Revert check: with main's src/cli/hook_augment.c, exactly this test fails (follow is NULL); with the change, it passes.
  • Local (macOS arm64, ASan/UBSan test runner): cli 363 passed / 0 failed, daemon_application 74 / 0, agent_clients 38 / 0.
  • Lint: clang-format (Homebrew LLVM 22) and cppcheck 2.20 (the CI lint image) both clean.
  • Linux and Windows legs were not run locally: the change is a fixed string appended within a bounded buffer, so PR CI is the gate.

Refs #509

When an agent greps for a symbol that the graph knows, the PreToolUse
augmentation (Grep, Glob and Bash searches) lists the matching symbols. It now
closes with one line that is cbm's own statement, outside the untrusted symbol
block, naming the graph tools for the usual next question:

  [codebase-memory] For these symbols, trace_path lists callers and callees,
  get_code_snippet returns the exact source, and search_graph finds related
  symbols by name.

The line carries no repository-derived value and is stated as facts, as Claude
Code asks of hook context. It is appended at the string's real end into
reserved room: the list loop's offset can run past its cap when a row is
truncated, so appending at that offset could have written past the buffer.
Searches without a hit, errors and non-search events are unchanged.

Refs #509

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData DeusData added enhancement New feature or request editor/integration Editor compatibility and CLI integration labels Oct 19, 2026
@DeusData
DeusData merged commit 171f99b into main Oct 20, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor/integration Editor compatibility and CLI integration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant