From df9e2251f860f9b0dc1df1fb002ad87586dc7e0f Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Wed, 19 Aug 2026 13:56:11 -0500 Subject: [PATCH] test(agent): give the MoA switch fake a reasoning_echo reader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 663fa68cd4 added an unguarded `agent._read_reasoning_echo_from_config()` call to switch_model's core field swap. The fake agent here carries only the attributes switch_model touches, so the new call raises AttributeError inside the rollback-protected block — every field the test asserts on gets restored to its pre-swap value and all four cases fail on main with `assert 'opencode-go' == 'moa'`. Teach the fake the reader, matching the production AIAgent shape. --- tests/agent/test_moa_switch_api_mode.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/agent/test_moa_switch_api_mode.py b/tests/agent/test_moa_switch_api_mode.py index 3abf48dae3..4d1b048bdc 100644 --- a/tests/agent/test_moa_switch_api_mode.py +++ b/tests/agent/test_moa_switch_api_mode.py @@ -34,6 +34,12 @@ def _make_fake_agent(): agent._config_context_length = 123456 agent._transport_cache = {} agent.quiet_mode = True + # switch_model re-reads reasoning_echo for the incoming model as part of the + # core field swap, before the moa branch runs. On a real AIAgent this is a + # method; without it the swap raises and the rollback undoes every field + # this test asserts on. + agent._reasoning_echo_flag = False + agent._read_reasoning_echo_from_config = lambda: False return agent