From 336a1639247d8daf6b22e53caa7bfb9a4264ed39 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Mon, 2 Mar 2026 12:13:24 -0800 Subject: [PATCH] feat: Add model utils, move to websockets and responses api, add gpt-5.3-codex (#998) * feat: Add model utils, move to websockets and responses api, add gpt-5.3-codex * cr --- apps/agent/agent/server.py | 4 ++-- apps/agent/agent/utils/model.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 apps/agent/agent/utils/model.py diff --git a/apps/agent/agent/server.py b/apps/agent/agent/server.py index 0de0029d..b453fe07 100644 --- a/apps/agent/agent/server.py +++ b/apps/agent/agent/server.py @@ -23,7 +23,6 @@ warnings.filterwarnings("ignore", message=".*Pydantic V1.*", category=UserWarnin # Now safe to import agent (which imports LangChain modules) from deepagents import create_deep_agent from deepagents.backends.protocol import SandboxBackendProtocol -from langchain_openai import ChatOpenAI from langsmith.sandbox import SandboxClientError from .encryption import decrypt_token @@ -36,6 +35,7 @@ from .middleware import ( ) from .prompt import construct_system_prompt from .tools import commit_and_open_pr, fetch_url, http_request +from .utils.model import make_model client = get_client() @@ -361,7 +361,7 @@ 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=ChatOpenAI(model="gpt-5.2-codex", temperature=0, max_tokens=20_000), + model=make_model("openai:gpt-5.3-codex", temperature=0, max_tokens=20_000), system_prompt=construct_system_prompt( repo_dir, linear_project_id=linear_project_id, diff --git a/apps/agent/agent/utils/model.py b/apps/agent/agent/utils/model.py new file mode 100644 index 00000000..c9cca8a7 --- /dev/null +++ b/apps/agent/agent/utils/model.py @@ -0,0 +1,13 @@ +from langchain.chat_models import init_chat_model + +OPENAI_RESPONSES_WS_BASE_URL = "wss://api.openai.com/v1" + + +def make_model(model_id: str, **kwargs: dict): + model_kwargs = 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)