Skip to content

feat(tool): add per-tool-call timeout_ms to ToolRequest#350

Merged
chaliy merged 1 commit intomainfrom
claude/feat-337-per-call-timeout-TjcEQ
Feb 27, 2026
Merged

feat(tool): add per-tool-call timeout_ms to ToolRequest#350
chaliy merged 1 commit intomainfrom
claude/feat-337-per-call-timeout-TjcEQ

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Feb 27, 2026

Summary

  • Add optional timeout_ms field to ToolRequest for per-call execution timeouts
  • Returns exit code 124 on timeout (matching bash timeout convention)
  • Both execute and execute_with_status respect the timeout
  • Backward compatible: field uses #[serde(default)] so existing JSON without it still works

Test plan

  • Unit test: timeout triggers on sleep 10 with 100ms timeout (exit 124)
  • Unit test: fast command completes within generous timeout (exit 0)
  • Unit test: ToolRequest::new() convenience constructor
  • Unit test: JSON deserialization with and without timeout_ms
  • All existing tool tests pass (49 tests)
  • CI green

Closes #337

Add optional `timeout_ms` field to `ToolRequest` that allows callers to
set per-call execution timeouts. When the timeout expires, execution is
aborted and a response with exit_code=124 is returned (matching bash
`timeout` convention).

- Add `timeout_ms: Option<u64>` with `#[serde(default)]` for backward compat
- Wrap both `execute` and `execute_with_status` with `tokio::time::timeout`
- Add `ToolRequest::new()` convenience constructor
- Add tests for timeout, no-timeout, and serde deserialization
- Update tool contract spec (009)

Closes #337
@chaliy chaliy merged commit e6c5097 into main Feb 27, 2026
16 checks passed
@chaliy chaliy deleted the claude/feat-337-per-call-timeout-TjcEQ branch February 27, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants