Execute tool_calls in parallel using ToolManager.stream_execute_tools(). Args: tool_calls: List of tool call objects from the LLM name_mapping: Mapping from LLM tool names to actual tool names reasoning_content: Optional reasoning content from th
(
self,
tool_calls: list[Any],
name_mapping: dict[str, str] | None = None,
reasoning_content: str | None = None,
)
| 95 | context.tool_processor = self |
| 96 | |
| 97 | async def process_tool_calls( |
| 98 | self, |
| 99 | tool_calls: list[Any], |
| 100 | name_mapping: dict[str, str] | None = None, |
| 101 | reasoning_content: str | None = None, |
| 102 | ) -> None: |
| 103 | """ |
| 104 | Execute tool_calls in parallel using ToolManager.stream_execute_tools(). |
| 105 | |
| 106 | Args: |
| 107 | tool_calls: List of tool call objects from the LLM |
| 108 | name_mapping: Mapping from LLM tool names to actual tool names |
| 109 | reasoning_content: Optional reasoning content from the LLM |
| 110 | """ |
| 111 | if not tool_calls: |
| 112 | logger.warning("Empty tool_calls list received.") |
| 113 | return |
| 114 | |
| 115 | if name_mapping is None: |
| 116 | name_mapping = {} |
| 117 | |
| 118 | logger.info( |
| 119 | f"Processing {len(tool_calls)} tool calls with {len(name_mapping)} name mappings" |
| 120 | ) |
| 121 | |
| 122 | # Reset state |
| 123 | self._call_metadata.clear() |
| 124 | self._cancelled = False |
| 125 | self._result_ids_added = set() |
| 126 | self._faulted_page_ids.clear() |
| 127 | |
| 128 | # Add assistant message with all tool calls BEFORE executing |
| 129 | self._add_assistant_message_with_tool_calls(tool_calls, reasoning_content) |
| 130 | |
| 131 | # Convert LLM tool calls to CTP format and check confirmations |
| 132 | ctp_calls: list[CTPToolCall] = [] |
| 133 | |
| 134 | try: |
| 135 | for idx, call in enumerate(tool_calls): |
| 136 | if getattr(self.ui_manager, "interrupt_requested", False): |
| 137 | self._cancelled = True |
| 138 | break |
| 139 | |
| 140 | # Extract tool call details |
| 141 | llm_tool_name, raw_arguments, call_id = self._extract_tool_call_info( |
| 142 | call, idx |
| 143 | ) |
| 144 | |
| 145 | # Map to execution name |
| 146 | execution_tool_name = name_mapping.get(llm_tool_name, llm_tool_name) |
| 147 | |
| 148 | # Get display name - special handling for dynamic tool call_tool |
| 149 | display_name = execution_tool_name |
| 150 | display_arguments = raw_arguments |
| 151 | |
| 152 | # For dynamic tools, extract the actual tool name from call_tool |
| 153 | if execution_tool_name == DYNAMIC_TOOL_PROXY_NAME: |
| 154 | # Parse arguments to get the real tool name |