From 9b15e89b0251aa7d35f4d6f48ea8ed74a69cea5a Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 16:00:06 -0500 Subject: [PATCH] refac --- cptr/utils/context.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cptr/utils/context.py b/cptr/utils/context.py index 4f8fcf0..1a4e12c 100644 --- a/cptr/utils/context.py +++ b/cptr/utils/context.py @@ -93,14 +93,13 @@ def resolve_compact_token_threshold( model: str | None = None, *, chat_models_config: dict | None = None, - global_cap: int | None = None, + global_threshold: int | None = None, ) -> int: """Return the effective compaction threshold for a model. - The existing global threshold is the cap. Model-level values can lower it - for smaller context windows, but never raise it. + Model-level values override the global default. """ - cap = global_cap or _get_threshold() + default_threshold = global_threshold or _get_threshold() model_threshold = None if chat_models_config: @@ -117,7 +116,7 @@ def resolve_compact_token_threshold( if model_threshold: break - return min(model_threshold, cap) if model_threshold else cap + return model_threshold or default_threshold async def load_compact_token_threshold(model: str | None = None) -> int: