Skip to main content

Module recall_session

Module recall_session 

Source
Expand description

recall_session tool (#2348): session-scoped memory query (RAG over session history).

Why: epic #2343 (Infinite Sessions) requires all other session context beyond the 5 pinned goal slots and the compressed working history to be retrieved ON DEMAND by querying trusty-memory, rather than kept resident in the prompt. #2345’s turn recorder already dual-writes every turn into trusty-memory (tagged session:<id>, turn) as the semantic recall surface; this tool is the model-invoked query side of that surface — an explicit tool call the model makes when it needs something from earlier in THIS session that has scrolled out of its visible context, never an automatic per-turn injection. What: RecallSessionTool implements ToolExecutor. execute calls trusty-memory’s memory_recall via the tools/call MCP envelope (spike-verified on issue #2348: the daemon wraps the tool result as a STRINGIFIED JSON blob inside result.content[0].text, not a raw JSON value — crate::memory_envelope::parse_tools_call_envelope, the shared unwrap this module originally owned and #2424 promoted so the turn recorder writes through the same shape, handles that), over-fetching top_k * [OVER_FETCH_FACTOR] results because the daemon cannot tag-filter server-side (filtering happens client-side, AFTER the daemon’s own truncation — see the spike comment on #2348). Results are filtered to those tagged session:<id> (matching the exact tag memory_sink::write_turn writes), capped at top_k (clamped to MAX_TOP_K), and truncated to fit [TOKEN_BUDGET] (the epic’s recall_injection_reserve) by dropping WHOLE lowest-scored results (never mid-text) — daemon results already arrive score-sorted highest-first, so this is a simple prefix take. Unreachable daemon / malformed response is fail-open: a successful (non-error) ToolResult carrying an explicit “unavailable” message plus a tracing::warn!, so a flaky trusty-memory never derails the agent loop. Test: recall_session::tests::*.

Structs§

RecallSessionTool
ToolExecutor for the recall_session tool (#2348).

Constants§

DEFAULT_TOP_K
Default top_k when the model omits it.
MAX_TOP_K
Hard cap on top_k regardless of what the model requests — keeps a single call bounded even if the model asks for an unreasonable count.
RECALL_SESSION_TOOL_NAME
The tool’s registered/advertised name.