feat: add background command execution support to execute_command tool #9075
+187
−11
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.
Summary
This PR adds support for background command execution in the
execute_commandtool, allowing commands to run asynchronously without blocking the workflow.Problem
Currently, all commands executed through the
execute_commandtool block the workflow and may require user interaction via prompts. This limits the ability to run long-running processes or scripts that should execute in the background while the agent continues with other tasks.Solution
Added a new optional
backgroundparameter to theexecute_commandtool that allows for non-blocking command execution.Changes Made
1. Core Implementation
src/shared/tools.ts: Added "background" parameter to toolParamNames array and ExecuteCommandToolUse interfacesrc/core/tools/executeCommandTool.ts: Implemented background execution logic with async handlingsrc/integrations/terminal/TerminalProcess.ts: Updated to support background execution2. Documentation Updates
src/core/prompts/tools/execute-command.ts: Updated tool prompt with background parameter documentationsrc/core/prompts/sections/capabilities.ts: Updated capabilities documentation3. Testing
src/integrations/terminal/__tests__/background-execution.spec.ts: Comprehensive test suite for background executionUsage
Standard Command (blocking)
Background Command (non-blocking)
Behavior
background=true: Command executes asynchronously, no user prompts, continues workflowbackground=falseor omitted: Standard behavior (blocking, may show prompts)execute_commandusage continues to work unchangedBenefits
Testing
background=trueandbackground=falsescenariosFiles Changed
Checklist
Important
Adds background execution support to
execute_commandtool with a newbackgroundparameter, enabling asynchronous command execution.backgroundparameter toexecute_commandtool for asynchronous execution insrc/core/tools/executeCommandTool.ts.getExecuteCommandDescription()insrc/core/prompts/tools/execute-command.tsto documentbackgroundparameter.background=true(non-blocking) andbackground=false(blocking) modes.background-execution.spec.tsfor background execution scenarios.background=true,background=false, and default behavior.toolParamNamesandExecuteCommandToolUseinsrc/shared/tools.tsto includebackgroundparameter.This description was created by
for 945d3fc. You can customize this summary. It will automatically update as commits are pushed.