Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: update max context window on base provider sync (#8803)

Ari Webb5136a8eaede9
diff --git a/letta/services/provider_manager.py b/letta/services/provider_manager.py
index bdf5e0e23..8fdcfe261 100644
--- a/letta/services/provider_manager.py
+++ b/letta/services/provider_manager.py
@@ -737,7 +737,17 @@ class ProviderManager:
# Roll back the session to clear the failed transaction
await session.rollback()
else:
- logger.info(f" LLM model {llm_config.handle} already exists (ID: {existing[0].id}), skipping")
+ # Check if max_context_window needs to be updated
+ existing_model = existing[0]
+ if existing_model.max_context_window != llm_config.context_window:
+ logger.info(
+ f" Updating LLM model {llm_config.handle} max_context_window: "
+ f"{existing_model.max_context_window} -> {llm_config.context_window}"
+ )
+ existing_model.max_context_window = llm_config.context_window
+ await existing_model.update_async(session)
+ else:
+ logger.info(f" LLM model {llm_config.handle} already exists (ID: {existing[0].id}), skipping")
# Process embedding models - add new ones
logger.info(f"Processing {len(embedding_models)} embedding models for provider {provider.name}")