Skip to content

fix(ollama): keep active remote model streams from timing out - #115648

Merged
steipete merged 1 commit into
mainfrom
codex/ollama-stream-idle-timeout-94251
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/ollama-stream-idle-timeout-94251

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #94251.

What Problem This Solves

Fixes an issue where users streaming a slow remote Ollama model would lose an actively progressing response once the initial request timeout expired, even though valid tokens continued arriving.

Why This Change Was Made

Honor the existing guarded fetch's idle-timeout contract whenever an actual Ollama NDJSON response makes progress. Preserve the existing SSRF guard, caller cancellation, dispatcher release, and timeout for a genuinely stalled stream.

This independently reviewed canonical fix builds on @henrybrewer00-dotcom's original diagnosis and patch in #96635. The official-repository commit explicitly retains Henry's original Co-authored-by credit.

User Impact

Users can stream a slow remote Ollama model for longer than the configured idle timeout while valid responses continue arriving. A stream that actually stops responding still times out.

Evidence

The regression uses a real local node:http TCP server and the actual native Ollama application/x-ndjson transport, not a simulated response: it sends token chunks every 35 ms with a 120 ms guarded idle timeout.

Before the fix:

  • The guarded timeout's refreshTimeout callback was called zero times instead of three.
  • The progressing real HTTP NDJSON stream failed before completion.

After the fix:

  • The same progressing real HTTP NDJSON stream completes beyond the initial 120 ms deadline.
  • A real HTTP NDJSON stream that sends one token and then stalls still expires as expected.
  • Caller abort, dispatcher cleanup, and neighboring stream behavior remain covered.

Validation against the exact pushed commit:

  • node scripts/run-vitest.mjs extensions/ollama/src/stream.test.ts extensions/ollama/src/stream-runtime.test.ts: 2 files, 142 tests passed.
  • ./node_modules/.bin/oxfmt --check extensions/ollama/src/stream.ts extensions/ollama/src/stream.test.ts: passed.
  • git diff --check: passed.
  • ./.agents/skills/autoreview/scripts/autoreview --mode commit --commit HEAD --thinking xhigh: clean; no accepted or actionable findings.

Retain the existing guarded-fetch timeout callback while consuming native Ollama NDJSON. Prove active slow HTTP streams remain alive and genuine stalls still expire.

Reconstructed from the independently reviewed contributor fix for #94251.

Co-authored-by: Henry <[email protected]>
@steipete
steipete merged commit f466ad0 into main Jul 29, 2026
90 of 94 checks passed
@steipete
steipete deleted the codex/ollama-stream-idle-timeout-94251 branch July 29, 2026 06:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…115648)

Retain the existing guarded-fetch timeout callback while consuming native Ollama NDJSON. Prove active slow HTTP streams remain alive and genuine stalls still expire.

Reconstructed from the independently reviewed contributor fix for openclaw#94251.

Co-authored-by: Henry <[email protected]>
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…ifecycle-hooks

* origin/main:
  fix(mattermost): key private channels as group on outbound routing (#96645)
  fix(ci): grant Telegram QA runtime scratch access (#115659)
  fix(telegram): stop retrying blocked recipients (#115640)
  fix(tts): persist generated speech in media store (#115647)
  fix(gateway): preserve complete streamed chat completions (#115652)
  fix(mac): prevent app auth from blocking node-host startup (#115533)
  fix(heartbeat): keep message-tool final replies private (#115629)
  fix(gateway): drain root work continuations before direct-stop process exit (#105848)
  fix(ollama): keep active streams within their idle timeout (#115648)
  fix(delivery): keep session keys out of inferred message targets (#115657)
  fix(ci): type code mode matrix catch callback (#115674)
  refactor(agents): centralize bundled CLI backend auth policy (#115633)
  refactor: remove 3,527 lines of runtime and test duplication (#115626)
  [AI] fix(doctor): stop repeated bundledDiscovery migration noise on beta (#115208)

# Conflicts:
#	scripts/code-mode-model-matrix.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama remote provider streaming not consumed — model_call:started never progresses in chat sessions

1 participant