From d635e2df3fd7b0f30c55f055f787b256d2737678 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 25 Apr 2026 19:26:26 +0530 Subject: [PATCH] fix(compression): pass provider to context length resolver in feasibility check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _check_compression_model_feasibility calls get_model_context_length without provider=, so Codex OAuth users get 1,050,000 (from models.dev for 'openai') instead of the actual 272,000 limit. This happens because _infer_provider_from_url maps chatgpt.com → 'openai' (not 'openai-codex'), skipping the Codex-specific resolution branch entirely. Result: compression threshold set at 85% of 1.05M = 892K — conversations never trigger compression, the context grows unbounded, and when gateway hygiene eventually forces compression, the Codex endpoint drops the oversized streaming request ('peer closed connection without sending complete message body'). Fix: forward self.provider to get_model_context_length so provider- specific resolution branches (Codex OAuth 272K, Copilot live /models, Nous suffix-match) fire correctly. Reported by user on GPT 5.5 via Codex OAuth Pro (paste.rs/vsra3). --- run_agent.py | 1 + tests/run_agent/test_compression_feasibility.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/run_agent.py b/run_agent.py index 7187499bb1..8db343a2a5 100644 --- a/run_agent.py +++ b/run_agent.py @@ -2399,6 +2399,7 @@ 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", ""), ) # Hard floor: the auxiliary compression model must have at least diff --git a/tests/run_agent/test_compression_feasibility.py b/tests/run_agent/test_compression_feasibility.py index 2050bee28e..7b4b7da612 100644 --- a/tests/run_agent/test_compression_feasibility.py +++ b/tests/run_agent/test_compression_feasibility.py @@ -184,6 +184,7 @@ def test_feasibility_check_passes_config_context_length(mock_get_client, mock_ct base_url="http://custom-endpoint:8080/v1", api_key="sk-custom", config_context_length=1_000_000, + provider="openrouter", ) @@ -206,6 +207,7 @@ def test_feasibility_check_ignores_invalid_context_length(mock_get_client, mock_ base_url="http://custom:8080/v1", api_key="sk-test", config_context_length=None, + provider="openrouter", ) @@ -258,6 +260,7 @@ def test_init_feasibility_check_uses_aux_context_override_from_config(): base_url="http://custom-endpoint:8080/v1", api_key="sk-custom", config_context_length=1_000_000, + provider="", )