(
self,
context: ToolProcessorContext,
ui_manager: UIManagerProtocol,
*,
max_concurrency: int = 4,
)
| 63 | """ |
| 64 | |
| 65 | def __init__( |
| 66 | self, |
| 67 | context: ToolProcessorContext, |
| 68 | ui_manager: UIManagerProtocol, |
| 69 | *, |
| 70 | max_concurrency: int = 4, |
| 71 | ) -> None: |
| 72 | self.context = context |
| 73 | self.ui_manager = ui_manager |
| 74 | self.max_concurrency = max_concurrency |
| 75 | |
| 76 | # Tool manager for execution - access via protocol attribute |
| 77 | self.tool_manager: ToolManager | None = context.tool_manager |
| 78 | |
| 79 | # Track transport failures for recovery detection |
| 80 | self._transport_failures = 0 |
| 81 | self._consecutive_transport_failures = 0 |
| 82 | |
| 83 | # Track state for callbacks |
| 84 | self._call_metadata: dict[str, ToolCallMetadata] = {} |
| 85 | self._cancelled = False |
| 86 | |
| 87 | # Track which tool_call_ids have received results (for orphan detection) |
| 88 | self._result_ids_added: set[str] = set() |
| 89 | |
| 90 | # Track page_fault calls within a conversation to prevent re-fault loops |
| 91 | self._faulted_page_ids: set[str] = set() |
| 92 | |
| 93 | # Give the context a back-pointer for Ctrl-C cancellation |
| 94 | # Note: This is the one place we set an attribute on context |
| 95 | context.tool_processor = self |
| 96 | |
| 97 | async def process_tool_calls( |
| 98 | self, |
nothing calls this directly
no outgoing calls
no test coverage detected