diff --git a/holmes/core/tool_calling_llm.py b/holmes/core/tool_calling_llm.py index e21bad43fc..5716697234 100644 --- a/holmes/core/tool_calling_llm.py +++ b/holmes/core/tool_calling_llm.py @@ -403,6 +403,9 @@ def call( # type: ignore perf_timing.measure(f"tool completed {tool_call_result.tool_name}") + # Update the tool number offset for the next iteration + tool_number_offset += len(tools_to_call) + # Add a blank line after all tools in this batch complete if tools_to_call: logging.info("") @@ -602,6 +605,7 @@ def call_stream( perf_timing.measure("get_all_tools_openai_format") max_steps = self.max_steps i = 0 + tool_number_offset = 0 while i < max_steps: i += 1 @@ -695,7 +699,7 @@ def call_stream( tool_to_call=t, # type: ignore previous_tool_calls=tool_calls, trace_span=DummySpan(), # Streaming mode doesn't support tracing yet - tool_number=tool_index, + tool_number=tool_number_offset + tool_index, ) ) yield StreamMessage( @@ -716,6 +720,9 @@ def call_stream( data=tool_call_result.as_streaming_tool_result_response(), ) + # Update the tool number offset for the next iteration + tool_number_offset += len(tools_to_call) + raise Exception( f"Too many LLM calls - exceeded max_steps: {i}/{self.max_steps}" )