test(tui_gateway): assert target_model in resolve_runtime_provider call#16684
test(tui_gateway): assert target_model in resolve_runtime_provider call#16684briandevans wants to merge 2 commits into
Conversation
_make_agent in tui_gateway/server.py:1410-1413 was updated in e9c47c7 ("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) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates a TUI gateway regression test to match the current _make_agent() call signature, ensuring the test continues to validate that runtime provider resolution is invoked with the correct kwargs after the earlier production change that threaded target_model.
Changes:
- Update
test_make_agent_passes_resolved_providerto assertresolve_runtime_provider()is called with bothrequestedandtarget_model.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mock_resolve.assert_called_once_with( | ||
| requested=None, target_model="claude-opus-4-6" | ||
| ) |
…ion is hermetic Address Copilot review on PR NousResearch#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) <noreply@anthropic.com>
|
@copilot Finding addressed in commit Finding (line 50 — All 6 tests in the file pass under |
|
Closing — main's This PR's monkeypatch approach only neutralises env-var overrides ( Thanks @kshitijk4poor. |
Summary
_make_agentintui_gateway/server.py:1410-1413was updated in e9c47c704 ("fix(tui): honor launch model overrides") to passtarget_model=model or Nonetoresolve_runtime_provider. The regression test intests/tui_gateway/test_make_agent_provider.pystill pinned the old shape withassert_called_once_with(requested=None), so it fails on cleanorigin/main.resolve_runtime_providerhappens once with the right kwargs.The bug
Before e9c47c7,
_make_agentcalled:After e9c47c7, it threads the configured/launch model in:
The fake config used by this test (
fake_cfg = {\"model\": {\"default\": \"claude-opus-4-6\", ...}}) makesmodel = \"claude-opus-4-6\", so the production call now includestarget_model=\"claude-opus-4-6\". The strictassert_called_once_with(requested=None)raises:This reproduces on
ef41d3bd4(currentorigin/main) underpython3.11andpython3.12.The fix
Update the assertion to:
The test continues to verify the documented behavior described in its own docstring ("_make_agent forwards provider/base_url/api_key/api_mode from resolve_runtime_provider to AIAgent") via the four
call_kwargs.kwargs[...] == ...assertions immediately below. Only the call-site shape was updated to reflect the new kwarg.Test plan
origin/main(ef41d3bd4):tests/tui_gateway/test_make_agent_provider.py→ 6 passed.Related
target_modelbecause they don't strictly pin the call signature — only this one was strict.