chore: Add Opus 4.6 with 1M context window [OPUS-46] (#9301)
opus 4.6 1M version
This commit is contained in:
committed by
Caren Thomas
parent
34159ffa21
commit
644f7b9d5d
@@ -71,7 +71,7 @@ class AnthropicClient(LLMClientBase):
|
||||
else:
|
||||
betas.append("interleaved-thinking-2025-05-14")
|
||||
|
||||
# 1M context beta for Sonnet 4/4.5 when enabled
|
||||
# 1M context beta for Sonnet 4/4.5 or Opus 4.6 when enabled
|
||||
try:
|
||||
from letta.settings import model_settings
|
||||
|
||||
@@ -79,6 +79,8 @@ class AnthropicClient(LLMClientBase):
|
||||
llm_config.model.startswith("claude-sonnet-4") or llm_config.model.startswith("claude-sonnet-4-5")
|
||||
):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
elif model_settings.anthropic_opus_1m and llm_config.model.startswith("claude-opus-4-6"):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -118,7 +120,7 @@ class AnthropicClient(LLMClientBase):
|
||||
else:
|
||||
betas.append("interleaved-thinking-2025-05-14")
|
||||
|
||||
# 1M context beta for Sonnet 4/4.5 when enabled
|
||||
# 1M context beta for Sonnet 4/4.5 or Opus 4.6 when enabled
|
||||
try:
|
||||
from letta.settings import model_settings
|
||||
|
||||
@@ -126,6 +128,8 @@ class AnthropicClient(LLMClientBase):
|
||||
llm_config.model.startswith("claude-sonnet-4") or llm_config.model.startswith("claude-sonnet-4-5")
|
||||
):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
elif model_settings.anthropic_opus_1m and llm_config.model.startswith("claude-opus-4-6"):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -291,7 +295,7 @@ class AnthropicClient(LLMClientBase):
|
||||
else:
|
||||
betas.append("interleaved-thinking-2025-05-14")
|
||||
|
||||
# 1M context beta for Sonnet 4/4.5 when enabled
|
||||
# 1M context beta for Sonnet 4/4.5 or Opus 4.6 when enabled
|
||||
try:
|
||||
from letta.settings import model_settings
|
||||
|
||||
@@ -299,6 +303,8 @@ class AnthropicClient(LLMClientBase):
|
||||
llm_config.model.startswith("claude-sonnet-4") or llm_config.model.startswith("claude-sonnet-4-5")
|
||||
):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
elif model_settings.anthropic_opus_1m and llm_config.model.startswith("claude-opus-4-6"):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -849,6 +855,8 @@ class AnthropicClient(LLMClientBase):
|
||||
and (model.startswith("claude-sonnet-4") or model.startswith("claude-sonnet-4-5"))
|
||||
):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
elif model and model_settings.anthropic_opus_1m and model.startswith("claude-opus-4-6"):
|
||||
betas.append("context-1m-2025-08-07")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class AnthropicProvider(Provider):
|
||||
logger.warning(f"Couldn't find context window size for model {model['id']}, defaulting to 200,000")
|
||||
model["context_window"] = 200000
|
||||
|
||||
# Optional override: enable 1M context for Sonnet 4/4.5 when flag is set
|
||||
# Optional override: enable 1M context for Sonnet 4/4.5 or Opus 4.6 when flag is set
|
||||
try:
|
||||
from letta.settings import model_settings
|
||||
|
||||
@@ -209,6 +209,8 @@ class AnthropicProvider(Provider):
|
||||
model["id"].startswith("claude-sonnet-4") or model["id"].startswith("claude-sonnet-4-5")
|
||||
):
|
||||
model["context_window"] = 1_000_000
|
||||
elif model_settings.anthropic_opus_1m and model["id"].startswith("claude-opus-4-6"):
|
||||
model["context_window"] = 1_000_000
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -177,6 +177,16 @@ class ModelSettings(BaseSettings):
|
||||
),
|
||||
alias="ANTHROPIC_SONNET_1M",
|
||||
)
|
||||
anthropic_opus_1m: bool = Field(
|
||||
default=False,
|
||||
description=(
|
||||
"Enable 1M-token context window for Claude Opus 4.6. When true, adds the"
|
||||
" 'context-1m-2025-08-07' beta to Anthropic requests and sets model context_window"
|
||||
" to 1,000,000 instead of 200,000. Note: This feature is in beta and not available"
|
||||
" to all orgs; once GA, this flag can be removed and behavior can default to on."
|
||||
),
|
||||
alias="ANTHROPIC_OPUS_1M",
|
||||
)
|
||||
|
||||
# ollama
|
||||
ollama_base_url: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user