diff --git a/CUSTOMIZATION.md b/CUSTOMIZATION.md index 74d507de..2573feab 100644 --- a/CUSTOMIZATION.md +++ b/CUSTOMIZATION.md @@ -5,7 +5,7 @@ Open SWE is designed to be forked and customized for your org. The core agent is ```python # agent/server.py — the key lines 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, ...), tools=[http_request, fetch_url, commit_and_open_pr, linear_comment, slack_thread_reply], backend=sandbox_backend, @@ -117,12 +117,15 @@ See `agent/integrations/langsmith.py` (`LangSmithBackend` class) for a full refe ## 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 -model=make_model("anthropic:claude-opus-4-6", temperature=0, max_tokens=20_000) +```bash +# 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 Use the `provider:model` format: diff --git a/agent/server.py b/agent/server.py index e4fa208b..10b4e714 100644 --- a/agent/server.py +++ b/agent/server.py @@ -4,6 +4,7 @@ # Suppress deprecation warnings from langchain_core (e.g., Pydantic V1 on Python 3.14+) # ruff: noqa: E402 import logging +import os import shlex 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 @@ -400,7 +402,11 @@ async def get_agent(config: RunnableConfig) -> Pregel: # noqa: PLR0915 logger.info("Returning agent with sandbox for thread %s", thread_id) 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, linear_project_id=linear_project_id,