Skip to content

feat: uteke memory loop — harness-level recall + remember - #81

Closed
ajianaz wants to merge 4 commits into
developfrom
feature/uteke-memory-loop
Closed

ajianaz wants to merge 4 commits into
developfrom
feature/uteke-memory-loop

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What

Cross-session memory as owner-configured harness behavior (--memory uteke / TOLE_MEMORY), not model tools: pre-turn recall injection + post-session summary, namespace repo-<dir> per ecosystem convention.

Stacked on #80 ← #79. GitHub retargets as those merge.

Why

The memory tools (uteke_recall/uteke_document) only fire if the model chooses to call them — cross-session continuity needs the harness to close the loop itself: inject relevant memory before the first turn, store a summary when the session settles. This is tole's equivalent of Hermes Mode C and the piece that makes sessions feel alive.

Changes

  • tole-core/memory.rs: recall/remember_session/format_recall_block over the uteke CLI (scrubbed env, hard timeout, argv-only); fenced injection block with explicit origin/extent markers; single truncation choke point at format time; argv-safe namespace sanitization; fake-binary e2e tests pin the CLI contract
  • CLI: --memory uteke flag (env fallback TOLE_MEMORY, namespace override TOLE_MEMORY_NAMESPACE); injection on the first turn of a fresh session (run/chat); summary on settle (run Final / clean chat exit)
  • Amplification guard (caught in live E2E round 1): the stored summary uses the PRE-injection prompt — otherwise recalled memory gets re-stored inside the summary
  • Host knobs (workspace/mcp/memory) bundled into HostConfig; too_many_arguments allow removed
  • Trust notes: host-initiated on both ends (model cannot trigger/suppress); every failure degrades to stderr and the turn proceeds; memory is never a dependency

Testing

  • fmt / clippy -D warnings / test --workspace ✅ (8 new memory tests)
  • Live E2E (release binary, scratch namespace repo-tole-live-test, real bifrost provider): seeded fact recalled → correct answers (BUAH NAGA / Tuesday); summary verified in store with no echo; durable JSONL contains the fenced block; test memories cleaned up afterwards
  • cora review --staged: No issues found (exit 0)

The mcp feature was opt-in, so 'cargo check/clippy/test --workspace'
with default features never compiled the mcp paths — and they had
rotted: a moved-value borrow error in register_server_tools, an unused
PathBuf import, two deprecated rmcp::model::ClientInfo uses (now
ClientConfig per rmcp 3.3), and mcp_tests.rs calling risk() without the
Tool trait in scope. All fixed; no behavior change.
When the cora binary is on PATH, tole now attaches the local 'cora mcp'
server automatically: the full code-intel surface (brain search, callers,
impact, affected tests, dead-code, review — 18 tools, registry names
mcp_cora_*) registers with no manual flag, matching the ecosystem goal
that sibling tools are usable out of the box.

- tole-cli default features now include the mcp client
  (default = ["shell-tools", "mcp"]); embedder profiles are unaffected
  (tole-core defaults do not change).
- --no-auto-mcp global flag skips the presets per run; an explicit
  --mcp-server cora=... spec replaces the preset for that name (explicit
  wins over auto in the pure, unit-tested merge_mcp_specs).
- cora_search now follows the same startup-probing contract as the uteke
  tools: a missing cora binary degrades to a one-line warning instead of
  a phantom tool, and the native single-tool fallback is skipped when
  the cora MCP surface is attached (no duplicate search tools).
- Trust model untouched: MCP tools stay Risk::Write with the approval
  gate on every call; server metadata is never trusted.

Live E2E (release binary): auto-preset registers 18 tools in ~23ms;
--no-auto-mcp attaches nothing; explicit --mcp-server cora=... yields
exactly one registration (no duplicate).
@ajianaz
ajianaz force-pushed the feature/cora-mcp-autopreset branch from 0bfd01d to 3924b43 Compare September 18, 2026 01:44
@ajianaz
ajianaz force-pushed the feature/uteke-memory-loop branch from e7faee9 to 7a59964 Compare September 18, 2026 01:45
CodeCora code-scanning finding: the native fallback decision used
config presence (mcp_servers contains 'cora'), but registration happens
later — a cora binary whose MCP server fails (old version, bad
handshake, timeout) left the user with zero code-intel tools while the
native cora_search was already skipped.

Now the MCP loop records the cora server's registration count and the
native fallback decision runs AFTER it: no MCP cora tools → register
native cora_search (when the binary exists); MCP tools present → skip
the fallback. Live-verified both paths: a fake failing cora mcp
degrades to the native tool with a one-line server warning; the real
cora mcp registers 18 tools and the fallback stays dormant.
Cross-session memory as owner-configured harness behavior, not model
tools: the model can neither trigger nor suppress the loop.

- Pre-turn recall (--memory uteke / TOLE_MEMORY): on the first turn of
  a fresh session, prompt-relevant memories are recalled from the
  owner's uteke store and injected into the user message inside a
  clearly marked fenced block; the durable log stores exactly what the
  provider saw. Truncation happens at the single format choke point.
- Post-session remember: when a session settles with a final answer, a
  compact summary (--type context, tags tole,session) lands in the
  namespace. The summary stores the PRE-injection prompt — storing the
  injected block would echo recalled memory back into the store
  (amplification, caught in live E2E round 1 and fixed).
- Namespace follows the ecosystem repo-<dir> convention
  (TOLE_MEMORY_NAMESPACE overrides, argv-safe sanitization); every
  failure degrades to stderr and the turn proceeds without memory.
- Host knobs (workspace / mcp_server / memory) bundled into a shared
  HostConfig so command signatures stop growing per feature; the
  clippy too_many_arguments allow is gone.
- memory.rs: fake-binary e2e tests pin the exact CLI argv contract for
  recall and remember; sanitization and fence formatting unit-tested.

Live E2E (release binary, real uteke store via scratch namespace +
bifrost provider): injected recall answered a fact only present in
memory (BUAH NAGA / Tuesday); summary verified in the store, no echo;
test memories cleaned up afterwards.
@ajianaz
ajianaz force-pushed the feature/uteke-memory-loop branch from 7a59964 to e17fd71 Compare September 18, 2026 01:58
@ajianaz
ajianaz changed the base branch from feat/cora-mcp-autopreset to develop September 18, 2026 02:12
@ajianaz ajianaz closed this Sep 18, 2026
@ajianaz
ajianaz deleted the feature/uteke-memory-loop branch September 18, 2026 02:18
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