diff --git a/backend/agentpress/thread_manager.py b/backend/agentpress/thread_manager.py index 1f75c4aa..b89db3a6 100644 --- a/backend/agentpress/thread_manager.py +++ b/backend/agentpress/thread_manager.py @@ -353,11 +353,11 @@ Here are the XML tools available with examples: if self._is_tool_result_message(msg): # Only compress ToolResult messages _i += 1 # Count the number of ToolResult messages msg_token_count = token_counter(messages=[msg]) # Count the number of tokens in the message - if msg_token_count > 5000: # If the message is too long + if msg_token_count > 1000: # If the message is too long if _i > 1: # If this is not the most recent ToolResult message message_id = msg.get('message_id') # Get the message_id if message_id: - msg["content"] = msg["content"][:10000] + "... (truncated)" + f"\n\nThis message is too long, use the expand-message tool with message_id \"{message_id}\" to see the full message" # Truncate the message + msg["content"] = msg["content"][:3000] + "... (truncated)" + f"\n\nThis message is too long, use the expand-message tool with message_id \"{message_id}\" to see the full message" # Truncate the message else: msg["content"] = msg["content"][:200000] + f"\n\nThis message is too long, repeat relevant information in your response to remember it" # Truncate to 300k characters to avoid overloading the context at once, but don't truncate otherwise diff --git a/backend/requirements.txt b/backend/requirements.txt index cc58b88b..395edcae 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -32,7 +32,7 @@ stripe>=12.0.1 dramatiq>=1.17.1 pika>=1.3.2 prometheus-client>=0.21.1 -langfuse>=2.60.5 +langfuse==2.60.5 httpx>=0.24.0 Pillow>=10.0.0 sentry-sdk[fastapi]>=2.29.1