Repository navigation
fix: surface truncated upstream streams instead of silent end_turn - #239
Merged
Merged
Conversation
Follow-up to #221 (PR #222): the reporter still sees the agent stop while outputting a long conclusion. If the relay drops the SSE stream mid-generation (before message_delta/message_stop), the loop received no done event, finishReason stayed undefined, and emitCompletion defaulted it to a clean end_turn — the client then ended the turn mid-text with no indication anything went wrong, which reads as the agent silently stopping. Detect the abnormal termination (no done event in the round) and emit an explicit [acp-proxy: upstream stream truncated (...)] error block plus an error-level log, so truncation is visible and diagnosable instead of masquerading as a normal turn end. Refs #221
Closed
Contributor
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-239Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr239.tgz
npm install -g packageThis comment is automatically updated on each push. |
This was referenced Aug 25, 2026
Merged
Closed
ranxianglei
pushed a commit
that referenced
this pull request
Aug 26, 2026
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.
cskwork
pushed a commit
to cskwork/billion-context
that referenced
this pull request
Oct 21, 2026
…ei#221) 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 ranxianglei#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #221 / PR #222.
What the reporter still sees
After PR #222 (thinking-replay fix), the agent no longer stops right after every ACP marker, but stops still occur, seemingly while the model outputs its long conclusion (#221 latest comment).
Root cause of this residual failure mode
If the relay drops the SSE stream mid-generation — before
message_delta/message_stop(long conclusions are exactly where flaky relays truncate) — the loop's round ended with:doneevent →finishReason === undefinedemitCompletion({ finishReason: undefined })defaultedstop_reasonto a cleanend_turnSo the client received a protocol-clean turn end in the middle of the conclusion text: no error, no retry, the agent just silently stops. This matches "stops while outputting the conclusion".
Fix
Detect abnormal round termination (no
doneevent in the round) and, in the terminal branch:[acp-proxy: upstream stream truncated (no completion event; round N, X text chars + Y reasoning chars received)]error block (still ends the SSE cleanly), and[acp-loop] upstream stream truncated ...)Truncation is now visible and diagnosable instead of masquerading as a normal turn end. Kept master's
suppressCompletionpassthrough semantics intact.Tests
tests/upstream-truncation.test.ts(3 tests):[acp-proxy: upstream stream truncatederror + cleanend_turnround 2identified in the errorFull suite: 596 pass, typecheck + build clean.
Refs #221