Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat(router): add content-based reroute rules for auto mode (#10134)
Ari Webb4b833242976d
diff --git a/letta/agents/letta_agent_v3.py b/letta/agents/letta_agent_v3.pyindex 9b9babffb..b86ef6988 100644--- a/letta/agents/letta_agent_v3.py+++ b/letta/agents/letta_agent_v3.py@@ -1047,6 +1047,13 @@ class LettaAgentV3(LettaAgentV2):)if not is_primary:self.logger.info(f"[LLM ROUTER]: primary {primary_handle} rerouted, falling back to {active_llm_config.handle}")+ # Content-based rerouting (e.g. images → vision-capable model)+ active_llm_config = routing_client.apply_reroute_rules(+ resolved_config=active_llm_config,+ messages=messages,+ stored_llm_config=self.agent_state.llm_config,+ agent_state=self.agent_state,+ )active_llm_client = LLMClient.create(provider_type=active_llm_config.model_endpoint_type,put_inner_thoughts_first=True,diff --git a/letta/services/llm_router/llm_router_client_base.py b/letta/services/llm_router/llm_router_client_base.pyindex bce6f69a9..1231d0e51 100644--- a/letta/services/llm_router/llm_router_client_base.py+++ b/letta/services/llm_router/llm_router_client_base.py@@ -91,3 +91,7 @@ class LLMRoutingClient:None — no fallback routes configured without Redis."""return None++ def apply_reroute_rules(self, resolved_config, messages, stored_llm_config, agent_state):+ """Apply content-based reroute rules (noop in base)."""+ return resolved_config