Skip to content

fix(adk): bypass retry for mid-stream graph interruptions - #1478

Open
1828703450qqcom-ux wants to merge 1 commit into
cloudwego:mainfrom
1828703450qqcom-ux:fix/stream-interrupt-bypass-retry
Open

1828703450qqcom-ux wants to merge 1 commit into
cloudwego:mainfrom
1828703450qqcom-ux:fix/stream-interrupt-bypass-retry

Conversation

@1828703450qqcom-ux

Copy link
Copy Markdown

fix(adk): bypass retry for mid-stream graph interruptions

Fixes #1446

Summary

  • The Generate retry path already checks compose.ExtractInterruptInfo(err)
    and returns immediately for interrupt errors. The stream retry paths
    (both ShouldRetry and legacy) did not — a graph interruption delivered by
    a model stream was treated as a retryable error, and the next attempt's
    output replaced the original interruption.
  • Fix: add the same interrupt check to the stream error handling in both
    streamWithShouldRetry and streamLegacy.

Reproduction

From the issue, with a model whose first Stream() call emits one chunk then
an interrupt error, and a second call that succeeds:

  • On main: the retry layer calls the model a second time and returns the
    second attempt's output. The interruption is lost.
  • After the fix: the original interruption error is preserved.

Fix

adk/retry_chatmodel.go — two hunks, both adding the same pattern after
stream error consumption and before the retry decision:

if streamErr != nil {
    if _, ok := compose.ExtractInterruptInfo(streamErr); ok {
        // bypass retry, preserve the original interruption
        ...
        return nil, streamErr
    }
}
  1. streamWithShouldRetry: added after typedConsumeStream and before
    ShouldRetry is called.
  2. streamLegacy: added after consumeStreamForError and before
    isRetryAble is called.

The Generate path (both ShouldRetry and legacy) already has the same check
and is unchanged.

Validation

  • Full adk suite: go test ./adk/ -count=1 -timeout 120s → ok (49s).
  • All retry/stream tests pass (go test ./adk/ -run "Retry|Stream" -count=1).
  • go vet clean.

Scope

  • 1 file: adk/retry_chatmodel.go (two hunks in stream retry paths).
  • No change to the Generate retry path, retry policy, backoff computation,
    or any other logic beyond interrupt bypass.

The Generate retry path already checks compose.ExtractInterruptInfo
and returns immediately for interrupt errors. The stream retry paths
(both ShouldRetry and legacy) did not, so a graph interruption
delivered by a model stream was treated as a retryable error and the
next attempt's output replaced the original interruption (issue cloudwego#1446).

Add the same interrupt check to the stream error handling in both
streamWithShouldRetry and streamLegacy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

adk: mid-stream graph interruptions are retried instead of preserving the original error

1 participant