duplicate output fix
This commit is contained in:
@@ -4848,10 +4848,11 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
// break to let the outer loop's auto-continue logic handle it
|
// break to let the outer loop's auto-continue logic handle it
|
||||||
if any_tool_executed && !final_output_called {
|
if any_tool_executed && !final_output_called {
|
||||||
debug!("Tools were executed but final_output not called - breaking to auto-continue");
|
debug!("Tools were executed but final_output not called - breaking to auto-continue");
|
||||||
// Add the text response to context before breaking
|
// NOTE: We intentionally do NOT set full_response here.
|
||||||
if has_text_response && !current_response.trim().is_empty() {
|
// The content was already displayed during streaming.
|
||||||
full_response = current_response.clone();
|
// Setting full_response would cause duplication when the
|
||||||
}
|
// function eventually returns.
|
||||||
|
// Context window is updated separately via add_message().
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5095,13 +5096,14 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
} else if has_response {
|
} else if has_response {
|
||||||
// Only set full_response if it's empty (first iteration without tools)
|
// Only set full_response if it's empty (first iteration without tools)
|
||||||
// This prevents duplication when the agent responds without calling final_output
|
// This prevents duplication when the agent responds without calling final_output
|
||||||
if full_response.is_empty() && !current_response.is_empty() {
|
// NOTE: We intentionally do NOT set full_response here anymore.
|
||||||
full_response = current_response.clone();
|
// The content was already displayed during streaming via print_agent_response().
|
||||||
debug!(
|
// Setting full_response would cause the CLI to print it again.
|
||||||
"Set full_response from current_response: {} chars",
|
// We only need full_response for the context window (handled separately).
|
||||||
full_response.len()
|
debug!(
|
||||||
);
|
"Response already streamed, not setting full_response. current_response: {} chars",
|
||||||
}
|
current_response.len()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed());
|
let _ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed());
|
||||||
|
|||||||
Reference in New Issue
Block a user