open-swe/agent/utils/model.py
Johannes du Plessis 448be4a466
feat(open-swe): Default to GPT-5.5 medium reasoning (#1224)
* feat: default to GPT-5.5 medium reasoning

Use OpenAI GPT-5.5 with medium reasoning as the default model and document the completion-token budget semantics for reasoning models.

* fix: use Responses API reasoning config

Pass GPT-5.5 reasoning settings through LangChain's Responses API parameter instead of the Chat Completions-only reasoning_effort field.

* feat: raise GPT-5.5 output budget

Set the default GPT-5.5 output token budget to the model maximum so long-running coding tasks have more room for reasoning and final responses.

* feat: align recursion limit with Deep Agents

Use Deep Agents' default recursion limit so longer coding runs have room to complete without Open SWE imposing a lower cap.

* chore: remove minimal effort level

* chore: reduce max tokens to 64_000

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-04-28 15:03:21 -07:00

28 lines
783 B
Python

from typing import Literal, TypedDict, Unpack
from langchain.chat_models import init_chat_model
OPENAI_RESPONSES_WS_BASE_URL = "wss://api.openai.com/v1"
OpenAIReasoningEffort = Literal["none", "low", "medium", "high", "xhigh"]
class OpenAIReasoning(TypedDict, total=False):
effort: OpenAIReasoningEffort
class ModelKwargs(TypedDict, total=False):
max_tokens: int | None
reasoning: OpenAIReasoning | None
temperature: float | None
def make_model(model_id: str, **kwargs: Unpack[ModelKwargs]):
model_kwargs: dict[str, object] = kwargs.copy()
if model_id.startswith("openai:"):
model_kwargs["base_url"] = OPENAI_RESPONSES_WS_BASE_URL
model_kwargs["use_responses_api"] = True
return init_chat_model(model=model_id, **model_kwargs)