Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: preserve agent context_window when applying conversation model override (LET-7991) (#9986)
Cameron25d52fcfd7e4
diff --git a/letta/server/rest_api/routers/v1/conversations.py b/letta/server/rest_api/routers/v1/conversations.pyindex 303020ef2..881608b79 100644--- a/letta/server/rest_api/routers/v1/conversations.py+++ b/letta/server/rest_api/routers/v1/conversations.py@@ -427,6 +427,9 @@ async def send_conversation_message(conversation_llm_config = await server.get_llm_config_from_handle_async(actor=actor,handle=conversation.model,+ # Preserve the agent's context window (capped at the new model's max).+ # Without this, the context window resets to the model/global default.+ context_window_limit=agent.llm_config.context_window,)if conversation.model_settings is not None:update_params = conversation.model_settings._to_legacy_config_params()@@ -546,6 +549,9 @@ async def preview_conversation_model_request(conversation_llm_config = await server.get_llm_config_from_handle_async(actor=actor,handle=conversation.model,+ # Preserve the agent's context window (capped at the new model's max).+ # Without this, the context window resets to the model/global default.+ context_window_limit=agent.llm_config.context_window,)if conversation.model_settings is not None:update_params = conversation.model_settings._to_legacy_config_params()diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.pyindex a7cf6cb47..ad8f95da9 100644--- a/letta/services/streaming_service.py+++ b/letta/services/streaming_service.py@@ -158,6 +158,9 @@ class StreamingService:conversation_llm_config = await self.server.get_llm_config_from_handle_async(actor=actor,handle=conversation.model,+ # Preserve the agent's context window (capped at the new model's max).+ # Without this, the context window resets to the model/global default.+ context_window_limit=agent.llm_config.context_window,)if conversation.model_settings is not None:update_params = conversation.model_settings._to_legacy_config_params()