Skip to content

fix(core): reset attempt timeout on received chunks (#87) - #88

Merged
patlux merged 2 commits into
patlux:mainfrom
leon-zym:agent/fix-stream-idle-timeout
Sep 15, 2026
Merged

patlux merged 2 commits into
patlux:mainfrom
leon-zym:agent/fix-stream-idle-timeout

Conversation

@leon-zym

@leon-zym leon-zym commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #87.

In streamCommandCode, attemptTimeoutId was started when the HTTP request begins, but was not refreshed inside readLoop when reader.read() yielded new chunks. This caused timeoutMs (forwarded from Pi's httpIdleTimeoutMs setting, default 300,000ms) to act as a hard wall-clock cap on the total duration of the generation rather than an idle gap timeout between chunks, aborting legitimate long-running reasoning generations (e.g. GLM-5.3-flash with max thinking or DeepSeek models) after 300 seconds.

Changes

  • In src/core.ts (readLoop):
    • Clear the timeout when done is true (response completed).
    • Refresh attemptTimeoutId whenever a new chunk is received, preserving the idle timeout protection against hanging streams while allowing active generations of any length.
  • In tests/test-retry.ts:
    • Added regression test does not abort actively streaming responses that exceed timeoutMs overall (streams for 90ms with 30ms gaps under a 50ms timeout).
  • In CHANGELOG.md:

Test plan

  • npm run typecheck — 0 errors
  • npm run format:check — Prettier clean
  • npm run test:unit — all unit tests pass, including the new regression test and all existing retry/timeout tests

@patlux

patlux commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Integrated current main and widened the active-stream regression timing margin (200ms gaps, 500ms idle limit, >600ms total). Confirmed this test fails on the original implementation and passes with the fix. Existing regression explicitly verifies a stream that emits partial text and then stalls times out without retrying; it remains green. Full npm test passes with real Pi and OMP plus format/diff checks. Waiting for CI.

@patlux
patlux merged commit 6938b15 into patlux:main Sep 15, 2026
15 checks passed
@patlux

patlux commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Shipped in pi-commandcode-provider@0.7.0: https://github.com/patlux/pi-commandcode-provider/releases/tag/v0.7.0 . Public npm package model discovery and GOAT live smoke verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long reasoning streams abort after 300s: treat timeoutMs as chunk idle timeout instead of total wall-clock limit

2 participants