From 308c31e25f0b384c78b89b1eb971e4974bd4bdaf Mon Sep 17 00:00:00 2001 From: marko-kraemer Date: Sat, 5 Apr 2025 13:32:51 +0100 Subject: [PATCH] tool index --- backend/agentpress/response_processor.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/backend/agentpress/response_processor.py b/backend/agentpress/response_processor.py index df5360e3..25c5f1ff 100644 --- a/backend/agentpress/response_processor.py +++ b/backend/agentpress/response_processor.py @@ -109,10 +109,7 @@ class ResponseProcessor: # For tracking pending tool executions pending_tool_executions = [] - # Tool execution index counter - tool_execution_index = 0 - - # Tool index for remaining tools (used at end of function) + # Tool index counter for tracking all tool executions tool_index = 0 logger.info(f"Starting to process streaming response for thread {thread_id}") @@ -150,7 +147,7 @@ class ResponseProcessor: # Create a context for this tool execution context = self._create_tool_context( tool_call=tool_call, - tool_index=tool_execution_index + tool_index=tool_index ) # Execute tool if needed, but in background @@ -165,12 +162,12 @@ class ResponseProcessor: pending_tool_executions.append({ "task": execution_task, "tool_call": tool_call, - "tool_index": tool_execution_index, + "tool_index": tool_index, "context": context }) - # Increment the tool execution index - tool_execution_index += 1 + # Increment the tool index + tool_index += 1 # Immediately continue processing more chunks @@ -223,7 +220,7 @@ class ResponseProcessor: # Create a context for this tool execution context = self._create_tool_context( tool_call=tool_call_data, - tool_index=tool_execution_index + tool_index=tool_index ) # Yield tool execution start message @@ -236,12 +233,12 @@ class ResponseProcessor: pending_tool_executions.append({ "task": execution_task, "tool_call": tool_call_data, - "tool_index": tool_execution_index, + "tool_index": tool_index, "context": context }) - # Increment the tool execution index - tool_execution_index += 1 + # Increment the tool index + tool_index += 1 # Immediately continue processing more chunks