Check if execution should be stopped due to limits
(
&self,
execution_count: usize,
start_time: Instant,
)
| 548 | |
| 549 | /// Check if execution should be stopped due to limits |
| 550 | fn check_execution_limits( |
| 551 | &self, |
| 552 | execution_count: usize, |
| 553 | start_time: Instant, |
| 554 | ) -> Result<(), ToolExecutionError> { |
| 555 | if execution_count >= self.config.max_tool_calls { |
| 556 | return Err(ToolExecutionError::MaxCallsExceeded(format!( |
| 557 | "Reached maximum tool call limit: {}", |
| 558 | self.config.max_tool_calls |
| 559 | ))); |
| 560 | } |
| 561 | |
| 562 | if start_time.elapsed().as_millis() as u64 > self.config.max_execution_time_ms { |
| 563 | return Err(ToolExecutionError::ExecutionTimeout(format!( |
| 564 | "Reached maximum execution time: {}ms", |
| 565 | self.config.max_execution_time_ms |
| 566 | ))); |
| 567 | } |
| 568 | |
| 569 | Ok(()) |
| 570 | } |
| 571 | |
| 572 | /// Parse a tool call from Python object |
| 573 | fn parse_tool_call( |