feat: add force parameter to commit to skip blocking failed archives (fixes #2475)
Problem
Closes #2475
A single transient failure (VLM timeout, SSL error, LLM parse error, etc.) during Phase 2 (memory extraction) writes a .failed.json marker that permanently blocks all future commits on that session. There is no auto-recovery, no retry mechanism, and no admin API to clear it.
Real-world impact
When OpenViking is used as an OpenClaw context engine plugin, the afterTurn hook auto-commits on token threshold. A single VLM 180s timeout locks the entire session forever — the user has no way to recover without manually deleting .failed.json files from the filesystem.
Failure chain
- Session commits → Phase 1 (archive) succeeds
- Phase 2 (memory extraction) fails (VLM timeout, SSL error, etc.)
.failed.jsonis written to the archive directory- All subsequent
POST /sessions/{id}/commitreturnFAILED_PRECONDITION - Session is permanently locked
Additionally, the failure cascades: archive_002 fails → archive_003's _wait_for_previous_archive_done() sees 002's .failed.json → 003 also writes .failed.json → archive_004 blocked → entire session dead.
Solution
Add a force: bool = False parameter throughout the commit flow. When force=True, both the Phase 1 and Phase 2 blocking checks are skipped with a warning log.
Changes
| File | Change |
|---|---|
session.py |
commit_async(force=False): skip _get_blocking_failed_archive_ref() when force=True |
session.py |
_run_memory_extraction(force=False): skip _wait_for_previous_archive_done() when force=True |
session.py |
create_task call: pass force=force to _run_memory_extraction |
session_service.py |
commit_async(force=False): pass through to session |
sessions.py router |
CommitRequest: add force: bool = False field, pass through |
Design decisions
- Default
force=Falsepreserves existing behavior — no breaking changes force=Trueonly logs a warning, does not delete.failed.json— the marker stays for debugging- Phase 1 and Phase 2 both need independent
forcehandling because Phase 2 runs in a backgroundasyncio.create_task()with its own_wait_for_previous_archive_done()check
Testing
Verified in production:
- VLM timeout →
.failed.jsonwritten → session locked - With
force=True: commit proceeds, Phase 2 runs, new memories extracted - Without
force: existingFAILED_PRECONDITIONbehavior unchanged
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
|
🎫 Ticket compliance analysis ✅ 2475 - Fully compliant Compliant requirements:
|
| ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
| 🏅 Score: 90 |
| 🧪 No relevant tests |
| 🔒 No security concerns identified |
| ✅ No TODO sections |
| 🔀 No multiple PR themes |
| ⚡ No major issues detected |
PR Code Suggestions ✨
No code suggestions found for the PR.
有点没看懂,为什么要引入独立 pending queue