Repository navigation
Add BackgroundCodeExecToolProvider for long-running commands - #100
Draft
MohamedAkbarally wants to merge 1 commit into
Draft
MohamedAkbarally wants to merge 1 commit into
MohamedAkbarally wants to merge 1 commit into
Conversation
Wraps a sandboxed backend (Docker, E2B, or custom) so code_exec can return while a command keeps running, with a process_control tool to poll, terminate, or list those processes. Each command runs in its own tmux session; output goes to a bounded ring buffer, is previewed head/tail inline, and saved in full to a file. Teardown terminates every process the provider started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
Adds
BackgroundCodeExecToolProvider, which wraps any sandboxedCodeExecToolProviderand replaces its blockingcode_execwith two tools:code_execstarts a Bash command and waits up toyield_time_ms(clamped betweenmin_wait_secandmax_yield_time_sec). If the command is still running when the wait ends, it keeps running and the result includes aprocess_id.wait_for="output"returns early when new output appears.process_controlpolls a process for new output, terminates it with its process tree, or lists the processes still running.This lets agents run builds, test suites and dev servers without blocking a turn until they finish, or until the shell timeout kills them.
How
cgroup.killwhen it's writable, then the process group, then the recorded process tree, and checks that nothing survives. When the provider exits, it terminates everything it started. Each provider instance uses its own process root, so two providers in one sandbox don't touch each other's processes.Constraints
BACKGROUND_TOOLS). The provider checks this on enter and fails with a clear error.LocalCodeExecToolProvider(its absolute-path guard blocks the paths the provider uses) and backends withallowed_commands(the provider needs a shell).share_parent_exec_env=Truegets the backend's blockingcode_exec, notprocess_control.Testing
tests/test_background_execution.py: 12 tests against a real Bash backend on the host. They cover exit codes, backgrounding and polling,wait_for="output", terminating a process tree, cleanup on exit, large-output previews and the saved file, commands over 200 KB,workdir, the minimum wait, and backend validation. They're skipped where the tools aren't installed.DockerCodeExecToolProviderwith a Debian image that has tmux and procps: start, background, poll, terminate and file I/O all worked.ruff,tyand the full suite (-m "not browser") pass.🤖 Generated with Claude Code