fix(agents): detect truncated API responses to prevent silent session hang#89160
Conversation
|
Codex review: found issues before merge. Reviewed June 1, 2026, 7:49 PM ET / 23:49 UTC. Summary PR surface: Source +55, Tests +148, Config 0. Total +203 across 4 files. Reproducibility: Do we have a high-confidence way to reproduce the issue? Partly: the linked report and proof screenshot demonstrate an Ollama Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Preserve native provider length termination at the Ollama stream boundary, remove the committed proof image, keep the runner guard as a generic safety net, and land only after maintainer acceptance of the fail-closed liveness behavior. Do we have a high-confidence way to reproduce the issue? Do we have a high-confidence way to reproduce the issue? Partly: the linked report and proof screenshot demonstrate an Ollama Is this the best way to solve the issue? Is this the best way to solve the issue? No; the runner guard is a useful safety net, but the best fix must also preserve the provider's native length terminal signal and get maintainer acceptance for the fail-closed lifecycle change. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 086274fd7e7a. Label changesLabel justifications:
Evidence reviewedPR surface: Source +55, Tests +148, Config 0. Total +203 across 4 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
|
a392986 to
5721545
Compare
Real Behavior Proof: Live Ollama Truncation DetectionTested against a real Ollama instance ( Screenshot: Live proof execution (real Ollama API)What was proven
Unit Tests (242 passing)
|
Co-authored-by: joelnishanth <[email protected]>
2036004 to
50e143e
Compare
|
Land-ready verification for
Known proof gap: direct Anthropic live tool calling could not run because available credentials failed billing before prompt/tool execution. No Anthropic or OpenAI transport code changed; shared terminal-output and tool-use behavior has focused regression coverage. |
Preserve Ollama length termination and surface incomplete token-limited embedded-agent turns without discarding durable tool output. Fixes openclaw#89051. Co-authored-by: joelnishanth <[email protected]>
Preserve Ollama length termination and surface incomplete token-limited embedded-agent turns without discarding durable tool output. Fixes openclaw#89051. Co-authored-by: joelnishanth <[email protected]>
Preserve Ollama length termination and surface incomplete token-limited embedded-agent turns without discarding durable tool output. Fixes openclaw#89051. Co-authored-by: joelnishanth <[email protected]>

Summary
Fixes #89051.
done_reason: "length"instead of collapsing it tostop.toolUsesemantics unchanged. No OpenAI or Anthropic transport code changed.Verification
tbx_01kv3kmhyx52hb7w9awywk9rjypassedpnpm check:changedforcore,coreTests,extensions, andextensionTests.Real behavior proof
done_reason: "length"could be normalized to success and leave an embedded run with partial or empty output instead of an incomplete-turn response.qwen3.5:9b; official OpenAI Codex OAuth gateway harness with an MCP/tool probe.num_predict: 3, then exercised the real OpenClaw Ollama stream adapter and incomplete-turn resolver; ranOPENCLAW_LIVE_CODEX_HARNESS=1 OPENCLAW_LIVE_CODEX_HARNESS_MCP_PROBE=1 OPENCLAW_LIVE_CODEX_HARNESS_MODEL='openai/gpt-5.5' node scripts/test-live.mjs --codex-harness -- src/gateway/gateway-codex-harness.live.test.ts.done_reason: "length"; OpenClaw returnedstopReason: "length", partial textThe color of, and the incomplete-turn response. The Codex OAuth MCP/tool smoke passed.