Previously, observeAndTranslateExecutorStream published final usage from
the upstream observer goroutine and treated any ctx.Err() as a stream
failure. When a client disconnected immediately after receiving the
terminal SSE event (e.g. response.completed, message_stop, or
finishReason), completed plugin streams were falsely reported as 499
failures, while non-canceled downstream flush errors were not reconciled
with usage.WaitStreamDelivery.
- Synchronize streamUsage/streamErr/lineBuffer with a mutex and wait for
upstream observation completion (observeDone) after closing the output
channel so downstream delivery acknowledgment never deadlocks.
- Track terminal SSE chunk delivery across split chunk boundaries
(covering Gemini, OpenAI, Responses, Claude, and Interactions events).
- Reconcile usage.WaitStreamDelivery(ctx): treat post-terminal
context.Canceled as success while preserving failure reporting for
pre-terminal disconnects and non-canceled delivery errors.
- Add unit tests covering post-terminal cancel, pre-terminal disconnect,
and post-terminal delivery errors.