diff --git a/letta/agents/letta_agent.py b/letta/agents/letta_agent.py index 3f7faab7..bd02a261 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_ids diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py index 45efcd54..d41d9cf1 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( ) -@router.post("/{agent_id}/summarize", response_model=AgentState, operation_id="summarize_agent_conversation") +@router.post("/{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.", + )