change delete agent return type to none

This commit is contained in:
Caren Thomas
2024-12-26 12:06:01 -08:00
parent fd8961c39e
commit 1fdfb181ac
2 changed files with 6 additions and 6 deletions

View File

@@ -170,7 +170,7 @@ def get_agent_state(
raise HTTPException(status_code=404, detail=str(e))
@router.delete("/{agent_id}", response_model=AgentState, operation_id="delete_agent")
@router.delete("/{agent_id}", response_model=None, operation_id="delete_agent")
def delete_agent(
agent_id: str,
server: "SyncServer" = Depends(get_letta_server),
@@ -181,7 +181,8 @@ def delete_agent(
"""
actor = server.user_manager.get_user_or_default(user_id=user_id)
try:
return server.agent_manager.delete_agent(agent_id=agent_id, actor=actor)
server.agent_manager.delete_agent(agent_id=agent_id, actor=actor)
return JSONResponse(status_code=status.HTTP_200_OK)
except NoResultFound:
raise HTTPException(status_code=404, detail=f"Agent agent_id={agent_id} not found for user_id={actor.id}.")

View File

@@ -279,7 +279,7 @@ class AgentManager:
return agent.to_pydantic()
@enforce_types
def delete_agent(self, agent_id: str, actor: PydanticUser) -> PydanticAgentState:
def delete_agent(self, agent_id: str, actor: PydanticUser) -> None:
"""
Deletes an agent and its associated relationships.
Ensures proper permission checks and cascades where applicable.
@@ -288,15 +288,14 @@ class AgentManager:
agent_id: ID of the agent to be deleted.
actor: User performing the action.
Returns:
PydanticAgentState: The deleted agent state
Raises:
NoResultFound: If agent doesn't exist
"""
with self.session_maker() as session:
# Retrieve the agent
agent = AgentModel.read(db_session=session, identifier=agent_id, actor=actor)
agent_state = agent.to_pydantic()
agent.hard_delete(session)
return agent_state
# ======================================================================================================================
# In Context Messages Management