From 0bfd7ecb3f76a6f54fe333e621fadb7be7a1412d Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Thu, 29 May 2025 15:28:53 +0000 Subject: [PATCH] fix(thread_manager): adjust token count condition to handle default max token value --- backend/agentpress/thread_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/agentpress/thread_manager.py b/backend/agentpress/thread_manager.py index 61bb1edf..eb6d2584 100644 --- a/backend/agentpress/thread_manager.py +++ b/backend/agentpress/thread_manager.py @@ -325,7 +325,7 @@ Here are the XML tools available with examples: uncompressed_total_token_count = token_counter(model=llm_model, messages=prepared_messages) - if uncompressed_total_token_count > llm_max_tokens: + if uncompressed_total_token_count > (llm_max_tokens or (100 * 1000)): _i = 0 # Count the number of ToolResult messages for msg in reversed(prepared_messages): # Start from the end and work backwards if "content" in msg and msg['content'] and "ToolResult" in msg['content']: # Only compress ToolResult messages