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: add compaction response (#7389)

Sarah Wooders3f3e54d93721
diff --git a/fern/openapi.json b/fern/openapi.json
index 8f15541f5..bdee6983d 100644
--- a/fern/openapi.json
+++ b/fern/openapi.json
@@ -8192,8 +8192,15 @@
}
},
"responses": {
- "204": {
- "description": "Successful Response"
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CompactionResponse"
+ }
+ }
+ }
},
"422": {
"description": "Validation Error",
@@ -24660,6 +24667,29 @@
"type": "object",
"title": "CompactionRequest"
},
+ "CompactionResponse": {
+ "properties": {
+ "summary_message": {
+ "type": "string",
+ "title": "Summary Message"
+ },
+ "num_messages_before": {
+ "type": "integer",
+ "title": "Num Messages Before"
+ },
+ "num_messages_after": {
+ "type": "integer",
+ "title": "Num Messages After"
+ }
+ },
+ "type": "object",
+ "required": [
+ "summary_message",
+ "num_messages_before",
+ "num_messages_after"
+ ],
+ "title": "CompactionResponse"
+ },
"CompactionSettings-Input": {
"properties": {
"model": {
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py
index 059fc2e8b..e621e12b3 100644
--- a/letta/server/rest_api/routers/v1/agents.py
+++ b/letta/server/rest_api/routers/v1/agents.py
@@ -2099,13 +2099,13 @@ class CompactionRequest(BaseModel):
)
-class CompactionResult(BaseModel):
+class CompactionResponse(BaseModel):
summary_message: str
num_messages_before: int
num_messages_after: int
[email protected]("/{agent_id}/summarize", status_code=204, operation_id="summarize_messages")
[email protected]("/{agent_id}/summarize", response_model=CompactionResponse, operation_id="summarize_messages")
async def summarize_messages(
agent_id: AgentId,
request: Optional[CompactionRequest] = Body(default=None),
@@ -2146,7 +2146,7 @@ async def summarize_messages(
# update the agent state
await agent_loop._checkpoint_messages(run_id=None, step_id=None, new_messages=[summary_message], in_context_messages=messages)
- return CompactionResult(
+ return CompactionResponse(
summary_message=summary_message,
num_messages_before=num_messages_before,
num_messages_after=num_messages_after,