From c46bc9294991929a3dc8f6c28111c3e7780406a2 Mon Sep 17 00:00:00 2001 From: rxdxxxx Date: Tue, 5 May 2026 10:07:58 +0800 Subject: [PATCH] fix(run_agent): use aux provider for compression context length lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each auxiliary model must be resolved with its own provider so that provider-specific paths (e.g. Bedrock static table, OpenRouter API) are invoked for the correct client, not inherited from the main model. When the main model is Bedrock, passing self.provider unconditionally to get_model_context_length() for the aux model caused the Bedrock static table hard-intercept (step 1b) to fire for non-Bedrock models, returning BEDROCK_DEFAULT_CONTEXT_LENGTH=128K instead of the model's real context window — triggering a false compression warning every session. Fix: pass _aux_cfg_provider when explicitly set, falling back to self.provider only when the aux provider is unset or "auto". Closes #12977 Related: #13807, #17460 --- run_agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run_agent.py b/run_agent.py index c5662c70ec..bf1e2258bb 100644 --- a/run_agent.py +++ b/run_agent.py @@ -2667,7 +2667,10 @@ class AIAgent: base_url=aux_base_url, api_key=aux_api_key, config_context_length=getattr(self, "_aux_compression_context_length_config", None), - provider=getattr(self, "provider", ""), + # Each model must be resolved with its own provider so that + # provider-specific paths (e.g. Bedrock static table, OpenRouter API) + # are invoked for the correct client, not inherited from the main model. + provider=(_aux_cfg_provider if _aux_cfg_provider and _aux_cfg_provider != "auto" else getattr(self, "provider", "")), ) # Hard floor: the auxiliary compression model must have at least