fix: fix message responses for new agent loop (#2170)

This commit is contained in:
Sarah Wooders
2025-05-14 10:24:16 -07:00
committed by GitHub
parent 43acb725da
commit f8aee4f806
2 changed files with 7 additions and 4 deletions

View File

@@ -14,9 +14,9 @@ def _create_letta_response(new_in_context_messages: list[Message], use_assistant
"""
Converts the newly created/persisted messages into a LettaResponse.
"""
response_messages = []
for msg in new_in_context_messages:
response_messages.extend(msg.to_letta_messages(use_assistant_message=use_assistant_message))
response_messages = Message.to_letta_messages_from_list(
messages=new_in_context_messages, use_assistant_message=use_assistant_message, reverse=False
)
return LettaResponse(messages=response_messages, usage=LettaUsageStatistics())

View File

@@ -93,8 +93,11 @@ class LettaAgent(BaseAgent):
)
tool_call = response.choices[0].message.tool_calls[0]
reasoning = [TextContent(text=response.choices[0].message.content)] # reasoning placed into content for legacy reasons
persisted_messages, should_continue = await self._handle_ai_response(tool_call, agent_state, tool_rules_solver)
persisted_messages, should_continue = await self._handle_ai_response(
tool_call, agent_state, tool_rules_solver, reasoning_content=reasoning
)
self.response_messages.extend(persisted_messages)
new_in_context_messages.extend(persisted_messages)