Revert "Fix auto-continue bug: ensure assistant message before continue prompt"

This reverts commit fe96969adb.
This commit is contained in:
Dhanji R. Prasanna
2025-12-24 15:52:23 +11:00
parent fe96969adb
commit f9d0c33461

View File

@@ -4550,20 +4550,20 @@ impl<W: UiWriter> Agent<W> {
} }
// Add any text response to context before prompting for continuation // Add any text response to context before prompting for continuation
// IMPORTANT: We must always add an assistant message to maintain User/Assistant alternation if has_response {
// Without this, consecutive User messages confuse the LLM and cause empty responses let response_text = if !current_response.is_empty() {
let response_text = if !current_response.is_empty() { current_response.clone()
current_response.clone() } else {
} else if !full_response.is_empty() { full_response.clone()
full_response.clone() };
} else { if !response_text.trim().is_empty() {
"[empty response]".to_string() let assistant_msg = Message::new(
}; MessageRole::Assistant,
let assistant_msg = Message::new( response_text.trim().to_string(),
MessageRole::Assistant, );
if response_text.trim().is_empty() { "[empty response]".to_string() } else { response_text.trim().to_string() }, self.context_window.add_message(assistant_msg);
); }
self.context_window.add_message(assistant_msg); }
// Add a follow-up message asking for continuation // Add a follow-up message asking for continuation
let continue_prompt = if has_incomplete_tool_call { let continue_prompt = if has_incomplete_tool_call {