The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(codex): preserve session model in app-server threads
cucurigoo27f2c5a4866e
diff --git a/agent/codex_runtime.py b/agent/codex_runtime.pyindex 0edc8a3e7ca..c2c2862a796 100644--- a/agent/codex_runtime.py+++ b/agent/codex_runtime.py@@ -581,8 +581,9 @@ def _ensure_codex_session(agent, messages: List[Dict[str, Any]] | None = None) -from agent.codex_runtime_history_seed import render_history_seedhistory_seed = render_history_seed(messages) or None# A named custom provider (``providers.<name>``) maps onto codex's own ``[model_providers.<name>]``- # table: send the stable id plus the active model and let codex resolve base_url/env_key itself, so- # Hermes' credential never enters the JSON-RPC payload (#75186). openai/openai-codex keep codex's defaults.+ # table: send the stable id and let codex resolve base_url/env_key itself, so Hermes' credential never+ # enters the JSON-RPC payload (#75186). The model always rides along: codex's home is shared, while the+ # Hermes model is per profile/session, so omitting it ran codex's own default instead of the selection.model_provider = Noneif str(getattr(agent, "provider", "") or "").strip().lower() == "custom":from hermes_cli.runtime_provider_custom import codex_model_provider_id@@ -593,7 +594,7 @@ def _ensure_codex_session(agent, messages: List[Dict[str, Any]] | None = None) -request_routing=_ServerRequestRouting(auto_approve_exec=auto_approve_requests, auto_approve_apply_patch=auto_approve_requests),on_event=make_codex_app_server_event_bridge(agent),developer_instructions=developer_instructions or None,- model=getattr(agent, "model", None) if model_provider else None, model_provider=model_provider,+ model=getattr(agent, "model", None), model_provider=model_provider,resume_thread_id=resume_thread_id, history_seed=history_seed,)diff --git a/tests/agent/transports/test_codex_app_server_session.py b/tests/agent/transports/test_codex_app_server_session.pyindex fc5a9630313..14c3fc89808 100644--- a/tests/agent/transports/test_codex_app_server_session.py+++ b/tests/agent/transports/test_codex_app_server_session.py@@ -200,7 +200,7 @@ class TestLifecycle:def test_named_custom_provider_selects_codex_model_provider(self, monkeypatch):"""#75186: for ``provider=custom`` + a configured ``providers.<name>`` entry, the session built by``_ensure_codex_session`` sends ``model`` + ``modelProvider=<name>`` on thread/start and never the- API key; openai/openai-codex agents keep codex's defaults (cwd only)."""+ API key; openai/openai-codex agents send the selected model with codex's own provider."""import hermes_cli.runtime_provider as rpfrom agent.codex_runtime import _ensure_codex_sessionfrom agent.transports import codex_app_server_session as sess_mod@@ -224,8 +224,9 @@ class TestLifecycle:base = {"cwd": "/tmp", "personality": "none"}assert named == {**base, "modelProvider": "my-gateway", "model": "gpt-5.4"}assert "sk-secret" not in repr(named)- assert thread_start_params(provider="openai-codex", requested_provider="openai-codex", model="gpt-5.4") == base- assert thread_start_params(provider="custom", requested_provider="custom", model="gpt-5.4") == base+ assert thread_start_params(provider="openai-codex", requested_provider="openai-codex", model="gpt-5.4") == {+ **base, "model": "gpt-5.4"}+ assert thread_start_params(provider="custom", requested_provider="custom", model="gpt-5.4") == {**base, "model": "gpt-5.4"}def test_stored_thread_is_resumed_and_an_unresumable_one_falls_back_to_a_fresh_start(self):"""#100531: a stored id goes out as ``thread/resume`` (same params as thread/start, never a