[Bug]: Memory extraction silently extracts 0 memories — ReAct loop exhausts max_iterations=3 on read results padded to ~820 blank numbered lines
Environment
openviking-server0.4.17 (pip), Python 3.12.11, Linux x86_64auth_mode: api_key, local AGFS + local vectordb- Embedding:
BAAI/bge-m3(1024-dim) over an OpenAI-compatible endpoint - VLM: a local ~30B instruct model with reasoning disabled, served by vLLM behind an OpenAI-compatible proxy
Symptom
Every session commit reports success and extracts nothing:
INFO - Starting post-commit extraction from 4 archived messages
DEBUG - openviking.session.memory.extract_loop - [assistant]
INFO - Extracted 0 memories for long_term
INFO - Session <id> memory extraction completed
memories_extracted: {"total": 0} on every session, no error logged. This holds for a
minimal synthetic session containing unambiguous durable facts:
user: My name is <name>. Remember this preference for all future sessions:
I always want services bound to loopback only, never the overlay network,
for anything holding memory or credentials.
assistant: Understood, loopback only.
user: Also remember: my private git forge is at <host>:<port> and I never push to GitHub.
assistant: Noted.
Expected: at least one preferences memory. Actual: zero, silently.
Root cause
At DEBUG the assistant content shows the model doing the right thing — reading existing memory files before deciding what to write:
{"tool_call_name": "read",
"args": {"uri": "viking://user/<user>/memories/profile.md"},
"result": {"page_id": 3,
"content": "1\t# profile.md - Who Are You?\n2\t\n3\t- Date of birth\n …
820\t\n821\t\n822\t\n"}}
The read tool pads its result to ~820 numbered lines, almost all empty, for a file whose
real content is a dozen lines of template. With 11 memory types registered and
# openviking/session/memory/extract_loop.py:99
max_iterations: int = 3,
the ReAct loop spends its entire budget reading padded whitespace and never reaches a write.
It then exits through the Extracted 0 path without surfacing an error, so the failure is
invisible to operators — this looked healthy to me for hours because I was checking for
errors rather than for results.
Ruled out
- Model can't tool-call. It emits correct
tool_callsat 1, 5 and 11 tool definitions with a long system prompt (finish_reason: tool_calls, well-formed arguments). - Reasoning/thinking output breaking the parser. A thinking variant of the same model
produced
failure_kind=parse_errorwith prose; a no-thinking variant produces no error at all and still extracts zero.reasoning_effort: minimalmade it worse (empty_response). - Streaming tool-call parsing.
vlm.stream: falsechanges nothing. - Token ceiling.
vlm.max_tokens: 4096,finish_reasonis neverlength.
Raising max_iterations from 3 to 8 locally did not help on its own, which suggests the
padded read output also consumes enough context to crowd out the write step, not just
iterations.
Suggested fixes
- Don't pad
readresults to a fixed page height — return only lines that exist. This looks like the actual defect; the padding is pure context cost. - Make
max_iterationsconfigurable viaov.confrather than a constructor default. - Surface iteration exhaustion as a warning. A silent
Extracted 0is indistinguishable from "nothing was worth remembering", which makes this very hard to notice in production.
Happy to supply fuller DEBUG logs if useful.
I investigated current main but could not reproduce the reported fixed ~820-line padding from source alone, so I do not want to claim that root cause is confirmed. I did verify a narrower context-budget gap: optimize_tool_result("read", ...) already truncates content to 1,000 characters, but add_tool_call_pair_to_messages() serializes raw read results without invoking it. A local two-line wiring fix plus regression passes 11 focused tests, Ruff, format, and diff checks without mutating the original result. I have kept commit c147e41c local pending confirmation that extraction-loop read context should use the existing truncation policy; iteration-exhaustion warnings should remain a separate follow-up.
Confirming this silent-0-memories behavior on v0.4.17(.1) — in our case the loop was burning iterations on (a) DSML-markup tool calls leaked into content by DeepSeek V4 models and (b) prose answers from a thinking model (kimi-k2.6), after which the retry ran with tools disabled. Everything looked green from the API side; only the session archive's .failed.json told the truth.
Two things that helped us: a small patch to extract_loop.py (DSML rescue + continue-with-tools nudge, https://gist.github.com/tizerluo/f26126f1cd666dcc7598fc6bb3631455, details in #4580), and operationally: check data/viking/<account>/user/<user>/sessions/*/history/*/.failed.json — that's where the real extraction errors are recorded when the API surface stays silent.
Opened a fix PR: https://github.com/volcengine/OpenViking/pull/4633
Follow-up for suggested fix 2: configurable extract max_iterations — https://github.com/volcengine/OpenViking/pull/4636
Opened follow-up for suggested fix 3 (exhaustion observability): https://github.com/volcengine/OpenViking/pull/4639
Thanks for your feedback, but we are unable to reproduce this issue. Please try verifying with other models. We look forward to your further feedback.