Skip to content

feat: surface code-graph tools so the agent stops forgetting them (3-layer)#16

Merged
pirumu merged 3 commits into
masterfrom
feat/graph-affordance
Jul 14, 2026
Merged

feat: surface code-graph tools so the agent stops forgetting them (3-layer)#16
pirumu merged 3 commits into
masterfrom
feat/graph-affordance

Conversation

@pirumu

@pirumu pirumu commented Jul 14, 2026

Copy link
Copy Markdown
Member

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-affordance PreToolUse hook (catches the agent mid-forget)

A non-blocking PreToolUse hook on Grep|Glob that 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 as lesson-guard / the frustration prompt-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), the memory-exploring skill (mapped to the questions that already live there — architecture → communities, flow → processes, A→B → paths), and the memory-cli skill (new graph command family). This is the weakest layer on its own, included so it helps when the agent does read a skill.

Verification

Why not a hard block

require-memory-impact blocks because impact-before-edit is mandatory. Using the graph is a preference, not a requirement — so nudge, never block.

pirumu added 3 commits July 15, 2026 03:13
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).
@pirumu
pirumu merged commit 3bdd128 into master Jul 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant