fix(test): re-add explicit feasibility check call in lazy-check integration test#32001
fix(test): re-add explicit feasibility check call in lazy-check integration test#32001talwayh1 wants to merge 2 commits into
Conversation
…easibility check (NousResearch#12977) Two-part fix in agent/conversation_compression.check_compression_model_feasibility (after the main-init refactor moved the function out of run_agent): 1. When the aux compression model matches the main model (same name + base_url, which happens when no separate compression model is configured), fall back to self._config_context_length for the aux model's get_model_context_length call. Without this fallback the aux probe re-detects context for the same endpoint and ignores custom_providers.models.context_length. 2. Re-derive the main model's compression threshold from get_model_context_length instead of reading the potentially-stale threshold_tokens from the compressor — important when custom_providers context_length is loaded after the compressor was originally constructed. (Fix NousResearch#1 from the original PR — propagating _config_context_length after custom_providers resolution in __init__ — is already integrated in agent/agent_init.py line 1227, after the custom_providers branch.) Fixes NousResearch#12977
…ntext_length calls PR NousResearch#12977 added a second get_model_context_length call to re-derive the main model's compression threshold inside check_compression_model_feasibility(). The existing tests used assert_called_once_with which broke when the function was called twice (once for aux model, once for main model). Changes: - Changed assert_called_once_with to assert_any_call in 3 tests - Used side_effect=[aux_ctx, main_ctx] instead of return_value in 4 tests - Added threshold_percent to _make_agent mock compressor (root cause: MagicMock.int() returns 1, making threshold=max(1, 64k)=64k)
|
The test repair is correct — since #28957 deferred the feasibility check out of Two notes on the rest of the diff:
|
What
The test
test_init_feasibility_check_uses_aux_context_override_from_configwas broken by commitffde18286which removed the explicitagent._check_compression_model_feasibility()call needed to trigger the aux-model context probe. Since #28957 (defer feasibility check to first compression attempt), the check is lazy and won't fire duringAIAgent.__init__— the test must drive it manually.Root Cause
The lazy deferral in #28957 moved
check_compression_model_feasibilityout of__init__and intocompress_context(). The test was partially updated (changedassert_called_once_with→assert_any_call, added #12977 comment) but the call to_check_compression_model_feasibility()was accidentally deleted while the assertion was moved outside thewithblock.Fix
_aux_compression_context_length_configassertion back inside thewithblockagent._check_compression_model_feasibility()call inside thewithblock so the mock captures the aux-model context probeRelated