Skip to content

feat: add per-tool-call timeout to Tool trait #337

@chaliy

Description

@chaliy

Summary

The `Tool` trait's `execute()` method has no per-call timeout parameter. If an agent sends a script that runs too long, there's no way for the orchestrating system to abort it except by dropping the future.

Current state

  • Resource limits (max_commands, max_iterations) are set on the `BashTool` instance at build time
  • `timeout` builtin exists for wrapping individual commands
  • But no way for the tool caller to say "this entire call must complete in N seconds"

Proposed API

```rust
pub struct ToolRequest {
pub commands: String,
pub timeout_ms: Option, // NEW: per-call timeout
}
```

Or alternatively:
```rust
async fn execute_with_timeout(
&mut self,
req: ToolRequest,
timeout: Duration,
) -> ToolResponse;
```

Use cases

  1. Agent frameworks with per-tool timeouts (LangChain, CrewAI)
  2. Preventing runaway scripts in production
  3. Different timeouts for different task types (quick query vs. data processing)

Acceptance criteria

  • Per-call timeout on Tool execute
  • Proper cleanup on timeout (VFS state consistent)
  • Clear error message when timed out
  • Update tool contract spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions