test(compress): re-initialise main_runtime attrs in manually-built compressor - #10903
Closed
luigileap wants to merge 1 commit into
Closed
test(compress): re-initialise main_runtime attrs in manually-built compressor#10903luigileap wants to merge 1 commit into
luigileap wants to merge 1 commit into
Conversation
…mpressor The `_make_compressor` helper uses `ContextCompressor.__new__` to bypass `__init__`, so every attribute referenced by the method under test must be set explicitly. PR NousResearch#7910 (fix(agent): route compression aux through live session runtime) added a `main_runtime` dict inside `_generate_summary` that reads `self.model`, `self.provider`, `self.base_url`, `self.api_key`, and `self.api_mode`. The focus-topic regression test bypassed `__init__`, so those attributes were missing and `_generate_summary` raised `AttributeError: 'ContextCompressor' object has no attribute 'model'`, making the test fail with `result is None` (the method returned None via its broad-exception cooldown path) and `KeyError: 'messages'` on the captured-prompt assertion. Initialise the attributes in `_make_compressor` so the test exercises the real code path. Same pattern as the prior CLI-interrupt fix that added missing attributes for a `SomeClass.__new__(SomeClass)` stub.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tests/agent/test_compress_focus.py::test_focus_topic_injected_into_summary_promptand
test_no_focus_topic_no_injectionfail with:Both tests then report
result is None/KeyError: 'messages'because_generate_summaryswallowed theAttributeErrorin its broad-exceptcooldown path.
Root cause
_make_compressorin the test file builds a compressor withContextCompressor.__new__(ContextCompressor), bypassing__init__, andexplicitly sets only the attributes the method used to touch (token
budgets, protect counts, the previous-summary cache, etc.).
PR #7910 ("fix(agent): route compression aux through live session
runtime") added a
main_runtimedict to thecall_llminvocation inside_generate_summary:Production sets those attributes in
__init__, but the test fixture —which predates the runtime-aware change — never did. Accessing
self.modelraisesAttributeError, which the method catches andconverts into a 10-minute cooldown +
Nonereturn.Fix
Extend
_make_compressorto set the five runtime attributes(
model,provider,base_url,api_key,api_mode) so the fixturematches the current production surface.
Verification
All four tests in the module pass, including the previously failing two.