Skip to content

🤖 feat: add isolation:none for non-local sub-agent tasks#3475

Open
ammar-agent wants to merge 2 commits into
mainfrom
agent-isolation-cs0v
Open

🤖 feat: add isolation:none for non-local sub-agent tasks#3475
ammar-agent wants to merge 2 commits into
mainfrom
agent-isolation-cs0v

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

Summary

Adds an isolation: none | fork configuration to the task tool so sub-agents on non-local runtimes (worktree/SSH) can run directly in the parent workspace's checkout instead of paying for a fork. fork remains the default to preserve current semantics. The parameter is runtime-conditional: on local runtimes it is omitted from the tool schema entirely, so it never enters LLM context.

Background

On worktree/SSH runtimes, every spawned sub-agent forks a new checkout (git worktree / remote clone) plus runs init hooks. For read-only analysis (e.g. explore) — or when the caller has already arranged isolation via the prompt — that overhead is pure waste. Local runtimes already share the project directory, so forking is a no-op there and the option is meaningless (hence hidden).

Implementation

  • Runtime-conditional tool schema (the novel part). createTaskTool now builds its inputSchema per runtime: buildTaskToolAgentArgsSchema({ includeIsolation }). isolation is only included for runtimes that support sharing the parent checkout (runtimeModeSupportsSharedTaskWorkspace → worktree/SSH). The local schema is .strict() without the field, so the model is never shown it. The canonical schema (with isolation) is still used for the execute() re-parse and token counting.
  • No-fork path in TaskService.create. When isolation: "none" is honored, the task skips orchestrateFork, points its workspace path at the parent's checkout, reuses the parent runtime, and skips runBackgroundInit (the parent dir is already initialized). The queued + dequeue paths persist/honor the same flag (taskIsolation), and the dequeue fork-fallback (parent checkout gone) clears the flag.
  • Deletion safety. A new taskIsolation field is persisted on the workspace config entry. WorkspaceService.remove skips physical runtime deletion for taskIsolation: "none" tasks so removing a shared task never deletes the parent's working tree. (Deletion is already keyed on the task's unique name — a no-op for shared tasks — but the guard makes the invariant explicit and future-proof.)
  • Scope. Honored for worktree and ssh (the runtimes named in the request). docker/devcontainer tie runtime identity to the workspace name in the runtime factory, so they are intentionally excluded for now; multi-project parents also fall back to forking.

Validation

  • make static-check green (incl. regenerated docs/hooks/tools.mdx + built-in skill snapshot from the new tool param).
  • New tests: schema is runtime-conditional (task.test.ts asserts the advertised schema rejects/accepts isolation per runtime; toolDefinitions.test.ts covers the builder + description gating; runtime.test.ts covers the gating helper), isolation is forwarded to TaskService.create, an integration test that isolation: "none" shares the parent worktree without calling orchestrateFork/runBackgroundInit, and a guard test that remove never deletes the shared parent checkout.

Risks

  • Touches the hot TaskService.create path (immediate + queued + dequeue) and WorkspaceService.remove. The shared path is gated behind an opt-in flag and supported runtimes; default fork behavior is unchanged. Main regression surface is task lifecycle (create/remove) on worktree/SSH — covered by the full taskService/workspaceService suites.

Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: max • Cost: $n/a

Allow worktree/SSH sub-agents to skip fork overhead by sharing the parent
workspace checkout (isolation: none|fork, default fork). The isolation tool
parameter is conditionally added to the task tool schema based on runtime, so
it never enters LLM context on local runtimes.
@mintlify
Copy link
Copy Markdown

mintlify Bot commented Jun 5, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Mux 🟢 Ready View Preview Jun 5, 2026, 9:34 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f4c7f284b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/types/runtime.ts
Codex P1: worktree isolation:none tasks resolved cwd/ensureReady from the
name-derived child path (never created) instead of the parent checkout. Make
WorktreeRuntime honor an explicit workspacePath override (mirroring SSHRuntime)
so shared tasks land in the parent's checkout. Adds WorktreeRuntime tests.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the P1 (worktree shared-checkout resolution):

WorktreeRuntime now honors an explicit workspacePath override (mirroring SSHRuntime.getWorkspacePath). For an isolation: "none" task, the runtime is built with the child's unique name but the parent's persisted checkout path, so getWorkspacePath / ensureReady / cwd resolution all land in the parent checkout instead of the name-derived directory that was never created. Added WorktreeRuntime.test.ts covering the override + ensureReady. (SSH already honored the override via its identity-keyed getWorkspacePath.)

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant