fix: prevent llm fallback retries after output - #7233
Open
chenghao-mou wants to merge 4 commits into
Open
Conversation
Mark post-output API errors non-retryable when retry_on_chunk_sent is false, so the outer LLMStream retry loop cannot replay text or tool calls. Preserve retries before output and explicit opt-in retries after output. Addresses AGT-3492 Based on the diagnosis and reproducers in livekit/agents-js#2477. Related fix: livekit/agents-js#2480 Co-authored-by: Dan Tran <7690403+dtran26@users.noreply.github.com>
Track text and tool-call output when each chunk enters the stream channel, before a provider can raise and retry within the same event-loop turn. Apply the fallback adapter's retry policy to foreground child streams. Preserve metadata-only retries, recovery probes, and explicit opt-in retries. Addresses AGT-3492 Fixes Devin's "Child retries still replay output" finding on e295c64.
Apply the output retry policy to the fallback stream so both retry loops use LLMStream's guard. Remove the adapter's duplicate error assignment.
Keep the fallback retry policy and main's caller-span initialization.
chenghao-mou
added a commit
to livekit/agents-js
that referenced
this pull request
Sep 14, 2026
Apply the fallback output policy to foreground child streams and the outer stream. Record output at enqueue time, then mark the original APIError non-retryable in the shared retry guard. Preserve pre-output, recovery, direct provider, and explicit opt-in retries. Port the retry guard from livekit/agents#7233 at 50a5924b7e0e. Addresses AGT-3492
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.
Child and outer retries could replay text or tool calls after provider output. Both now use the shared retry guard when
retry_on_chunk_sent=False. Preserve pre-output, metadata-only, and explicit opt-in retries.Addresses AGT-3492. Builds on @dtran26's diagnosis and reproducers in agents-js#2477 and the outer-retry fix in agents-js#2480.
Validated: 57 fallback tests and
make check; 2,933 broader tests passed before the final cleanup. Excluded baseline Google credential and missinglivekit-serverfailures, reproduced on main.Initial prompt and agent context
Model: GPT-6