fix(consolidation): trigger compaction from reported usage, not just tiktoken estimates (#6260)

Co-authored-by: Muzhen2000 <254800372+Muzhen2000@users.noreply.github.com>
Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-17 02:47:42 +08:00
1 parent bd779e9f54
commit faf1efaf09
5 files changed
+391 -3

No files matched your search

+3 -2
View File
@@ -1351,8 +1351,9 @@ class AgentRunner:
usage = self._usage_or_estimate(
spec, state.messages, response, tool_definitions=state.tool_definitions,
)
state.usage = usage
return state.usage
# A rewritten input or another model's count cannot bound the next request.
state.usage = None if response.provider_compaction_applied or response.is_fallback else usage
return usage
def _estimate_response_usage(
self,