[Bug] session_commit intermittently fails: streaming calls to Ark time out after retries exhaust — large commits hit it most
Issue Origin
Observed in a real local deployment (OpenViking v0.4.22, macOS, local server, Doubao VLM doubao-seed-2.1-lite via Ark plan gateway /api/plan/v3), 2026-09-30, ~15:30–20:30 CST.
Bug Description
session_commit tasks intermittently fail with ArkAPITimeoutError during Phase 2 (long_term / archive_summary, incl. the WM streaming path). The streaming response stalls beyond the client read timeout; retries exhaust; the whole commit task is marked failed.
Key characteristics:
- Dominant failure class: of ~37 Phase-2 step failures in the observed window, 35 were
Request timed out(the rest: 1 parse_error, 1 unrelated TypeError). - Non-deterministic: the same session that failed at 19:56 succeeded on a manual re-commit 25 min later (48.8 s, extracted 4 memories).
- Size-correlated: commits archiving 100–218 messages fail frequently; an 18-message commit passed in 49 s.
- Duration pattern ≈ read-timeout × attempts: 67 s / 120 s / 653 s / 869 s observed (vlm
timeout=180,max_retries=2). - Recoverable: failed sessions succeed when re-committed (verified), so impact is "memories missing until re-commit", not permanent loss.
- Queue amplification: SessionCommit queue is a single worker — a stalled commit blocks subsequent commits.
Evidence
Error (repeated, request ids differ):
volcenginesdkarkruntime._exceptions.ArkAPITimeoutError: Request timed out.,
request_id: ToB-direct,OpenViking_Service,openviking-service_cn-beijing,<hex>
Traceback tail: streaming_batcher.flush → policy_trainer._process_batch → model_retry.retry_async → ark client request → httpcore.ReadTimeout (http11._receive_event)
Sample task ids (all session_commit, 2026-09-30 CST): 181463a7… (failed 10m53s, session with 51 archived msgs), 30df2d3a… (failed 527s, 218 archived msgs), 6044222c… (failed 869s), plus 32 more within GET /api/v1/tasks?status=failed.
Reproduction pointer: submit a large session commit while the upstream is slow; retries exhaust in model_retry.retry_async and the task ends failed (Result timed out).
Environment
- OpenViking v0.4.22 (uv tool install), Python 3.13 runtime
ov.conf:vlm.timeout=180,vlm.max_retries=2, provider volcengine,api_base=https://ark.cn-beijing.volces.com/api/plan/v3- Direct network for
*.volces.com/*.siliconflow.cn(NO_PROXY set), other traffic via local proxy
Ask
- Recommended
timeout/max_retriesfor the WM streaming path — any tuned defaults for large commits? - Is anything like the resource-aware scheduling in #4028 (and queue priority in #4578) on the roadmap? Long stalls blocking the single worker amplify this.
- Would it be reasonable to treat these as retryable at the phase level with backoff rather than failing the whole commit?
(Related: #4028, #4578. Happy to provide fuller logs via a private channel if useful.)
Follow-up question (skipped sessions after a failed commit): when a commit fails in Phase 2 (e.g. streaming timeout), a later re-POST of /api/v1/sessions/{id}/commit for some sessions returns {"status":"ok","result":{"status":"skipped","task_id":null}} with no live messages — i.e. the failed batch's extraction cannot be re-triggered via commit, and there seems to be no re-extract/reprocess entry point in the API. Is re-running extraction for such a session/archive supported (or planned)? Locally this affects ~12 sessions whose failed batches sit unextracted. (Related: #4578, #4028.)
Field data on the re-extract dead end — 18 retried sessions, 12 of them unrecoverable via /commit.
Context: this is the follow-up to my question above. On 2026-09-30 (v0.4.22, macOS) I took the set of sessions whose commit had failed and re-POSTed POST /api/v1/sessions/{sid}/commit on each, serially, one at a time.
Result split (18 sessions):
| outcome | count | meaning |
|---|---|---|
completed |
5 | the re-commit genuinely re-ran and succeeded (42–90 s each) |
skipped |
12 | no live messages left — dead end |
failed |
1 | 'list' object has no attribute 'strip' (deterministic, see #5515) |
Verbatim response for a skipped one (all 12 are identical apart from the id):
{"status":"ok","result":{"session_id":"cc-e605aaef-7a5b-49e2-b136-cfa27f13902d","status":"skipped","task_id":null,"archive_uri":null,"archived":false,"reason":"no_messages","trace_id":""}}
The 12 skipped ids, for completeness:
cc-2c40d60b-88bf-47ff-a654-1aca7af53e1b
cc-e605aaef-7a5b-49e2-b136-cfa27f13902d
hermes-remember-35487620304c
20260930_143938_a97f2d
hermes-remember-c52c705c92ed
hermes-remember-063eed0b0a64
cc-ab425abf-8942-449b-8782-807efdc22929
cc-2116b6d4-b9c7-43aa-b06f-9f21d5af0d92
cc-498fcb4b-23d2-4e9d-80dc-c2c134fcb118
cc-0d7cde26-ede3-4c23-9878-d9d427ad226f
hermes-remember-a422ea6a6868
20260930_174809_ed547d21
Why this matters: two thirds of the failed commits cannot be recovered through the documented path, because the session's messages were already archived when the commit failed — so the "just re-commit" advice silently degrades to a no-op with task_id: null. The only remaining route for them is the archive-based retry, which is what #4295 proposes; failing that, an explicit re-extract entry point would be enough.
No workaround found on this side beyond keeping the archive files. Happy to re-test here once a retry route lands.
Cross-reference: a distinguishing observation — this deployment does not match #5622
Both bugs reach the user as "Phase 2 timed out", so it is worth separating them with data before triage folds one into the other. What #5622 describes versus what this deployment shows:
| #5622 | this deployment | |
|---|---|---|
| log signature | Unterminated string starting at: line 1 column 59183 |
ArkAPITimeoutError: Request timed out. |
| terminal task state | stuck pending indefinitely |
failed (recorded normally) |
| duration | crash ~1.5 s, reported to client after ~232 s | attempts land at the vlm.timeout ceiling (301 / 302 / 302 / 304 / 337 s) |
Checks on this deployment (v0.4.23, macOS, Ark plan endpoint), all zero:
grep -c "Unterminated string" server.log → 0
grep -c "Concurrent worker error for SessionCommit" server.log → 0
grep -c "JSONDecodeError" server.log → 0
Task ledger across every session_commit record: completed 261 / failed 562 / running 1. Nothing has been left pending. The single running record was created 3.3 min before the check (an in-flight commit), not a stuck one.
Verbatim from this deployment:
volcenginesdkarkruntime._exceptions.ArkAPITimeoutError: Request timed out., request_id: ToB-direct,OpenViking_Service,openviking-service_cn-beijing,17fce81b61d84d77a2984381787a950b
Phase 2 step long_term failed: Request timed out., request_id: ToB-direct,OpenViking_Service,openviking-service_cn-beijing,17fce81b61d84d77a2984381787a950b
Takeaway: on this deployment the "Phase 2 timed out" reports are genuine upstream timeouts, not a 1.5 s crash masked as a timeout. The two are cleanly separable by exactly the two markers #5622 highlights — terminal state (failed vs. permanently pending) and the presence of the Unterminated string signature. Worth stating explicitly in the issue text so neither gets folded into the other.
Taking this one — triaged and root-caused, fix in progress.
Root cause (read at HEAD 4c9a755b): call-level retries live only in openviking/utils/model_retry.py:436-455 (retry_async re-raises once attempt >= max_retries); ArkAPITimeoutError is classified transient (:73, :154, allowed by is_retryable_api_error :289-291) but the retry budget is just vlm.max_retries. The exception then propagates unguarded through policy_trainer.py:307-334 (_process_batch) and streaming_batcher.py:114-142 (flush re-raises after marking item futures), so session.py:2259-2272 sees any failed Phase-2 step and raises → the whole commit task ends failed. The resume path (completed_memory_steps, session.py:2276-2333) exists but only helps on a manual re-commit — there is no phase-level retry/backoff for transient errors. That matches your window (35/37 failures = Request timed out, re-commit succeeds).
Plan: scope this to ask 3 — a bounded, exponential-backoff retry at the Phase-2 step level, reusing the existing transient-error classifier (is_retryable_api_error), configurable, falling through to the existing failed/resume path only when retries exhaust. Not touching vlm.timeout/max_retries defaults (ask 1) or queue scheduling (ask 2) — those deserve maintainer input.
Will open a PR once tests are green. Disclosure: this comment and the upcoming fix were prepared with AI assistance (Claude), reviewed and verified by a human maintainer-of-record (@akushonkamen).
Follow-up with a correction to my triage note above — deeper reading at HEAD 4c9a755b changed the root cause, and it's more tractable than "missing phase-level retry":
Corrected root cause — the retry machinery mostly exists; it just never fires for this error class:
classify_api_error(openviking/utils/model_retry.py) matches transient errors against text patterns that include"timeout"— butArkAPITimeoutError's message is"Request timed out., request_id: …", which contains no contiguoustimeoutsubstring. The error therefore classifies asunknown,is_retryable_api_errorreturns False.- Consequence: neither the VLM call-level retry (
retry_asyncinopenviking/models/vlm/backends/volcengine_vlm.py,vlm.max_retries) nor the Phase-2 step-level retry (_run_retryable_phase2_step, added for long-term extraction in #5364) engages. The first stalled streaming request fails the whole commit — which is why your logs show single-shot failures landing straight onPhase 2 step long_term failed. - Credit where due: #5364 (merged 09-24, likely just missing from your v0.4.22 build) already established the intended retry design — call-level
max_retriesfor transient errors incl. "identified timeouts", step-level retry (3x) kept for long-term extraction, and deliberately no Session-level retry for Working Memory so failures surface instead of producing placeholder summaries. The classifier just fails to "identify" timeouts, so that design never engaged for your dominant failure class.
Fix (local branch fix/5513-phase2-retry, PR to follow after your sign-off on scope):
"timed out"+ bareTimeoutErrornow classify transient → the existing #5364 retry contract actually engages for Ark timeouts (call-levelmax_retries, step-level 3x for long-term).- Since each stall attempt burns the full
vlm.timeout, the Phase-2 step retry now separates stall-class errors (timeout/connection) by 30s→120s exponential backoff instead of the fast-fail 1-8s window, via a new optionaldelay_forhook onretry_async. Retry counts unchanged; exhaustion still lands in the existing failed/resume path; WM propagation untouched.
Tests: new tests/unit/session/test_phase2_step_retry.py — on pristine HEAD a fake VLM raising ArkAPITimeoutError twice then succeeding reproduces the bug (task failed after 1 extractor call); with the fix the same scenario completes, writes .done/completed_memory_steps, and a persistent-timeout case still fails via the existing path after exactly 1+3 calls. tests/unit/session: 324 passed, only the 2 failures that already fail on pristine main (unrelated: extract-loop hydration logging, event-tag meta snapshot).
Still leaving ask 1 (recommended vlm.timeout/max_retries for large commits) and ask 2 (queue scheduling) to you — happy to adjust the 30/120s backoff constants if you'd prefer different defaults.
PR opened: #5927 — implements the corrected root-cause fix from my note above (classify timed out / bare TimeoutError as transient so the #5364 retry contract actually fires for Ark timeouts, plus a stall-aware 30-120s backoff inside the existing Phase-2 step retry; retry counts and the failed/resume path unchanged). Test evidence is in the PR description. Not addressed there (needs maintainer input): vlm.timeout / vlm.max_retries defaults and SessionCommit queue scheduling.