Yield CTPToolResult for each call.
(
self, calls, timeout=None, on_tool_start=None, max_concurrency=4
)
| 118 | ) |
| 119 | |
| 120 | async def stream_execute_tools( |
| 121 | self, calls, timeout=None, on_tool_start=None, max_concurrency=4 |
| 122 | ): |
| 123 | """Yield CTPToolResult for each call.""" |
| 124 | import platform |
| 125 | import os |
| 126 | |
| 127 | for call in calls: |
| 128 | self.executed_tool = call.tool |
| 129 | self.executed_args = call.arguments |
| 130 | |
| 131 | # Invoke start callback if provided |
| 132 | if on_tool_start: |
| 133 | await on_tool_start(call) |
| 134 | |
| 135 | if self.raise_exception: |
| 136 | now = datetime.now(UTC) |
| 137 | yield CTPToolResult( |
| 138 | id=call.id, |
| 139 | tool=call.tool, |
| 140 | result=None, |
| 141 | error="Simulated execute_tool exception", |
| 142 | start_time=now, |
| 143 | end_time=now, |
| 144 | machine=platform.node(), |
| 145 | pid=os.getpid(), |
| 146 | ) |
| 147 | elif self.return_result.get("isError"): |
| 148 | now = datetime.now(UTC) |
| 149 | yield CTPToolResult( |
| 150 | id=call.id, |
| 151 | tool=call.tool, |
| 152 | result=None, |
| 153 | error=self.return_result.get("error", "Simulated error"), |
| 154 | start_time=now, |
| 155 | end_time=now, |
| 156 | machine=platform.node(), |
| 157 | pid=os.getpid(), |
| 158 | ) |
| 159 | else: |
| 160 | now = datetime.now(UTC) |
| 161 | yield CTPToolResult( |
| 162 | id=call.id, |
| 163 | tool=call.tool, |
| 164 | result=self.return_result.get("content"), |
| 165 | error=None, |
| 166 | start_time=now, |
| 167 | end_time=now, |
| 168 | machine=platform.node(), |
| 169 | pid=os.getpid(), |
| 170 | ) |
| 171 | |
| 172 | |
| 173 | class DummyContext: |
nothing calls this directly
no test coverage detected