feat: add --target-dir flag to direct backend#37
Merged
Conversation
When set, all tasks run in the specified directory instead of creating per-task workspace subdirectories. This disables per-task workspace isolation while still supporting setup/teardown commands. Configurable via CLI flag (--target-dir) or YAML config (target_dir under backend.direct). Co-Authored-By: Oz <oz-agent@warp.dev>
ianhodge
approved these changes
Mar 24, 2026
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.
Summary
Add a
--target-diroption for the direct backend that runs all tasks in a specified directory instead of creating per-task workspace subdirectories. This disables per-task workspace isolation for users who want the agent to operate against an existing directory (e.g. a pre-existing repo checkout).Changes
internal/config/config.go: Addtarget_dirfield toDirectConfigYAML schema.internal/worker/direct.go:TargetDirtoDirectBackendConfig.NewDirectBackend: validate target dir exists at startup; skip workspace root setup when target dir is set.ExecuteTask: use target dir as working directory when set, skipping per-task subdirectory creation. Shared directory is never deleted on cleanup (teardown commands still run).Shutdown: early-return whenWorkspaceRootis empty (target-dir mode) to avoid spurious warnings.runTeardownIfConfiguredfromcleanupto reuse in both code paths.defer os.Remove(envFilePath)to clean up temp env files explicitly (previously relied on workspace dir removal).main.go: Add--target-dirCLI flag, wire throughmergeConfigwith CLI > config file precedence.internal/config/config_test.go: Add test fortarget_dirconfig parsing.Usage
Testing
go build ./...— compiles cleanly.go test ./...— all tests pass, including newTestLoadDirectConfigWithTargetDir.target_diris set, no per-task subdirectory is created; when unset, behavior is unchanged.Co-Authored-By: Oz oz-agent@warp.dev
Conversation