feat: read LLM model ID from LLM_MODEL_ID env var, defaulting to anthropic:claude-opus-4-6 (#1128)

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
Brace Sproul 2026-03-25 11:32:44 -07:00 • committed by GitHub
parent 267b2fd011
commit 3fea3c8709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View file

@ -5,7 +5,7 @@ Open SWE is designed to be forked and customized for your org. The core agent is
```python ```python
# agent/server.py — the key lines # agent/server.py — the key lines
return create_deep_agent( return create_deep_agent(
model=make_model("anthropic:claude-opus-4-6", temperature=0, max_tokens=20_000), model=make_model(os.environ.get("LLM_MODEL_ID", DEFAULT_LLM_MODEL_ID), temperature=0, max_tokens=20_000),
system_prompt=construct_system_prompt(repo_dir, ...), system_prompt=construct_system_prompt(repo_dir, ...),
tools=[http_request, fetch_url, commit_and_open_pr, linear_comment, slack_thread_reply], tools=[http_request, fetch_url, commit_and_open_pr, linear_comment, slack_thread_reply],
backend=sandbox_backend, backend=sandbox_backend,
@ -117,12 +117,15 @@ See `agent/integrations/langsmith.py` (`LangSmithBackend` class) for a full refe
## 2. Model ## 2. Model
The model is configured in the `get_agent()` function in `agent/server.py`: The model is configured in the `get_agent()` function in `agent/server.py`. By default it uses `anthropic:claude-opus-4-6`, but you can override it with the `LLM_MODEL_ID` environment variable:
```python ```bash
model=make_model("anthropic:claude-opus-4-6", temperature=0, max_tokens=20_000) # Set the model via environment variable (uses provider:model format)
LLM_MODEL_ID="anthropic:claude-sonnet-4-6"
``` ```
If `LLM_MODEL_ID` is not set, the default model (`anthropic:claude-opus-4-6`) is used.
### Switching models ### Switching models
Use the `provider:model` format: Use the `provider:model` format:

View file

@ -4,6 +4,7 @@
# Suppress deprecation warnings from langchain_core (e.g., Pydantic V1 on Python 3.14+) # Suppress deprecation warnings from langchain_core (e.g., Pydantic V1 on Python 3.14+)
# ruff: noqa: E402 # ruff: noqa: E402
import logging import logging
import os
import shlex import shlex
import warnings import warnings
@ -244,6 +245,7 @@ def graph_loaded_for_execution(config: RunnableConfig) -> bool:
) )
DEFAULT_LLM_MODEL_ID = "anthropic:claude-opus-4-6"
DEFAULT_RECURSION_LIMIT = 1_000 DEFAULT_RECURSION_LIMIT = 1_000
@ -400,7 +402,11 @@ async def get_agent(config: RunnableConfig) -> Pregel: # noqa: PLR0915
logger.info("Returning agent with sandbox for thread %s", thread_id) logger.info("Returning agent with sandbox for thread %s", thread_id)
return create_deep_agent( return create_deep_agent(
model=make_model("anthropic:claude-opus-4-6", temperature=0, max_tokens=20_000), model=make_model(
os.environ.get("LLM_MODEL_ID", DEFAULT_LLM_MODEL_ID),
temperature=0,
max_tokens=20_000,
),
system_prompt=construct_system_prompt( system_prompt=construct_system_prompt(
repo_dir, repo_dir,
linear_project_id=linear_project_id, linear_project_id=linear_project_id,