mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 09:46:05 -04:00
fix(agent): stream assistant text only in the REPL
Streaming defaulted on for every mode, so one-shot `--task` and script runs interleaved intermediate assistant commentary into stdout, which wrappers treat as the answer. Gate the stream hook on `Terminal.isRepl` so non-interactive modes keep the buffered final answer.
This commit is contained in:
@@ -604,9 +604,11 @@ fn endStreamedText(self: *Agent) void {
|
||||
}
|
||||
|
||||
/// The text-delta hook, or null when `/stream off` — a null hook makes
|
||||
/// `runTools` fall back to a buffered response.
|
||||
/// `runTools` fall back to a buffered response. Streaming is an interactive
|
||||
/// REPL affordance; one-shot (`--task`) and script modes keep stdout to the
|
||||
/// buffered final answer so wrappers can parse it cleanly.
|
||||
fn streamHook(self: *Agent) ?zenai.provider.Client.TextDeltaHook {
|
||||
if (!self.stream_enabled) return null;
|
||||
if (!self.stream_enabled or !self.terminal.isRepl()) return null;
|
||||
return .{ .context = @ptrCast(self), .onText = streamAssistantDelta };
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ pub fn init(allocator: std.mem.Allocator, history_paths: ?HistoryPaths, verbosit
|
||||
};
|
||||
}
|
||||
|
||||
fn isRepl(self: *const Terminal) bool {
|
||||
pub fn isRepl(self: *const Terminal) bool {
|
||||
return self.repl_arena != null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user