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.jsonindex 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.pyindex 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: strnum_messages_before: intnum_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 stateawait 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,