Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: Adjust `summarize_agent_conversation` endpoint to return 204 (#3595)
Matthew Zhou11540a45862d
diff --git a/letta/agents/letta_agent.py b/letta/agents/letta_agent.pyindex 3f7faab79..bd02a261a 100644--- a/letta/agents/letta_agent.py+++ b/letta/agents/letta_agent.py@@ -1130,7 +1130,7 @@ class LettaAgent(BaseAgent):return new_in_context_messages@trace_method- async def summarize_conversation_history(self) -> AgentState:+ async def summarize_conversation_history(self) -> None:"""Called when the developer explicitly triggers compaction via the API"""agent_state = await self.agent_manager.get_agent_by_id_async(agent_id=self.agent_id, actor=self.actor)message_ids = agent_state.message_idsdiff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex 45efcd542..d41d9cf10 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -1386,7 +1386,7 @@ async def preview_raw_payload()[email protected]("/{agent_id}/summarize", response_model=AgentState, operation_id="summarize_agent_conversation")[email protected]("/{agent_id}/summarize", status_code=204, operation_id="summarize_agent_conversation")async def summarize_agent_conversation(agent_id: str,request_obj: Request, # FastAPI Request@@ -1419,9 +1419,10 @@ async def summarize_agent_conversation(telemetry_manager=server.telemetry_manager if settings.llm_api_logging else NoopTelemetryManager(),message_buffer_min=max_message_length,)- return await agent.summarize_conversation_history()-- raise HTTPException(- status_code=status.HTTP_403_FORBIDDEN,- detail="Summarization is not currently supported for this agent configuration. Please contact Letta support.",- )+ await agent.summarize_conversation_history()+ # Summarization completed, return 204 No Content+ else:+ raise HTTPException(+ status_code=status.HTTP_403_FORBIDDEN,+ detail="Summarization is not currently supported for this agent configuration. Please contact Letta support.",+ )