fix(ollama): remote Ollama streaming stalls at model_call:started on slow hosts#96635
fix(ollama): remote Ollama streaming stalls at model_call:started on slow hosts#96635henrybrewer00-dotcom wants to merge 1 commit into
Conversation
…e not aborted mid-stream
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 2:17 PM ET / 18:17 UTC. Summary PR surface: Source +6, Tests +41. Total +47 across 2 files. Reproducibility: no. live current-main reproduction was run in this read-only review. Source inspection shows the native Ollama path consumes a guarded response body without refreshing its timeout, and the linked issue provides field evidence for the same remote-stream stall. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Merge only after redacted real behavior proof shows the affected remote or slow Ollama path completes and maintainers accept idle-timeout parity for native Ollama streams. Do we have a high-confidence way to reproduce the issue? No live current-main reproduction was run in this read-only review. Source inspection shows the native Ollama path consumes a guarded response body without refreshing its timeout, and the linked issue provides field evidence for the same remote-stream stall. Is this the best way to solve the issue? Yes, likely: refreshing the existing guarded-fetch timer in the native Ollama chunk loop is the narrow provider-owned fix and matches sibling stream wrappers. The remaining gap is real after-fix remote-Ollama proof and maintainer acceptance of the timeout semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a6768d9de567. Label changesLabel justifications:
Evidence reviewedPR surface: Source +6, Tests +41. Total +47 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
@henrybrewer00-dotcom thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
This pull request has been automatically marked as stale due to inactivity. |
Closes #94251
What Problem This Solves
Fixes an issue where users running a remote Ollama provider (Ollama on a different machine than OpenClaw, especially slow CPU-only inference) would never receive a chat response. The session stalls indefinitely at
model_call:started, and the remote Ollama host shows the model going toStopping...mid-generation — the server sees the client disconnect. Directcurlfrom the same host streams fine, so the failure is specific to OpenClaw's native Ollama stream client.Why This Change Was Made
The native Ollama stream path (
createRawOllamaStreamFn) requests a stream throughfetchWithSsrFGuard, which arms anAbortController-based deadline (buildTimeoutAbortSignal) and returns arefreshTimeoutcallback. That callback is the documented contract for converting the deadline into a no-progress (idle) timeout: it must be called as the body is consumed. The OpenAI-compatible transport (src/agents/provider-transport-fetch.ts) and MCP HTTP fetch (src/agents/mcp-http-fetch.ts) both callrefreshTimeout()on every chunk. The Ollama native path destructured only{ response, release }and never called it, so the configured request timeout acted as a hard wall-clock cap. Once a configuredtimeoutSecondselapsed while a slow remote model was still streaming, the request was aborted mid-stream, the server saw a disconnect, and the run stalled. The fix callsrefreshTimeout?.()for each consumed NDJSON chunk, matching the existing sibling contract.User Impact
Remote/slow Ollama hosts now stream to completion: the request deadline behaves as a no-progress timeout (reset on every chunk) rather than a total wall-clock cap. Chat sessions backed by a remote Ollama model return responses instead of hanging at
model_call:started. No config or API changes.Evidence
Added a regression test asserting
refreshTimeoutis called once per streamed NDJSON chunk.Before the production fix (test reverted), the test fails:
After the fix:
Also green on the touched area:
tsgoextensions typecheck (exit 0), oxlint (exit 0), oxfmt --check (all files correctly formatted).