Skip to content

fix(codegraph): name codegraph tools by their real MCP-prefixed names in steering#4125

Merged
esengine merged 1 commit into
main-v2from
fix/4111-codegraph-steer-names
Jun 12, 2026
Merged

fix(codegraph): name codegraph tools by their real MCP-prefixed names in steering#4125
esengine merged 1 commit into
main-v2from
fix/4111-codegraph-steer-names

Conversation

@esengine

Copy link
Copy Markdown
Owner

Closes #4111.

The codegraph steering injected into the system prompt named the tools by short name (codegraph_context), but they register under the MCP namespace as mcp__codegraph__context. A model that follows the steering verbatim calls a name that doesn't exist → "unknown tool". The list was also missing explore, node, and status.

Diagnosis (verified against current main-v2)

I reproduced the registration path in a test before changing anything: the codegraph daemon emits raw tool names codegraph_*, the spec sets StripRawPrefix: "codegraph_", and LazyToolset strips it before namespacing — so the real registered name is mcp__codegraph__context (single prefix). The doubled mcp__codegraph__codegraph_context in the report is stale (a build before StripRawPrefix, #3133); strip works on current main.

Fix (option D — static + drift-guard)

  • Use the real mcp__codegraph__<tool> names and cover all ten tools.
  • Kept as a static constant so the cached system-prompt prefix stays byte-for-byte identical across sessions with the same codegraph — no cache impact. (The text is injected once at boot and frozen for the session, so turn-to-turn caching was never at risk; this just keeps cross-session reuse intact too.)
  • New TestSteerTextNamesMatchRegisteredTools asserts, in both directions, that the steering names exactly match ReadOnlyToolNames() mapped through the prefix/strip — so if a codegraph tool is added/renamed or the text drifts, CI fails instead of silently shipping a name the model can't call.

go test ./internal/codegraph ./internal/boot green; gofmt/vet clean.

… in steering

The system-prompt steering text documented the codegraph tools by short name
(`codegraph_context`), but they register under the MCP namespace as
`mcp__codegraph__context` (the daemon's raw `codegraph_` prefix is stripped via
Spec.StripRawPrefix, then namespaced by plugin.ToolPrefix). A model that
followed the steering verbatim called a name that doesn't exist and got
"unknown tool"; the list was also missing `explore`, `node`, and `status`.

Use the real registered names and cover all ten tools. The text stays a static
constant so the cached system-prompt prefix is unchanged byte-for-byte across
sessions with the same codegraph; a new TestSteerTextNamesMatchRegisteredTools
fails if the names drift from ReadOnlyToolNames in either direction, so this
can't silently rot again.

Closes #4111
@esengine esengine requested a review from SivanCola as a code owner June 12, 2026 05:44
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development mcp MCP servers / plugins (internal/plugin, codegraph) and removed v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 12, 2026
@esengine esengine merged commit 76fdd92 into main-v2 Jun 12, 2026
14 checks passed
@esengine esengine deleted the fix/4111-codegraph-steer-names branch June 12, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcp MCP servers / plugins (internal/plugin, codegraph)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SteerText codegraph tool names don't match actual MCP-prefixed names (causing 'unknown tool' errors)

1 participant