Add timeout support to terminal tool#44895
Merged
nathansobo merged 7 commits intomainfrom Dec 15, 2025
Merged
Conversation
Adds an optional `timeout_ms` parameter to the terminal tool that allows bounding the runtime of shell commands. When the timeout expires, the running terminal task is killed and the tool returns with the partial output captured so far. Changes: - Add `timeout_ms` field to TerminalToolInput schema - Extend TerminalHandle trait with kill() method - Implement kill() for AcpTerminalHandle and EvalTerminalHandle - Race terminal exit against timeout, killing on expiry - Update system prompt to recommend using timeouts for long-running commands - Add test for timeout behavior - Update .rules to document GPUI executor timers for tests Release Notes: - agent: Added optional `timeout_ms` parameter to the terminal tool, allowing the agent to bound command runtime and prevent indefinite hangs
Combine rules 6 and 7 in system prompt to allow running potentially blocking commands (servers, file watchers, long builds) as long as a timeout_ms is specified. The user can always request a longer timeout or no timeout if they're willing to wait or cancel manually.
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
Adds an optional `timeout_ms` parameter to the terminal tool that allows bounding the runtime of shell commands. When the timeout expires, the running terminal task is killed and the tool returns with the partial output captured so far. ## Summary This PR adds the ability for the agent to specify a maximum runtime when invoking the terminal tool. This helps prevent indefinite hangs when running commands that might wait for network, user prompts, or long builds/tests. ## Changes - Add `timeout_ms` field to `TerminalToolInput` schema - Extend `TerminalHandle` trait with `kill()` method - Implement `kill()` for `AcpTerminalHandle` and `EvalTerminalHandle` - Race terminal exit against timeout, killing on expiry - Update system prompt to recommend using timeouts for long-running commands - Add test for timeout behavior - Update `.rules` to document GPUI executor timers for tests ## Testing - Added `test_terminal_tool_timeout_kills_handle` which verifies that when a timeout is specified and expires, the terminal handle is killed and the tool returns with partial output. - All existing agent tests pass. Release Notes: - agent: Added optional `timeout_ms` parameter to the terminal tool, allowing the agent to bound command runtime and prevent indefinite hangs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
timeout_msparameter to the terminal tool that allows bounding the runtime of shell commands. When the timeout expires, the running terminal task is killed and the tool returns with the partial output captured so far.Summary
This PR adds the ability for the agent to specify a maximum runtime when invoking the terminal tool. This helps prevent indefinite hangs when running commands that might wait for network, user prompts, or long builds/tests.
Changes
timeout_msfield toTerminalToolInputschemaTerminalHandletrait withkill()methodkill()forAcpTerminalHandleandEvalTerminalHandle.rulesto document GPUI executor timers for testsTesting
test_terminal_tool_timeout_kills_handlewhich verifies that when a timeout is specified and expires, the terminal handle is killed and the tool returns with partial output.Release Notes:
timeout_msparameter to the terminal tool, allowing the agent to bound command runtime and prevent indefinite hangs