runner: context-aware memory tracking

Memory tools now dispatch through a special path in the runner (like
working_stack) instead of the generic tools::dispatch. This gives them
&mut self access to track loaded nodes:

- memory_render/memory_links: loads MemoryNode, registers in
  context.loaded_nodes (replace if already tracked)
- memory_write: refreshes existing tracked node if present
- All other memory tools: dispatch directly, no tracking needed

The debug screen (context_state_summary) now shows a "Memory nodes"
section listing all loaded nodes with version, weight, and link count.

This is the agent knowing what it's holding — the foundation for
intelligent refresh and eviction.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-03-25 01:48:15 -04:00
parent 2c61a3575d
commit 4b97bb2f2e
3 changed files with 89 additions and 1 deletions

View file

@ -102,7 +102,7 @@ pub async fn dispatch(
"grep" => grep::grep(args),
"glob" => glob_tool::glob_search(args),
"journal" => journal::write_entry(args),
n if n.starts_with("memory_") => memory::dispatch(n, args, None),
// memory_* tools are dispatched in runner.rs for context tracking
_ => Err(anyhow::anyhow!("Unknown tool: {}", name)),
};