Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: expose agent_id to the messages search api endpoint (#8252)

Charles Packer64a1a8b14e85
diff --git a/fern/openapi.json b/fern/openapi.json
index 633914df2..f4daae742 100644
--- a/fern/openapi.json
+++ b/fern/openapi.json
@@ -36982,6 +36982,18 @@
"description": "Search mode to use",
"default": "hybrid"
},
+ "agent_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Agent Id",
+ "description": "Filter messages by agent ID"
+ },
"limit": {
"type": "integer",
"maximum": 100,
diff --git a/letta/schemas/message.py b/letta/schemas/message.py
index d09360dc7..2ebde2240 100644
--- a/letta/schemas/message.py
+++ b/letta/schemas/message.py
@@ -2310,6 +2310,7 @@ class MessageSearchRequest(BaseModel):
class SearchAllMessagesRequest(BaseModel):
query: str = Field(..., description="Text query for full-text search")
search_mode: Literal["vector", "fts", "hybrid"] = Field("hybrid", description="Search mode to use")
+ agent_id: Optional[str] = Field(None, description="Filter messages by agent ID")
limit: int = Field(50, description="Maximum number of results to return", ge=1, le=100)
start_date: Optional[datetime] = Field(None, description="Filter messages created after this date")
end_date: Optional[datetime] = Field(None, description="Filter messages created on or before this date")
diff --git a/letta/server/rest_api/routers/v1/messages.py b/letta/server/rest_api/routers/v1/messages.py
index 3a72ed8f6..e7e1a6ec9 100644
--- a/letta/server/rest_api/routers/v1/messages.py
+++ b/letta/server/rest_api/routers/v1/messages.py
@@ -73,6 +73,7 @@ async def search_all_messages(
actor=actor,
query_text=request.query,
search_mode=request.search_mode,
+ agent_id=request.agent_id,
limit=request.limit,
start_date=request.start_date,
end_date=request.end_date,