fix(agent): reset stream_active at turn start

`stream_active` relied on every runTools exit path balancing pause with
`endStreamedText`. If one is ever missed, a stale-true flag skips the
spinner pause on the next turn, interleaving frames with streamed text.
Reset it alongside `streamed_text` so the invariant is local.
This commit is contained in:
Adrià Arrufat
2026-07-12 22:10:29 +02:00
parent 2e8e0d1a6f
commit fa2dc02721

View File

@@ -1663,6 +1663,10 @@ fn processUserMessage(self: *Agent, input: TurnInput) !?[]const u8 {
const ma = self.conversation.arena.allocator();
self.api_error_detail = null;
self.streamed_text = false;
// Defensive: if an exit path ever missed `endStreamedText`, a stale-true
// `stream_active` would skip the spinner pause on the next turn's first
// delta and let frames interleave with the text. Reset it at the source.
self.stream_active = false;
self.http_interrupt.reset();
try self.conversation.ensureSystemPrompt();