You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: tau2 sliding window never logs the over max tokens warning #9338
In SlidingWindowHistoryProvider._get_token_count the red "over max tokens, will truncate" warning can never fire. The yellow "half of max" check runs first and also catches every case where the count is over the max, so the red branch is dead code.
Expected Behavior
When the total goes over max_tokens I expect the red truncation warning, not the yellow percentage one.
Call _get_token_count with one message worth about 27 tokens.
Only the yellow warning is logged ("270% of max tokens") and the red one never appears.
Minimal Reproduction
fromagent_framework_lab_tau2._sliding_windowimportSlidingWindowHistoryProviderfromagent_frameworkimportMessageprovider=SlidingWindowHistoryProvider(max_tokens=10)
msg=Message("user", ["hello world, this message is intentionally long so it clearly exceeds the tiny ten token budget"])
total=provider._get_token_count([msg])
asserttotal>provider.max_tokens# logged: "Total tokens 27 is 270% of max tokens 10" in yellow, nothing about truncation
Error Messages and Stack Traces
No error, only the yellow loguru warning is emitted.
Package Versions
agent-framework-lab packages built from main (dcbbf79)
Python Version
Python 3.14.8
Operating System
macOS
Regression
Unknown
Additional Context
The two conditions just need to be swapped so the over max case is checked first, then the half warning with elif. Truncation itself works fine, only the warning is lost. Happy to send a PR.
Acknowledgements
I searched existing issues and did not find a duplicate.
Activity
Python: fix(lab-tau2): check the over-max warning before the half-of-…
Python: fix(lab-tau2): check the over-max warning before the half-of-…