Add timeout support to terminal tool #44895
Merged
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