{{ message }}
Repository navigation
feat(opencode): add run_in_background to shell tool with auto notification - #47231
Closed
Kai-Liu001 wants to merge 3 commits into
Closed
Kai-Liu001 wants to merge 3 commits into
Kai-Liu001 wants to merge 3 commits into
Conversation
Author
Author
|
Pushed a second commit adding the observation/control half:
Tests: 3 new cases in |
…ation Long-running commands can now be launched with run_in_background=true. The tool returns immediately with a jobId; when the command exits, its output is injected into the session as a synthetic message so the model is re-invoked automatically. Gated behind OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS. Metadata streaming and the tool-call abort race are skipped for background jobs since the tool call has already completed by the time the command exits. Timeout stays honored when passed explicitly.
Background shell commands now tee all output to a log file (logPath in the result and job metadata), so live progress can be inspected anytime with Read/Grep instead of polling. The new bash_jobs tool lists background shell jobs (id, status, command, log path) and kills one by job id, killing the whole process group. Cancelled jobs do not trigger the completion injection.
bash_jobs now lists both background shell commands (type bash, with log path) and background subagents (type task, with child session id), and kill works for both kinds. Subagent cancellation rides the existing onInterrupt wiring in the task tool.
Kai-Liu001
force-pushed
the
shell-background-jobs
branch
from
September 7, 2026 10:25
9ef8b4f to
2bd2f8a
Compare
Contributor
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.

Issue for this PR
Closes # (no existing issue, happy to file one if useful)
Type of change
What does this PR do?
The shell tool is synchronous, so long-running commands (dev servers, watch modes, long test suites) block the turn until they exit or time out.
This adds a
run_in_backgroundparameter. When set, the command runs via the existingBackgroundJobregistry (same one the task tool uses for background subagents), the tool returns immediately with ajobId, and when the command exits its output is injected into the session as a synthetic message so the model gets re-invoked automatically. No polling needed.Background jobs skip the live metadata streaming and the tool-call abort race, since the tool call is already done by the time the command exits. An explicit
timeoutis still honored. Gated behind the sameOPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTSflag the task tool uses. Job state stays process-local, consistent with the existing registry.How did you verify your code works?
test/tool/shell.test.tscovering the immediate return, the completed job output, the synthetic prompt delivery, and the flag-disabled rejection.sleep 20 && echo ...returned instantly, I could keep chatting while it ran, and the completion notice came back on its own ~20s later.Screenshots / recordings
Not a UI change.
Checklist