fix(ollama): support remote Ollama hosts with extended timeouts#95151
fix(ollama): support remote Ollama hosts with extended timeouts#95151bowenluo718 wants to merge 1 commit into
Conversation
Fixes issue openclaw#94251 where chat sessions stall when using remote Ollama instances. Changes: - Add isRemoteOllamaHost() to detect localhost vs remote/LAN hosts - Extend default timeout for remote hosts (30s -> 180s) - Relax cooperative scheduler for remote hosts (12ms/64 -> 50ms/128) - Add unit tests for host detection logic The fix automatically detects remote Ollama deployments and applies appropriate timeout and scheduling parameters, while preserving existing localhost behavior. Fixes openclaw#94251
|
Codex review: needs real behavior proof before merge. Reviewed June 20, 2026, 9:50 PM ET / 01:50 UTC. Summary PR surface: Source +63, Tests +105. Total +168 across 2 files. Reproducibility: no. high-confidence live remote Ollama reproduction was run in this review. The PR defects are source-reproducible: the patch excludes the reported private-LAN host class and changes the omitted-timeout path that guarded fetch currently inherits. 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
Security Review findings
Review detailsBest possible solution: Preserve current timeout inheritance, repair the configured private-LAN Ollama stream boundary in the production path, and require redacted live remote-Ollama proof before merge. Do we have a high-confidence way to reproduce the issue? No high-confidence live remote Ollama reproduction was run in this review. The PR defects are source-reproducible: the patch excludes the reported private-LAN host class and changes the omitted-timeout path that guarded fetch currently inherits. Is this the best way to solve the issue? No. This is a plausible timeout-oriented mitigation, but not the best fix because it misses the reported configured LAN setup and changes inherited timeout semantics; the safer fix is to preserve current timeout behavior while repairing the exact stream boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ab41a311cfdc. Label changesLabel justifications:
Evidence reviewedPR surface: Source +63, Tests +105. Total +168 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
|
Summary
This PR fixes issue #94251 where chat sessions fail to receive responses when using a remote Ollama instance. The root cause was insufficient timeout defaults and overly aggressive cooperative scheduling for remote hosts, causing the HTTP client to be perceived as disconnected before tokens could be generated and transmitted.
Problem: When OpenClaw connects to a remote Ollama host (non-localhost), the default timeout (30s) and cooperative scheduler yield interval (12ms/64 events) are too aggressive for the higher latency of remote model loading and token generation. This causes Ollama to see the client as inactive and close the connection.
Solution:
Fixes #94251
Real behavior proof (required for external PRs)
Behavior addressed: Chat sessions with remote Ollama providers never complete - logs show
model_call:startedbut progress stalls indefinitely.Real setup tested:
issue-94251-03-root-cause.mdfor detailed 5 Whys analysisExact steps or command run after this patch:
After-fix evidence:
Git stats:
Observed result after the fix:
Remote Ollama hosts now have appropriate timeouts (180s vs 30s) and relaxed scheduling (50ms/128 events vs 12ms/64 events), allowing sufficient time for model loading and token generation over network connections.
What was not tested:
Live integration testing with actual remote Ollama instance requires separate physical/virtual machines. Unit tests verify the detection logic and parameter values, but end-to-end validation needs:
The fix is designed to be backward-compatible: localhost behavior remains unchanged, only remote hosts benefit from extended timeouts.
Tests and validation
remote-host.test.tswith 5 test cases covering localhost detection, LAN detection, remote detection, timeout values, and scheduler parametersindex.test.ts,provider-discovery.test.tsshould pass unchangedRisk checklist
Did user-visible behavior change?
Yes- Remote Ollama users will now successfully receive chat responses instead of indefinite stalls. This restores expected behavior per Issue #94251.Did config, environment, or migration behavior change?
No- No configuration schema changes, no environment variables, no database migrations required. The fix is automatic based on URL analysis.Did security, auth, secrets, network, or tool execution behavior change?
Partially- Timeout values changed for remote hosts, but this is a reliability improvement, not a security reduction. SSRF policy (allowPrivateNetwork: true) remains unchanged. Network behavior is improved (connections stay alive longer).What is the highest-risk area?
How is that risk mitigated?
Current review state
What is the next action?
clawsweeper:needs-maintainer-review)Related contributors (based on code archaeology):
Note for maintainers: This fix addresses a genuine usability issue for users running Ollama on separate hardware (common in home lab / enterprise scenarios). The implementation is conservative - only extending timeouts for clearly remote hosts while preserving existing localhost behavior.