From 663fa68cd43486a29c783481c9e80ad6255e0fda Mon Sep 17 00:00:00 2001 From: Yingliang Zhang Date: Sun, 2 Aug 2026 09:48:47 +0800 Subject: [PATCH] fix: add reasoning_echo_flag to init snapshot and switch rollback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review feedback on PR #76503: 1. Init-time primary snapshot (agent_init.py:2756) was missing reasoning_echo_flag — after fallback recovery the flag was restored as False even when model.reasoning_echo: true was set. 2. Switch transaction snapshot (agent_runtime_helpers.py:2284) was missing _reasoning_echo_flag — a failed client rebuild during switch_model would leave the old provider with the new provider echo policy. Both omissions now fixed. No test regressions (56 passed). Signed-off-by: Yingliang Zhang --- agent/agent_init.py | 1 + agent/agent_runtime_helpers.py | 1 + 2 files changed, 2 insertions(+) diff --git a/agent/agent_init.py b/agent/agent_init.py index 155ddba578..da92e6f881 100644 --- a/agent/agent_init.py +++ b/agent/agent_init.py @@ -2961,6 +2961,7 @@ def init_agent( "client_kwargs": dict(agent._client_kwargs), "use_prompt_caching": agent._use_prompt_caching, "use_native_cache_layout": agent._use_native_cache_layout, + "reasoning_echo_flag": getattr(agent, "_reasoning_echo_flag", False), # Context engine state that _try_activate_fallback() overwrites. # Use getattr for model/base_url/api_key/provider since plugin # engines may not have these (they're ContextCompressor-specific). diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.py index 451b3a0927..bcb1cc3a04 100644 --- a/agent/agent_runtime_helpers.py +++ b/agent/agent_runtime_helpers.py @@ -2654,6 +2654,7 @@ def switch_model(agent, new_model, new_provider, api_key='', base_url='', api_mo "_anthropic_base_url", "_is_anthropic_oauth", "_config_context_length", + "_reasoning_echo_flag", ) } # _client_kwargs is a dict — snapshot a shallow copy so mutating the