fix: use conversation message_ids when exporting agent with conversation_id (#9294)
When exporting an agent with a conversation_id, the export function was setting agent_state.message_ids from the conversation, but from_agent_state was ignoring this and fetching messages generically via list_messages. Now from_agent_state checks if message_ids is set and fetches those specific messages instead. 👾 Generated with [Letta Code](https://letta.com) Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -191,7 +191,14 @@ class AgentSchema(CreateAgent):
|
||||
per_file_view_window_char_limit=agent_state.per_file_view_window_char_limit,
|
||||
)
|
||||
|
||||
messages = await message_manager.list_messages(agent_id=agent_state.id, actor=actor, limit=50) # TODO: Expand to get more messages
|
||||
# If agent_state.message_ids is set (e.g., from conversation export), fetch those specific messages
|
||||
# Otherwise fall back to listing messages by agent_id
|
||||
if agent_state.message_ids:
|
||||
messages = await message_manager.get_messages_by_ids_async(message_ids=agent_state.message_ids, actor=actor)
|
||||
else:
|
||||
messages = await message_manager.list_messages(
|
||||
agent_id=agent_state.id, actor=actor, limit=50
|
||||
) # TODO: Expand to get more messages
|
||||
|
||||
# Convert messages to MessageSchema objects
|
||||
message_schemas = [MessageSchema.from_message(msg) for msg in messages]
|
||||
|
||||
Reference in New Issue
Block a user