Skip to content

Commit f763d2c

Browse files
committed
fix(gateway): remove double-reverse of history messages in _send_to_agent_background
hist_msgs is already sorted oldest→newest by list(reversed(...)), so passing reversed(hist_msgs) to _conv() flips the order again, causing the model to read conversation history in reverse chronological order.
1 parent 58bfa36 commit f763d2c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/app/api/gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ async def _send_to_agent_background(
390390
hist_msgs = list(reversed(hist_result.scalars().all()))
391391

392392
from app.services.llm.utils import convert_chat_messages_to_llm_format as _conv
393-
messages = _conv(reversed(hist_msgs))
393+
messages = _conv(hist_msgs)
394394

395395
# Add the new message with agent communication context
396396
user_msg = f"{agent_comm_alert}\n\n[Message from agent: {source_agent_name}]\n{content}"

0 commit comments

Comments
 (0)