feat: surface code-graph tools so the agent stops forgetting them (3-layer)#16
Merged
Conversation
The graph tools described their mechanism (BFS traversal, label propagation, shortest path) but not the situation that should trigger them, so an agent skimming the tool list never reached for them over Grep. Rewrite each description to lead with the use-case (trace how code connects, architecture map, execution flow, A->B path, taint dataflow) and to say 'INSTEAD of repeated Grep' where it applies. The tool list is the one surface the agent never forgets — the affordance rides there.
…ills memory-guidance (the recall-before-acting list), memory-exploring, and memory-cli predated the graph query/paths/communities/processes/taint tools and never mentioned them — an agent reading the skills would not know they exist. Add them where the matching question already lives (architecture → communities, execution flow → processes, A->B → paths, connections → query, security dataflow → taint).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the agent actually reach for the code-graph tools
The graph tools (query/paths/communities/processes/taint) work over MCP + CLI, but nothing led the agent to them — it kept grepping. Documentation alone gets forgotten. This wires them in structurally, at three layers of increasing forget-resistance, matching the repo's proven anti-forgetting pattern (hooks that fire at the moment of action, like lesson-guard).
Layer 1 — sharpen MCP tool descriptions (highest leverage, zero-recall)
The tool list is the one surface the agent never forgets — it's re-presented every turn. The graph tools described their mechanism ("BFS traversal from FQNs", "label propagation") but not the situation that should trigger them. Rewrote all five to lead with the use-case and, where it applies, "reach for this INSTEAD of repeated Grep": trace-how-code-connects (query), A→B path (paths), architecture map (communities), execution flow (processes), security dataflow (taint).
Layer 2 — behavior-triggered
graph-affordancePreToolUse hook (catches the agent mid-forget)A non-blocking PreToolUse hook on
Grep|Globthat counts code-searches in the session's enforcement log and, once past a threshold (4), surfaces a one-time nudge listing the graph tools. Fires once per session (sentinel, wiped at SessionStart so it re-arms), never blocks — a nudge, not a gate (the graph tools are optional-better, not mandatory, so blocking would be wrong). Same architecture aslesson-guard/ the frustrationprompt-guard. Pure counting/decision helpers are unit-tested; hook-registration count assertions updated.Layer 3 — docs (fallback layer)
Added the graph tools to
memory-guidance(the recall-before-acting list), thememory-exploringskill (mapped to the questions that already live there — architecture → communities, flow → processes, A→B → paths), and thememory-cliskill (newgraphcommand family). This is the weakest layer on its own, included so it helps when the agent does read a skill.Verification
state-clear(re-arms).cargo teston touched crates 0 failed, clippy 0 warnings, attribution gate 0.Why not a hard block
require-memory-impactblocks because impact-before-edit is mandatory. Using the graph is a preference, not a requirement — so nudge, never block.