Skip to content

agent: Cancel retries when the turn is cancelled#50580

Merged
benbrandt merged 1 commit intomainfrom
tomhoule-mslkxlrxxlnr
Mar 3, 2026
Merged

agent: Cancel retries when the turn is cancelled#50580
benbrandt merged 1 commit intomainfrom
tomhoule-mslkxlrxxlnr

Conversation

@tomhoule
Copy link
Copy Markdown
Contributor

@tomhoule tomhoule commented Mar 3, 2026

When a completion request fails with a retryable error (e.g. a 500 from the upstream provider), the retry loop waits on a timer before trying again. This timer did not race with the cancellation signal, so if the user switched models and submitted a new message during the retry delay, the old turn would continue retrying with the stale model for up to 15 seconds — making requests to the wrong provider and corrupting the thread's message list with spurious Resume entries.

Now the retry delay races with the cancellation receiver, so the old turn exits immediately when cancelled.

Release Notes:

  • Fixed cancelled turns in a conversation that failed (e.g. 500 from the LLM provider) bein retried even after cancellation

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 3, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 3, 2026
@tomhoule tomhoule changed the title Cancel retries promptly when the turn is cancelled Cancel retrie when the turn is cancelled Mar 3, 2026
@tomhoule tomhoule changed the title Cancel retrie when the turn is cancelled Cancel retries when the turn is cancelled Mar 3, 2026
@tomhoule tomhoule changed the title Cancel retries when the turn is cancelled agent: Cancel retries when the turn is cancelled Mar 3, 2026
When a completion request fails with a retryable error (e.g. a 500 from the upstream provider), the retry loop waits on a timer before trying again. This timer did not race with the cancellation signal, so if the user switched models and submitted a new message during the retry delay, the old turn would continue retrying with the stale model for up to 15 seconds — making requests to the wrong provider and corrupting the thread's message list with spurious Resume entries.

Now the retry delay races with the cancellation receiver, so the old turn exits immediately when cancelled.
@tomhoule tomhoule force-pushed the tomhoule-mslkxlrxxlnr branch from 9bf86fc to e5abd3c Compare March 3, 2026 09:59
@tomhoule tomhoule marked this pull request as ready for review March 3, 2026 10:12
@benbrandt benbrandt merged commit 906f5a6 into main Mar 3, 2026
28 checks passed
@benbrandt benbrandt deleted the tomhoule-mslkxlrxxlnr branch March 3, 2026 10:16
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
When a completion request fails with a retryable error (e.g. a 500 from
the upstream provider), the retry loop waits on a timer before trying
again. This timer did not race with the cancellation signal, so if the
user switched models and submitted a new message during the retry delay,
the old turn would continue retrying with the stale model for up to 15
seconds — making requests to the wrong provider and corrupting the
thread's message list with spurious Resume entries.

Now the retry delay races with the cancellation receiver, so the old
turn exits immediately when cancelled.

Release Notes:

- Fixed cancelled turns in a conversation that failed (e.g. 500 from the
LLM provider) bein retried even after cancellation
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
When a completion request fails with a retryable error (e.g. a 500 from
the upstream provider), the retry loop waits on a timer before trying
again. This timer did not race with the cancellation signal, so if the
user switched models and submitted a new message during the retry delay,
the old turn would continue retrying with the stale model for up to 15
seconds — making requests to the wrong provider and corrupting the
thread's message list with spurious Resume entries.

Now the retry delay races with the cancellation receiver, so the old
turn exits immediately when cancelled.

Release Notes:

- Fixed cancelled turns in a conversation that failed (e.g. 500 from the
LLM provider) bein retried even after cancellation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants