feat: Add conversation_id filtering to message endpoints (#8324)

* feat: Add conversation_id filtering to message list and search endpoints

Add optional conversation_id parameter to filter messages by conversation:
- client.agents.messages.list
- client.messages.list
- client.messages.search

Changes:
- Added conversation_id field to MessageSearchRequest and SearchAllMessagesRequest schemas
- Added conversation_id filtering to list_messages in message_manager.py
- Updated get_agent_recall_async and get_all_messages_recall_async in server.py
- Added conversation_id query parameter to router endpoints
- Updated Turbopuffer client to support conversation_id filtering in searches

Fixes #8320

🤖 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Charles Packer <cpacker@users.noreply.github.com>

* add conversation_id to message and tpuf

* default messages filter for backward compatibility

* add test and auto gen

* fix integration test

* fix test

* update test

---------

Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com>
Co-authored-by: Charles Packer <cpacker@users.noreply.github.com>
Co-authored-by: christinatong01 <christina@letta.com>
This commit is contained in:
Charles Packer
2026-01-07 13:45:52 -08:00
committed by Caren Thomas
parent 737d6e2550
commit ed6284cedb
9 changed files with 334 additions and 24 deletions

View File

@@ -7442,6 +7442,24 @@
},
"description": "Group ID to filter messages by."
},
{
"name": "conversation_id",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Conversation ID to filter messages by.",
"title": "Conversation Id"
},
"description": "Conversation ID to filter messages by."
},
{
"name": "use_assistant_message",
"in": "query",
@@ -16137,6 +16155,24 @@
"title": "Order"
},
"description": "Sort order for messages by creation time. 'asc' for oldest first, 'desc' for newest first"
},
{
"name": "conversation_id",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Conversation ID to filter messages by",
"title": "Conversation Id"
},
"description": "Conversation ID to filter messages by"
}
],
"responses": {
@@ -35419,6 +35455,18 @@
"title": "Batch Item Id",
"description": "The id of the LLMBatchItem that this message is associated with"
},
"conversation_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Conversation Id",
"description": "The conversation this message belongs to"
},
"is_err": {
"anyOf": [
{
@@ -35494,7 +35542,7 @@
"type": "object",
"required": ["role"],
"title": "Message",
"description": " Letta's internal representation of a message. Includes methods to convert to/from LLM provider formats.\n\n Attributes:\n id (str): The unique identifier of the message.\n role (MessageRole): The role of the participant.\n text (str): The text of the message.\n user_id (str): The unique identifier of the user.\n agent_id (str): The unique identifier of the agent.\n model (str): The model used to make the function call.\n name (str): The name of the participant.\n created_at (datetime): The time the message was created.\n tool_calls (List[OpenAIToolCall,]): The list of tool calls requested.\n tool_call_id (str): The id of the tool call.\n step_id (str): The id of the step that this message was created in.\n otid (str): The offline threading id associated with this message.\n tool_returns (List[ToolReturn]): The list of tool returns requested.\n group_id (str): The multi-agent group that the message was sent in.\n sender_id (str): The id of the sender of the message, can be an identity id or agent id.\nt"
"description": " Letta's internal representation of a message. Includes methods to convert to/from LLM provider formats.\n\n Attributes:\n id (str): The unique identifier of the message.\n role (MessageRole): The role of the participant.\n text (str): The text of the message.\n user_id (str): The unique identifier of the user.\n agent_id (str): The unique identifier of the agent.\n model (str): The model used to make the function call.\n name (str): The name of the participant.\n created_at (datetime): The time the message was created.\n tool_calls (List[OpenAIToolCall,]): The list of tool calls requested.\n tool_call_id (str): The id of the tool call.\n step_id (str): The id of the step that this message was created in.\n otid (str): The offline threading id associated with this message.\n tool_returns (List[ToolReturn]): The list of tool returns requested.\n group_id (str): The multi-agent group that the message was sent in.\n sender_id (str): The id of the sender of the message, can be an identity id or agent id.\n conversation_id (str): The conversation this message belongs to.\nt"
},
"MessageCreate": {
"properties": {
@@ -35676,6 +35724,18 @@
"title": "Template Id",
"description": "Filter messages by template ID"
},
"conversation_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Conversation Id",
"description": "Filter messages by conversation ID"
},
"limit": {
"type": "integer",
"maximum": 100,
@@ -38588,6 +38648,18 @@
"title": "Agent Id",
"description": "Filter messages by agent ID"
},
"conversation_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Conversation Id",
"description": "Filter messages by conversation ID"
},
"limit": {
"type": "integer",
"maximum": 100,