[Bug]: Failed Phase-2 archives are never retried or covered by later commits — covered_failed_archives is always empty, so extraction failures are silent and permanent
Issue Origin
Observed or reproduced in a real environment
Bug Description
A failed Phase-2 (memory extraction) archive is never recovered, and the code already contains the mechanism that was meant to recover it — nothing ever populates it.
What happens today:
-
Phase 2 fails →
_write_failed_marker(archive_uri, stage="memory_extraction", ...)writes.failed.jsonand the task is markedfailed(openviking/session/session.py, theexcept Exceptionaround the Phase-2 run).resume_queued_commit()then returnsTrue, so the queue treats the delivery as complete — the message is not redelivered. -
A later commit processes only its own archive.
_prepare_phase2_archive_messages()returnscovered_failed_archives=[]unconditionally, with the docstring "Prepare only the current archive, preserving its retry progress":return (current_messages, current_archive_id, current_archive_id, [], completed_memory_steps)I checked this function in 0.4.23, 0.5.0 and current main — identical in all three.
-
The coverage mechanism itself exists: the archive's
.donecarriescovered_failed_archives, andsession/archive_store.pyuses that field (plus coverage ranges) to treat failed archives as already covered. Because the producer always returns[], the mechanism never fires.
Net effect: an archive whose extraction failed stays failed forever. Its messages.jsonl is preserved, but the memories are never extracted, and the failure is silent to the client — the commit HTTP call already returned success (task accepted) before Phase 2 ran, so the integrating agent/harness has no signal and its watermark has already advanced.
This is adjacent to, but distinct from, the manual-retry proposals: #3340 and #5802 ask for an endpoint to re-run a failed archive by hand. The point here is that the automatic recovery path is already designed and dead-coded, so "wait for the next commit" does not work either. Related closed items: #4982, #4949. Failure classes that would feed this: #6096 / #6104.
Steps to Reproduce
- Run a self-hosted server and let a Phase-2 extraction fail (provider timeout, parse error, or output-budget exhaustion all work — see logs below).
- Observe
.failed.jsonnext to the archive and the task markedfailedinGET /api/v1/tasks. - Keep using the session so further commits happen.
- Inspect the later archive's
.done:covered_failed_archivesis[], and the failed archive is never processed again. Deleting.failed.jsonby hand is the only thing that helps, and nothing does that.
Expected Behavior
Either:
- a later commit covers previously failed archives (the existing
covered_failed_archivesdesign), or - if automatic coverage is intentionally out of scope, the server surfaces the failure to the caller/operator instead of silently dropping that window's memories (task status is async and not visible to the integrating harness).
Actual Behavior
Failed archives accumulate silently. On one self-hosted instance (single user, ~3 weeks):
3188archives with.done253archives with.failed.json(≈7.4%)- Failed-vs-completed for the same instance over the last week: 8 of 56 commits failed on 10-17, 2 of 19 on 10-18.
Error Logs
Sample .failed.json:
{
"stage": "memory_extraction",
"error": "Error code: 400 - {'error': {'message': 'Provider returned error', 'code': 400, 'metadata': {'raw': '{\"error\":{\"message\":\"Thinking mode does not support this tool_choice ...'",
"failed_at": "2026-10-13T03:59:58.987Z",
"skipped": true,
"completed_memory_steps": {"long_term": [...]}
}
Server log for the same path:
ERROR | openviking.session.memory.extract_loop:run:428 - Failed to parse memory operations (iteration 2/2)
failure_kind=parse_error error=Line 1: field 'content' does not support edit()/drop(): merge_op=replace
requires the complete new value, ...
ERROR | openviking.session.session - Phase 2 step long_term failed: Final response could not be parsed as operations after 2 iterations
Failure classes observed on this instance (168 tasks, 103 failed): 77 × provider 400 on thinking + forced tool_choice (masked by provider fallback), 17 × parse_error (model wrote content.edit() on a [replace] field), 7 × request timeout, 1 × empty_response (output budget consumed by reasoning, finish_reason=length), 1 × proxy 502.
OpenViking Version
0.4.23 (installed). Behaviour verified identical in 0.5.0 (PyPI wheel) and current main for _prepare_phase2_archive_messages and the failure-marker path.
Python Version
3.14.6
Operating System
Ubuntu 24.04 (Linux x86_64)
Model Backend
OpenAI-compatible endpoint (OpenRouter through a local proxy), deepseek/deepseek-v4.1-flash and deepseek/deepseek-v4.1-flash-1017
Additional Context
- The failure is invisible end-to-end: the commit request returns 200 with a task id, Phase 2 runs asynchronously, and only
GET /api/v1/tasksshowsfailed. The integrating plugin cannot retry what it cannot see. - We would be happy to test a fix: this instance has 253 failed archives available, and the coverage path is reproducible by simply observing that
covered_failed_archivesstays[]in every later.done. - Cross-references: #3340, #5802 (manual retry endpoint, in review), #4982, #4949 (closed), #6096, #6104 (one upstream cause of the failures).
I opened #6266: https://github.com/volcengine/OpenViking/pull/6266
It implements the automatic coverage path for failed Phase-2 archives: failed memory_extraction predecessors are rolled into the next successful commit, their per-step progress is merged, and their ids are recorded in covered_failed_archives. Pending, cancelled, and overview-only failures are left untouched. The roll-forward is bounded to 20 archives per commit so a large backlog drains over several commits. This is complementary to the manual retry endpoint in #5802.
Thanks for working on this. Our current commit design intentionally fails fast and keeps failure handling simple. We accept some loss of consistency and memory coverage in exchange for overall performance and a simpler pipeline. The impact on memory quality is acceptable for our use case, so we do not intend to add complex fault tolerance or strong consistency guarantees to the normal commit path.
Automatic recovery through roll-forward, as proposed here, introduces considerably more complexity. We would need to distinguish transient failures from problematic input, prevent a failed archive from causing newer commits to fail, handle memories already generated by a partially successful run, and account for message ordering when older messages are processed after newer ones. The attempt limit bounds repeated failures, but does not isolate newer commits from them.
[PR #5802](https://github.com/volcengine/OpenViking/pull/5802) has now been merged and provides explicit retries for individual archives. We consider this an acceptable user-initiated recovery mechanism. Given these trade-offs, I would prefer to keep the normal commit path simple and use explicit archive retries for recovery rather than introduce automatic roll-forward here.