Summary
When an API call fails mid-stream and triggers a retry, any TextDelta events that were already emitted remain visible in the UI. This could cause brief "partial text" display followed by the full retried response.
Current Behavior
User: "Hello"
[partial response appears: "Hi there! I'm hap"]
[retrying in 2s: rate limited]
[full response appears: "Hi there! I'm happy to help..."]
The partial text and full response may both be visible.
Proposed Behavior
Options:
- Track whether any text was emitted before retry, and emit a "clear" event for UI to handle
- Document this as expected behavior (current approach - comment exists in code)
- Buffer all TextDeltas until response completes, then emit (would lose streaming UX)
Related Code
src/agent.rs:386-388:
// If we had some response, clear it for the retry to avoid duplication
// (Note: TextDelta events were already sent, so UI might still show them)
full_response.clear();
Notes
This is a rare edge case that only occurs when:
- The API fails mid-stream (after some text was streamed)
- The error is retryable
Low priority as the current behavior is documented and the impact is minimal.
Summary
When an API call fails mid-stream and triggers a retry, any
TextDeltaevents that were already emitted remain visible in the UI. This could cause brief "partial text" display followed by the full retried response.Current Behavior
The partial text and full response may both be visible.
Proposed Behavior
Options:
Related Code
src/agent.rs:386-388:Notes
This is a rare edge case that only occurs when:
Low priority as the current behavior is documented and the impact is minimal.