fix: acp-loop auto-retry on no-content upstream truncation (#221) - #261
fix: acp-loop auto-retry on no-content upstream truncation (#221)#261ranxianglei wants to merge 2 commits into
Conversation
|
[bot] Reviewed the PR, verified the core mechanism, and found (and fixed) two edge-case holes in the retry guard. Pushed a follow-up commit to the branch: Verified as designed
Bug 1 — retry after a flushed real tool call (the important one). A truncation can carry a completed tool call: the Anthropic adapter flushes Bug 2 — final-round truncation swallowed the error. On round Tests — added 2 regression cases to
Full suite: 646 pass (was 644). typecheck + build clean. PR is ready for merge whenever you are — I can't merge it myself (AGENTS.md: merges are human-only). 🤖 ework agent · vllm-qwen/qwen3.8-27b |
A relay cutting a long-running request (e.g. MiniMax-M3 thinking server-side for minutes) before any token is emitted ends the upstream SSE with no completion event and zero content. PR #239 made that visible but the agent still stopped, because the proxy surfaced the error and terminated the turn. A truncation that produced no text/reasoning is a clean re-send: nothing reached the client, so the loop re-requests the same body and continues. The retry is treated as a later round so message_start is not re-emitted and no prefix is duplicated. Bounded by BILI_TRUNCATION_RETRY_MAX (default 2 retries; 0 restores the fail-fast error). A partial-content truncation is deliberately NOT retried (the model would regenerate from scratch and duplicate the already-streamed prefix) and still surfaces the visible error.
…call is flushed or on the final loop round
03b7f8f to
4d87ab2
Compare
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-261Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr261.tgz
npm install -g packageThis comment is automatically updated on each push. |
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-261Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr261.tgz
npm install -g packageThis comment is automatically updated on each push. |
Context
Follow-up to #221 (agent stops at the acp tool). PR #239 made the upstream-truncation failure visible (
[acp-proxy: upstream stream truncated ...]), and the user's logs confirm that is the failure mode:But the agent still stopped, because the proxy surfaced the error and terminated the turn.
Root cause
The relay cuts a long-running request (MiniMax-M3 thinking server-side for minutes) before any token is emitted. The upstream SSE ends with no completion event and zero content — nothing reached the client.
Fix
A truncation that produced no text/reasoning is a clean re-send: the loop now re-requests the same body and continues instead of erroring out. The retry is treated as a later round, so
message_startis not re-emitted and no prefix is duplicated.BILI_TRUNCATION_RETRY_MAX(default 2 retries;0restores the fail-fast error).Tests
tests/upstream-truncation.test.ts— 3 new cases:message_start, no error marker)Full suite: 644 pass. typecheck + build clean.