perf: reuse request_input_estimate instead of recomputing estimate_request_tokens_rough

The output-cap error handler already computes request_input_estimate at
line 4722 via estimate_request_tokens_rough(api_messages, tools=...).
The new compression block ~50 lines below was calling the same function
with the same inputs again. Reuse the existing local.
This commit is contained in:
kshitij 2026-08-04 11:19:15 +05:30
parent 78c8bcd122
commit 9fc8926975
1 changed files with 1 additions and 1 deletions

View File

@ -4775,7 +4775,7 @@ def run_conversation(
_overflow_input = messages
messages, active_system_prompt = agent._compress_context(
messages, system_message,
approx_tokens=estimate_request_tokens_rough(api_messages, tools=agent.tools or None),
approx_tokens=request_input_estimate,
task_id=effective_task_id,
)
if messages is _overflow_input and compression_skipped_due_to_lock(agent):