Revert "Fix auto-continue bug: ensure assistant message before continue prompt"
This reverts commit fe96969adb.
This commit is contained in:
@@ -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 if !full_response.is_empty() {
|
|
||||||
full_response.clone()
|
|
||||||
} else {
|
} else {
|
||||||
"[empty response]".to_string()
|
full_response.clone()
|
||||||
};
|
};
|
||||||
|
if !response_text.trim().is_empty() {
|
||||||
let assistant_msg = Message::new(
|
let assistant_msg = Message::new(
|
||||||
MessageRole::Assistant,
|
MessageRole::Assistant,
|
||||||
if response_text.trim().is_empty() { "[empty response]".to_string() } else { response_text.trim().to_string() },
|
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user