Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add model and embedding fields to modify agent api (#1412)
cthomasb5d83fcd0aac
diff --git a/letta/schemas/agent.py b/letta/schemas/agent.pyindex 14a2f2044..ee24cb78a 100644--- a/letta/schemas/agent.py+++ b/letta/schemas/agent.py@@ -244,6 +244,14 @@ class UpdateAgent(BaseModel):None,description="If set to True, the agent will not remember previous messages (though the agent will still retain state via core memory blocks and archival/recall memory). Not recommended unless you have an advanced use case.",)+ model: Optional[str] = Field(+ None,+ description="The LLM configuration handle used by the agent, specified in the format "+ "provider/model-name, as an alternative to specifying llm_config.",+ )+ embedding: Optional[str] = Field(+ None, description="The embedding configuration handle used by the agent, specified in the format provider/model-name."+ )class Config:extra = "ignore" # Ignores extra fieldsdiff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex fdbf7101b..591df4018 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -215,7 +215,7 @@ def modify_agent():"""Update an existing agent"""actor = server.user_manager.get_user_or_default(user_id=actor_id)- return server.agent_manager.update_agent(agent_id=agent_id, agent_update=update_agent, actor=actor)+ return server.update_agent(agent_id=agent_id, request=update_agent, actor=actor)@router.get("/{agent_id}/tools", response_model=List[Tool], operation_id="list_agent_tools")diff --git a/letta/server/server.py b/letta/server/server.pyindex 6c462634c..0756ed473 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -35,7 +35,7 @@ from letta.log import get_loggerfrom letta.offline_memory_agent import OfflineMemoryAgentfrom letta.orm.errors import NoResultFoundfrom letta.round_robin_multi_agent import RoundRobinMultiAgent-from letta.schemas.agent import AgentState, AgentType, CreateAgent+from letta.schemas.agent import AgentState, AgentType, CreateAgent, UpdateAgentfrom letta.schemas.block import BlockUpdatefrom letta.schemas.embedding_config import EmbeddingConfig@@ -768,6 +768,25 @@ class SyncServer(Server):actor=actor,)+ def update_agent(+ self,+ agent_id: str,+ request: UpdateAgent,+ actor: User,+ ) -> AgentState:+ if request.model is not None:+ request.llm_config = self.get_llm_config_from_handle(handle=request.model)++ if request.embedding is not None:+ request.embedding_config = self.get_embedding_config_from_handle(handle=request.embedding)++ # Invoke manager+ return self.agent_manager.update_agent(+ agent_id=agent_id,+ agent_update=request,+ actor=actor,+ )+# convert name->id# TODO: These can be moved to agent_manager