From e7bd2ef27d2289b6802968b13e996363d41222ea Mon Sep 17 00:00:00 2001 From: briandevans <252620095+briandevans@users.noreply.github.com> Date: Mon, 27 Apr 2026 12:20:48 -0700 Subject: [PATCH 1/2] test(tui_gateway): assert target_model in resolve_runtime_provider call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _make_agent in tui_gateway/server.py:1410-1413 was updated in e9c47c704 ("fix(tui): honor launch model overrides") to thread the resolved startup model into resolve_runtime_provider: runtime = resolve_runtime_provider( requested=requested_provider, target_model=model or None, ) The regression test still asserted the pre-change call shape (`assert_called_once_with(requested=None)`), so it failed on origin/main once the production change landed: Expected: resolve_runtime_provider(requested=None) Actual: resolve_runtime_provider(requested=None, target_model='claude-opus-4-6') Update the assertion to match the new shape (the fake config sets model.default = "claude-opus-4-6", so target_model is non-None and the call passes both kwargs). The test still verifies the original intent — that AIAgent is constructed from the resolved provider/base_url/api_key /api_mode — and the rest of the file already covers cases where target model resolution differs. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/tui_gateway/test_make_agent_provider.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tui_gateway/test_make_agent_provider.py b/tests/tui_gateway/test_make_agent_provider.py index 483b533df19a2..0a99c363e39b5 100644 --- a/tests/tui_gateway/test_make_agent_provider.py +++ b/tests/tui_gateway/test_make_agent_provider.py @@ -45,7 +45,9 @@ def test_make_agent_passes_resolved_provider(): _make_agent("sid-1", "key-1") - mock_resolve.assert_called_once_with(requested=None) + mock_resolve.assert_called_once_with( + requested=None, target_model="claude-opus-4-6" + ) call_kwargs = mock_agent.call_args assert call_kwargs.kwargs["provider"] == "anthropic" From 81c2c39dde09d46b04129779c8563d3e1957ed56 Mon Sep 17 00:00:00 2001 From: briandevans <252620095+briandevans@users.noreply.github.com> Date: Mon, 27 Apr 2026 13:00:32 -0700 Subject: [PATCH 2/2] test(tui_gateway): clear HERMES_MODEL env vars so target_model assertion is hermetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address Copilot review on PR #16684: ``_resolve_model()`` consults ``HERMES_MODEL`` and ``HERMES_INFERENCE_MODEL`` *before* falling back to the patched ``_load_cfg`` value. A developer running the suite with either env var set would see the resolved model — and therefore the ``target_model`` kwarg passed into ``resolve_runtime_provider`` — diverge from the ``"claude-opus-4-6"`` config default this test asserts on. Add ``monkeypatch.delenv(..., raising=False)`` for both env vars at the top of the test so the assertion only depends on the patched config. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/tui_gateway/test_make_agent_provider.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/tui_gateway/test_make_agent_provider.py b/tests/tui_gateway/test_make_agent_provider.py index 0a99c363e39b5..f4cca8d95b3ec 100644 --- a/tests/tui_gateway/test_make_agent_provider.py +++ b/tests/tui_gateway/test_make_agent_provider.py @@ -8,10 +8,19 @@ from unittest.mock import MagicMock, patch -def test_make_agent_passes_resolved_provider(): +def test_make_agent_passes_resolved_provider(monkeypatch): """_make_agent forwards provider/base_url/api_key/api_mode from resolve_runtime_provider to AIAgent.""" + # ``_resolve_model()`` consults ``HERMES_MODEL`` / + # ``HERMES_INFERENCE_MODEL`` *before* falling back to the patched + # ``_load_cfg`` value, so a developer running the suite with either + # env var set would see the resolved model — and therefore the + # ``target_model`` kwarg — diverge from the config default this test + # asserts on. Clear them up front so the assertion is hermetic. + monkeypatch.delenv("HERMES_MODEL", raising=False) + monkeypatch.delenv("HERMES_INFERENCE_MODEL", raising=False) + fake_runtime = { "provider": "anthropic", "base_url": "https://api.anthropic.com",