1 parent 67d378c commit bbca177Copy full SHA for bbca177
1 file changed
python_agent_harness/agent.py
@@ -676,9 +676,12 @@ def safe_delta(text: str) -> None:
676
return # response arrived after cancel: drop it
677
678
# persist the assistant response in the conversation history
679
- # (text and/or tool calls) so later turns and the UI see it
+ # (text and/or tool calls) so later turns and the UI see it;
680
+ # always append to maintain role alternation — a missing
681
+ # assistant message before a nudge creates consecutive user
682
+ # messages which some APIs reject with a 400 error.
683
+ self.messages.append(assistant)
684
if assistant.text().strip() or assistant.tool_calls:
- self.messages.append(assistant)
685
if not assistant.tool_calls and self.top_level:
686
session.last_messages = list(self.messages)
687
0 commit comments