[Bug]: memory extraction executes tool calls that were never advertised, and hides the model's own call so it cannot self-correct
Summary
During post-commit memory extraction, OpenViking executes tool calls that it never advertised to the model. The extraction VLM emits a function call with an invented name, session_extract_context_provider.execute_tool() dispatches it against the process-global memory-tool registry, and the loop continues instead of treating it as a protocol violation. The resulting error is fed back as a comment with no record of the call that caused it, so the model cannot see what it did wrong and repeats the class of mistake within the same run.
Benign in outcome (extraction still completes) and expensive in time on a local single-slot inference box: each event costs one wasted ReAct iteration.
Environment
- OpenViking v0.5.2.1 (container
ghcr.io/volcengine/openviking:v0.5.2.1) - Memory backend integration: Hermes agent plugin (external
examples/hermes-pluginlineage) memory.eager_prefetch: defaulttrue;memory.extraction_output_format: defaultpython;server.agent_evolution.enabled:true- Inference backend (disclosed as requested):
Qwen3.8-Flash-Next, served locally by oMLX 0.7.3, non-streaming,temperature 0.0,vlm.max_concurrent: 1 - Store size at the time: 4517 memory files (3743 self scope + 774 peer scope)
The model is not the subject of this report. A general-purpose chat checkpoint will sometimes emit function-call markup it learned from training data. The report is that nothing in OpenViking rejects a call for a tool that was never offered.
Observed symptom
Appears in the VLM request log as a role: user turn that OpenViking itself injected:
# search_memories failed for {'keywords': 'SYNC-1 fire 16, upstream sync, FEAT-1 adoption', 'memory_type': 'cases'}.
search_memories_error = {'error': 'Unknown tool: search_memories'}
Emitter: session/memory/extraction_output_protocol/python_protocol.py:471.
Root cause chain
session_extract_context_provider.py:624-629-get_tools()returns[]wheneager_prefetchis enabled (the default), because all content is already preloaded.extract_loop.py:229-235-_tool_schemasis built fromget_tools(), so it is empty;extract_loop.py:1228-1232then sends an empty tools list, which never reaches the wire. Verified: 0 of 51 logged extraction requests carried atoolsarray.- Despite that, a parsed tool call comes back and
session_extract_context_provider.py:607-612dispatches it:
tool = get_tool(tool_call.name)
if not tool:
return {"error": f"Unknown tool: {tool_call.name}"}
get_tool() consults the global MEMORY_TOOLS_REGISTRY (tools.py:455-457, exactly read, search, ls). It never checks tool_call.name against what this phase advertised. Under eager_prefetch the advertised set is empty, so any registered name is executable and any unregistered name produces the log line above.
python_protocol.py:386-396renders the result and doesdel call_id: the assistant tool-call turn is not written back into the message list. The model receives an orphan failure comment with no evidence of what it requested.
Why the names are hallucinations rather than missing tools
Proved on real traffic rather than assumed:
- The byte-complete request body of the preceding iteration (23041 prompt tokens) contains the string
search_memorieszero times. It then appears 3 times, all inside the error message OpenViking injected. - The string exists nowhere in the shipped package, nowhere in
ov.conf, nowhere in custom memory templates, and nowhere in the client integration. - The invented arguments are recombined from vocabulary the prompt does supply:
memory_typeappears 11 times (it is the output-schema field name), and the literal placeholder[Keywords]appears in the prefetch line rendered atsession_extract_context_provider.py:575(params={"query": "[Keywords]", ...}).
The model combines in-context field names with an out-of-context tool name. That is expected model behaviour. Executing it is not.
Measured impact, 2 days of real commits
20 distinct invented-tool-call events across 51 extraction-agent requests:
| emitted name | events | note |
|---|---|---|
read_file |
10 | the calling agent's own tool name, with real host paths as path |
search_memories / search_memory / memory_search |
5 | no such tool exists anywhere in the project |
terminal / execute_code |
3 | calling agent's tools, echoed from the summarized transcript |
create_cases |
1 | DSL field vocabulary, not a tool |
read with path= instead of uri= |
1 | real tool, wrong signature -> Access denied for : read permission required |
- Cost per event: one wasted ReAct iteration. Measured 60 s median (2087 output tokens at 35 tok/s) and 153 s worst case, on a single-slot local VLM that also serves per-turn recall, so wasted time competes with live queries.
extract_loop.py:325does set_disable_tools_for_iterationafter an unknown tool, which caps the damage at one extra iteration. That mitigation is why this is not data loss.- Extraction produced memories in every case we checked, so the failure is silent by design. No error reaches the operator, only log noise and burned inference time.
- The final row is the one we would treat as more serious: a legitimate registered tool invoked with arguments drawn from the summarized conversation. That it failed with a permission error instead of reading an arbitrary host path appears incidental, not by construction.
Suggested fixes
- Scope dispatch to the advertised set: in
execute_tool(), reject names absent fromself.get_tools()before the registry lookup, with a distinct error. This also closes the wrong-signature case above. - Echo the assistant tool-call turn back into the message list in python-DSL mode, so the model can see and correct its own call. The
del call_idpath makes the current retry information-free. - Treat an unknown tool name as a protocol violation for the iteration rather than a tool result, and include the valid tool names for this phase plus their required argument names. Today's message says only
Unknown tool: x. - Minor, related: when
get_tools()returns[], the phase arguably should not accept tool calls from the backend at all. The prompt prose ("ONLY read and search tools are available", "there is no read tool") also contradicts itself while the request offers neither tool.
Related issues
- #4580 - extraction yielding 0 memories when the VLM leaks tool-call markup into prose: same boundary problem, opposite symptom.
- #5296 - extractor copying placeholder URI examples from the prompt and failing with
Access denied: same mechanism of a model echoing in-context vocabulary. - #5526 - a tool call missing
opsilently dropping an update: adjacent robustness gap in the same loop.
Our mitigation
We gated this in our inference server rather than in OpenViking, by refusing to synthesize tool_calls for requests that declare no tools. That suppresses the symptom for that backend only. Any other OpenAI-compatible backend whose chat template emits function-call markup reproduces this report unchanged, so a defensive check inside OpenViking is still warranted.
Report authored by an agent under human supervision, reproduced against a live single-tenant installation. Made under human guidelines with free tokens from local oMLX inference server.
Cross-reference: the companion report on the extraction prefetch path is #6923 (memory.prefetch_search_topn is inert above 5, plus two docstrings that state the wrong defaults). Independent defects, shared root cause: the extraction phase runs with no tools advertised and a preloaded context an operator cannot actually size.
Hi, I'd like to take this one. The scope-dispatch guard (your suggested fix 1) is the right minimal surface, and I'd fold in fix 3's error content since it's the same line:
session_extract_context_provider.py::execute_tool()— before the registry lookup, reject names absent from what this phase advertised (self.get_tools()), with a distinct protocol-violation error that includes the valid tool names for the phase. Undereager_prefetch(advertised set empty) this rejects every invented call, including the wrong-signaturereadrow from your table, before it can touch the global registry or a host path.- Leave fixes 2 (echoing the assistant tool-call turn back) and 4 (prompt prose self-contradiction) out of the first PR — both touch the message protocol and prompt contract, and the advertised-set guard alone removes the wasted ReAct iteration this report is about.
Offline tests: under eager_prefetch an invented name (search_memories) is rejected without consulting get_tool(); a registered name the phase did not advertise (read) is rejected with the valid-names error; with tools advertised, a legitimate call still dispatches.
PR to follow.
Opened #6937 with the scope guard from my plan: execute_tool() now rejects names absent from get_tools() before the registry lookup, with a protocol-violation error listing the valid tools for the phase (your suggested fixes 1+3, same line). Fixes 2 (echo the assistant tool-call turn back) and 4 (prompt prose contradiction) are intentionally left out of the first PR as they touch the message protocol and prompt contract — the guard alone removes the wasted ReAct iteration your report measures, and it holds regardless of which inference backend is behind the extraction.