fix: Adjust summarize_agent_conversation endpoint to return 204 (#3595)

This commit is contained in:
Matthew Zhou
2025-07-28 14:29:09 -07:00
committed by GitHub
parent 87a48e1695
commit 2cd985ef8a
2 changed files with 9 additions and 8 deletions

View File

@@ -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

View File

@@ -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.",
)