Execute a tool, applying the configured timeout if set. On timeout, returns an error describing which tool timed out and after how many milliseconds. The caller converts this to a tool-result error message that is fed back to the LLM.
(
&self,
name: &str,
args: &serde_json::Value,
ctx: &ToolContext,
)
| 82 | /// how many milliseconds. The caller converts this to a tool-result error |
| 83 | /// message that is fed back to the LLM. |
| 84 | async fn execute_tool_timed( |
| 85 | &self, |
| 86 | name: &str, |
| 87 | args: &serde_json::Value, |
| 88 | ctx: &ToolContext, |
| 89 | ) -> anyhow::Result<crate::tools::ToolResult> { |
| 90 | let fut = self.tool_executor.execute_with_context(name, args, ctx); |
| 91 | if let Some(timeout_ms) = self.config.tool_timeout_ms { |
| 92 | match tokio::time::timeout(Duration::from_millis(timeout_ms), fut).await { |
| 93 | Ok(result) => result, |
| 94 | Err(_) => Err(anyhow::anyhow!( |
| 95 | "Tool '{}' timed out after {}ms", |
| 96 | name, |
| 97 | timeout_ms |
| 98 | )), |
| 99 | } |
| 100 | } else { |
| 101 | fut.await |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /// Execute a tool through the lane queue (if configured) or directly. |
| 106 | async fn execute_tool_queued_or_direct( |
no test coverage detected