[Bug]: extraction empty_response has no adaptive batch-shrink retry — one oversized batch fails the archive permanently
Issue Origin
Observed or reproduced in a real environment
Problem Statement
When an extraction VLM returns an empty content string (finish_reason: length, all
budget consumed by reasoning tokens), extract_loop marks the task empty_response and
stops. There is no adaptive fallback: the already-planned batches are not
re-planned smaller and the failing batch is never retried. One oversized batch therefore
fails the whole archive permanently.
Reproduced on v0.5.0. Same archive failed 3× in a row, ~18 min each, extracting 0
memories — a permanent, self-reinforcing failure that requires the operator to discover
and set auto_commit_policy manually.
Repro environment
- OpenViking 0.5.0 (PyPI), macOS arm64, Python 3.13
- VLM:
sensenova-6.8-flash-lite,reasoning_effort: low, nomax_tokensinov.conf - A single session of ~163 messages / 164 KB of conversation text
Measured behaviour
Replaying the real conversation against the real assembled extraction prompt:
| prompt_tokens | finish_reason |
completion | content |
|---|---|---|---|
| 79,738 | length |
reasoning 32,768 | 0 bytes (empty) |
| 23,564 | length |
— | 0 bytes (empty) |
| 19,735 | length |
— | 0 bytes (empty) |
| 13,063 | stop |
reasoning 5,250 | OK |
The 164 KB archive is split into 10 batches once pending_token_threshold: 12000 is
set, and every batch then completes successfully (task: completed, 91 s,
memories_extracted: {memory_edit: 1}).
Two ruled-out explanations (both verified against the real prompt assembly, not guesses):
- Output cap size is irrelevant. Cap 32768 → reasoning 32,768 / content 0. Cap
65536 → reasoning 65,536 / content 0. Both fail identically, so lowering or raising
max_tokenscannot help. extraction_output_format: jsondoes not help. The JSON contract is larger (31,137 vs 27,250 chars), prompt_tokens rises to 81,156, and the result is still empty. #5514's JSON workaround targetsparse_error, notempty_response.
Where the retry should live
session/memory/extract_loop.py:1272
self._last_llm_failure_kind = "empty_response" if not content else "parse_error"
After this assignment the batch is abandoned. plan_extraction_batches
(session/extraction_batch.py:87, called at session/session.py:1869) is never re-invoked
with tighter limits, so the failure is terminal rather than degradable.
Suggested fix
On empty_response, halve the batch (or split it at the message boundary immediately
preceding the current cut point) and retry, bounded to a small attempt budget so a
genuinely bad prompt still surfaces as a failure rather than looping. Reusing
plan_extraction_batches with a halved ExtractionBatchLimits keeps the splitting logic
in one place.
Why this matters beyond this case
The operator-visible symptom is indistinguishable from the model being incapable: the
task reports failed with empty_response, and nothing in the output hints that a
smaller batch would have succeeded. auto_commit_policy being None by default makes
this the default outcome for any large session, so the most likely first response is
"change models" — which the data above shows does not help at all.
Researched with local source inspection and direct A/B measurement against the real production prompt; no reproduction scripts or credentials included. Related: #5650 (flash-tier extraction failures), #5514 (JSON output format), #5881 (idle auto-commit).
Thanks for the detailed report and measurements.
We consider this a model configuration and commit-frequency issue. For memory extraction:
- Use a fast model that reliably handles your expected input size, with deep thinking disabled.
- Commit regularly based on message count or token volume, instead of accumulating a large session. Your successful run with
pending_token_threshold: 12000provides a useful starting point for this setup.
When the model still returns no usable output after retries, reporting extraction failure is expected. We are not planning automatic batch-shrink retries for this case.
Closing for now. If the problem persists with smaller commits and thinking disabled, please reopen with the relevant configuration and error logs, with credentials removed.