fix ordering of messages

This commit is contained in:
Adil Hafeez 2025-12-22 16:36:43 -08:00
parent 6cfd630a05
commit da8047e40c
No known key found for this signature in database
GPG key ID: 9B18EF7691369645
4 changed files with 8 additions and 3 deletions

View file

@ -349,6 +349,9 @@ async fn handle_agent_chat(
response_text.len()
);
// remove last message and add new one at the end
let last_message = current_messages.pop().unwrap();
// Create a new message with the agent's response as assistant message
// and add it to the conversation history
current_messages.push(OpenAIMessage {
@ -359,6 +362,8 @@ async fn handle_agent_chat(
tool_call_id: None,
});
current_messages.push(last_message);
}
// This should never be reached since we return in the last agent iteration