Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: remove gating from auto mode (#9821)
cthomas1a1846d769df
diff --git a/letta/agents/base_agent.py b/letta/agents/base_agent.pyindex c81f760d4..3e6019a4b 100644--- a/letta/agents/base_agent.py+++ b/letta/agents/base_agent.py@@ -56,7 +56,6 @@ class BaseAgent(ABC):input_messages: List[MessageCreate],max_steps: int = DEFAULT_MAX_STEPS,run_id: Optional[str] = None,- auto_mode_enabled: bool = False,billing_context: "BillingContext | None" = None,) -> LettaResponse:"""diff --git a/letta/agents/base_agent_v2.py b/letta/agents/base_agent_v2.pyindex 0edbee0ce..515edb76b 100644--- a/letta/agents/base_agent_v2.py+++ b/letta/agents/base_agent_v2.py@@ -53,7 +53,6 @@ class BaseAgentV2(ABC):request_start_timestamp_ns: int | None = None,client_tools: list["ClientToolSchema"] | None = None,include_compaction_messages: bool = False, # Not used in V2, but accepted for API compatibility- auto_mode_enabled: bool = False, # Not used in V2, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> LettaResponse:"""@@ -79,7 +78,6 @@ class BaseAgentV2(ABC):conversation_id: str | None = None,client_tools: list["ClientToolSchema"] | None = None,include_compaction_messages: bool = False, # Not used in V2, but accepted for API compatibility- auto_mode_enabled: bool = False, # Not used in V2, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> AsyncGenerator[LettaMessage | LegacyLettaMessage | MessageStreamStatus, None]:"""diff --git a/letta/agents/letta_agent_v2.py b/letta/agents/letta_agent_v2.pyindex b958c9fde..13fb9b07f 100644--- a/letta/agents/letta_agent_v2.py+++ b/letta/agents/letta_agent_v2.py@@ -186,7 +186,6 @@ class LettaAgentV2(BaseAgentV2):request_start_timestamp_ns: int | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False, # Not used in V2, but accepted for API compatibility- auto_mode_enabled: bool = False, # Not used in V2, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> LettaResponse:"""@@ -293,7 +292,6 @@ class LettaAgentV2(BaseAgentV2):conversation_id: str | None = None, # Not used in V2, but accepted for API compatibilityclient_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False, # Not used in V2, but accepted for API compatibility- auto_mode_enabled: bool = False, # Not used in V2, but accepted for API compatibilitybilling_context: BillingContext | None = None,) -> AsyncGenerator[str, None]:"""diff --git a/letta/agents/letta_agent_v3.py b/letta/agents/letta_agent_v3.pyindex c92f452ae..429e4e441 100644--- a/letta/agents/letta_agent_v3.py+++ b/letta/agents/letta_agent_v3.py@@ -161,7 +161,6 @@ class LettaAgentV3(LettaAgentV2):conversation_id: str | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,billing_context: "BillingContext | None" = None,) -> LettaResponse:"""@@ -273,7 +272,6 @@ class LettaAgentV3(LettaAgentV2):include_return_message_types=include_return_message_types,request_start_timestamp_ns=request_start_timestamp_ns,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,)input_messages_to_persist = [] # clear after first step@@ -378,7 +376,6 @@ class LettaAgentV3(LettaAgentV2):conversation_id: str | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,billing_context: BillingContext | None = None,) -> AsyncGenerator[str, None]:"""@@ -507,7 +504,6 @@ class LettaAgentV3(LettaAgentV2):include_return_message_types=include_return_message_types,request_start_timestamp_ns=request_start_timestamp_ns,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,)input_messages_to_persist = [] # clear after first stepasync for chunk in response:@@ -807,7 +803,6 @@ class LettaAgentV3(LettaAgentV2):dry_run: bool = False,enforce_run_id_set: bool = True,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,) -> AsyncGenerator[LettaMessage | dict, None]:"""Execute a single agent step (one LLM call and tool execution).@@ -948,7 +943,6 @@ class LettaAgentV3(LettaAgentV2):if is_auto_mode:routing_client = await get_llm_routing_client()active_llm_config, is_primary, primary_handle = await routing_client.resolve_auto_mode_config(- auto_mode_enabled=auto_mode_enabled,stored_llm_config=self.agent_state.llm_config,actor=self.actor,)diff --git a/letta/groups/sleeptime_multi_agent_v2.py b/letta/groups/sleeptime_multi_agent_v2.pyindex fb833b8d8..e842e0b7f 100644--- a/letta/groups/sleeptime_multi_agent_v2.py+++ b/letta/groups/sleeptime_multi_agent_v2.py@@ -70,7 +70,6 @@ class SleeptimeMultiAgentV2(BaseAgent):use_assistant_message: bool = True,request_start_timestamp_ns: int | None = None,include_return_message_types: list[MessageType] | None = None,- auto_mode_enabled: bool = False, # Not used in multi-agent, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> LettaResponse:run_ids = []diff --git a/letta/groups/sleeptime_multi_agent_v3.py b/letta/groups/sleeptime_multi_agent_v3.pyindex 4c1b95789..7a148eada 100644--- a/letta/groups/sleeptime_multi_agent_v3.py+++ b/letta/groups/sleeptime_multi_agent_v3.py@@ -48,7 +48,6 @@ class SleeptimeMultiAgentV3(LettaAgentV2):request_start_timestamp_ns: int | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False, # Not used in multi-agent, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> LettaResponse:self.run_ids = []@@ -65,7 +64,6 @@ class SleeptimeMultiAgentV3(LettaAgentV2):request_start_timestamp_ns=request_start_timestamp_ns,client_tools=client_tools,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,)@@ -86,7 +84,6 @@ class SleeptimeMultiAgentV3(LettaAgentV2):include_return_message_types: list[MessageType] | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,billing_context: "BillingContext | None" = None,) -> AsyncGenerator[str, None]:self.run_ids = []@@ -106,7 +103,6 @@ class SleeptimeMultiAgentV3(LettaAgentV2):request_start_timestamp_ns=request_start_timestamp_ns,client_tools=client_tools,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,):yield chunkdiff --git a/letta/groups/sleeptime_multi_agent_v4.py b/letta/groups/sleeptime_multi_agent_v4.pyindex dc1ceaa61..150cd3f7f 100644--- a/letta/groups/sleeptime_multi_agent_v4.py+++ b/letta/groups/sleeptime_multi_agent_v4.py@@ -48,7 +48,6 @@ class SleeptimeMultiAgentV4(LettaAgentV3):conversation_id: str | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False, # Not used in multi-agent, but accepted for API compatibilitybilling_context: "BillingContext | None" = None,) -> LettaResponse:self.run_ids = []@@ -66,7 +65,6 @@ class SleeptimeMultiAgentV4(LettaAgentV3):conversation_id=conversation_id,client_tools=client_tools,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,)@@ -87,7 +85,6 @@ class SleeptimeMultiAgentV4(LettaAgentV3):conversation_id: str | None = None,client_tools: list[ClientToolSchema] | None = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,billing_context: "BillingContext | None" = None,) -> AsyncGenerator[str, None]:self.run_ids = []@@ -108,7 +105,6 @@ class SleeptimeMultiAgentV4(LettaAgentV3):conversation_id=conversation_id,client_tools=client_tools,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,):yield chunkdiff --git a/letta/server/rest_api/dependencies.py b/letta/server/rest_api/dependencies.pyindex 15772d754..66ea43bb4 100644--- a/letta/server/rest_api/dependencies.py+++ b/letta/server/rest_api/dependencies.py@@ -20,7 +20,6 @@ class ExperimentalParams(BaseModel):letta_v1_agent: Optional[bool] = Noneletta_v1_agent_message_async: Optional[bool] = Nonemodal_sandbox: Optional[bool] = None- auto_mode: Optional[bool] = Noneclass HeaderParams(BaseModel):@@ -47,7 +46,6 @@ def get_headers(None, alias="X-Experimental-Letta-V1-Agent-Message-Async", include_in_schema=False),modal_sandbox: Optional[str] = Header(None, alias="X-Experimental-Modal-Sandbox", include_in_schema=False),- auto_mode: Optional[str] = Header(None, alias="X-Experimental-Auto-Mode", include_in_schema=False),billing_plan_type: Optional[str] = Header(None, alias="X-Billing-Plan-Type", include_in_schema=False),billing_cost_source: Optional[str] = Header(None, alias="X-Billing-Cost-Source", include_in_schema=False),billing_customer_id: Optional[str] = Header(None, alias="X-Billing-Customer-Id", include_in_schema=False),@@ -71,7 +69,6 @@ def get_headers(letta_v1_agent=(letta_v1_agent == "true") if letta_v1_agent else None,letta_v1_agent_message_async=(letta_v1_agent_message_async == "true") if letta_v1_agent_message_async else None,modal_sandbox=(modal_sandbox == "true") if modal_sandbox else None,- auto_mode=(auto_mode == "true") if auto_mode else None,),billing_context=BillingContext(plan_type=billing_plan_type,diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex 962728d1b..dce472409 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -1692,14 +1692,12 @@ async def send_message(actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)if request.streaming and is_1_0_sdk:- auto_mode_enabled = bool(headers.experimental_params and headers.experimental_params.auto_mode)streaming_service = StreamingService(server)run, result = await streaming_service.create_agent_stream(agent_id=agent_id,actor=actor,request=request,run_type="send_message",- auto_mode_enabled=auto_mode_enabled,billing_context=headers.billing_context,)return result@@ -1761,7 +1759,6 @@ async def send_message(})- auto_mode_enabled = bool(headers.experimental_params and headers.experimental_params.auto_mode)agent_loop = AgentLoop.load(agent_state=agent, actor=actor)result = await agent_loop.step(request.messages,@@ -1772,7 +1769,6 @@ async def send_message(include_return_message_types=request.include_return_message_types,client_tools=request.client_tools,include_compaction_messages=request.include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=headers.billing_context,)run_status = result.stop_reason.stop_reason.run_statusdiff --git a/letta/services/llm_router/client.py b/letta/services/llm_router/client.pyindex 87fa858c3..d47cc25f7 100644--- a/letta/services/llm_router/client.py+++ b/letta/services/llm_router/client.py@@ -71,7 +71,6 @@ class LLMRoutingClient(LLMRoutingClientBase):async def resolve_auto_mode_config(self,- auto_mode_enabled: bool,stored_llm_config: "LLMConfig",actor: "User",) -> tuple["LLMConfig", bool, str]:@@ -81,7 +80,6 @@ class LLMRoutingClient(LLMRoutingClientBase):Preserves user-configured context_window and max_tokens from the stored config.Args:- auto_mode_enabled: Whether the experimental auto_mode header was set.stored_llm_config: The agent's stored LLM config (with auto mode handle).actor: The user actor for provider lookups.@@ -89,22 +87,24 @@ class LLMRoutingClient(LLMRoutingClientBase):Tuple of (resolved_config, is_primary, primary_handle)."""from letta.services.provider_manager import ProviderManager+ from letta.settings import model_settingsprovider_manager = ProviderManager()primary_handle = AUTO_MODE_PRIMARY- if auto_mode_enabled:- if await self._is_healthy(primary_handle):- config = _build_fireworks_config()- config = config.model_copy(- update={- "context_window": min(stored_llm_config.context_window, config.context_window),- "max_tokens": min(stored_llm_config.max_tokens, config.max_tokens),- }- )- return config, True, primary_handle-- logger.warning(f"Auto mode: primary {primary_handle} unhealthy, using {AUTO_MODE_FALLBACK}")+ if not model_settings.auto_mode_enabled:+ logger.info(f"[AUTO MODE]: primary {primary_handle} disabled via kill switch, using {AUTO_MODE_FALLBACK}")+ elif await self._is_healthy(primary_handle):+ config = _build_fireworks_config()+ config = config.model_copy(+ update={+ "context_window": min(stored_llm_config.context_window, config.context_window),+ "max_tokens": min(stored_llm_config.max_tokens, config.max_tokens),+ }+ )+ return config, True, primary_handle+ else:+ logger.warning(f"[AUTO MODE]: primary {primary_handle} unhealthy, using {AUTO_MODE_FALLBACK}")config = await provider_manager.get_llm_config_from_handle(AUTO_MODE_FALLBACK, actor)config = config.model_copy(diff --git a/letta/services/llm_router/client_base.py b/letta/services/llm_router/client_base.pyindex 3c69c8d01..3bb9f8159 100644--- a/letta/services/llm_router/client_base.py+++ b/letta/services/llm_router/client_base.py@@ -20,14 +20,12 @@ class LLMRoutingClient:async def resolve_auto_mode_config(self,- auto_mode_enabled: bool,stored_llm_config: "LLMConfig",actor: "User",) -> tuple["LLMConfig", bool, str]:"""Resolve an auto mode handle to an actual model config.Args:- auto_mode_enabled: Whether the experimental auto_mode header was set.stored_llm_config: The agent's stored LLM config (with auto mode handle).actor: The user actor for provider lookups.diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.pyindex be925a2d5..18ecbdc8b 100644--- a/letta/services/streaming_service.py+++ b/letta/services/streaming_service.py@@ -81,7 +81,6 @@ class StreamingService:run_type: str = "streaming",conversation_id: Optional[str] = None,should_lock: bool = False,- auto_mode_enabled: bool = False,billing_context: "BillingContext | None" = None,) -> tuple[Optional[PydanticRun], Union[StreamingResponse, LettaResponse]]:"""@@ -191,7 +190,6 @@ class StreamingService:lock_key=lock_key, # For lock release (may differ from conversation_id)client_tools=request.client_tools,include_compaction_messages=request.include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,route_class=route_class,is_background=request.background,@@ -363,7 +361,6 @@ class StreamingService:lock_key: Optional[str] = None,client_tools: Optional[list[ClientToolSchema]] = None,include_compaction_messages: bool = False,- auto_mode_enabled: bool = False,billing_context: BillingContext | None = None,route_class: str = "foreground",is_background: bool = False,@@ -401,7 +398,6 @@ class StreamingService:conversation_id=conversation_id,client_tools=client_tools,include_compaction_messages=include_compaction_messages,- auto_mode_enabled=auto_mode_enabled,billing_context=billing_context,)