fix(agent): keep streaming off for suppressed turns

Streaming wrote assistant deltas straight to stdout regardless of
`suppress_answer`, so `--save`/capture turns (which set it to hide the
answer) leaked model text past the `runTurn` guard. Pass a null stream
hook when the turn's answer is suppressed.
This commit is contained in:
Adrià Arrufat
2026-07-12 22:09:25 +02:00
parent 40b902fed5
commit 5abae593d8

View File

@@ -1703,7 +1703,9 @@ fn processUserMessage(self: *Agent, input: TurnInput) !?[]const u8 {
// non-thinking models.
.effort = self.effort,
.cancel = .{ .context = @ptrCast(self), .checkFn = checkCancel },
.stream = self.streamHook(),
// Suppressed turns (e.g. `--save` capture) must keep stdout clean;
// streaming would bypass the `suppress_answer` guard in `runTurn`.
.stream = if (input.suppress_answer) null else self.streamHook(),
},
) catch |err| {
self.endStreamedText();
@@ -1790,7 +1792,7 @@ fn processUserMessage(self: *Agent, input: TurnInput) !?[]const u8 {
// `.none` stays off to opt out on models that reject it.
.effort = if (self.effort == .none) .none else .low,
.cancel = .{ .context = @ptrCast(self), .checkFn = checkCancel },
.stream = self.streamHook(),
.stream = if (input.suppress_answer) null else self.streamHook(),
},
) catch |err| {
self.endStreamedText();