Choose and use an agent harness

An agent harness coordinates an agent session, including tool calls, context, and code changes. In Visual Studio Code, you choose an agent harness and where it runs with the Session Target control. This article helps you choose a harness and covers the capabilities that are specific to Local, Copilot, Claude, Codex, and cloud sessions.

For the relationship between harnesses, language models, agent roles, and execution environments, see Agent harnesses.

Compare agent harnesses

Most harnesses share the same chat and session-management experience in VS Code. Your choice primarily affects where the agent runs, which tools and models it can use, and how it applies code changes.

Session target Where it runs Code access Choose it for
Local In the VS Code extension host on your machine Current workspace Interactive work that needs VS Code tools, extension tools, or any model configured in VS Code
Copilot On the Agent Host on your machine Current folder or an isolated Git worktree General coding tasks with the Copilot SDK and Copilot-specific capabilities
Claude On your machine Current folder or an isolated Git worktree Anthropic's agent capabilities, slash commands, and permission modes
Codex On your machine Current folder or an isolated Git worktree OpenAI's Codex capabilities for interactive or background work
Cloud On the provider's remote infrastructure A GitHub repository and pull request Well-scoped tasks that can run independently and benefit from team review

Select an agent harness

You can select an agent harness when you start a new session in the Chat view or the Agents window. When you change the agent harness for an ongoing session, VS Code considers this a handoff and carries the conversation history and context to the new harness.

To select an agent harness:

  1. Open the Chat view (⌃⌘I (Windows, Linux Ctrl+Alt+I)) or Agents window

  2. Select New Chat (+)

  3. Open the Session Target control and choose from the available agent harnesses.

    Screenshot of the Session Target control in the Agents window.

  4. Depending on the selected harness, other options for language model, isolation mode, or custom agents are available.

Learn more about creating and managing sessions.

Choose code isolation

Agent sessions that run on your machine (local, Copilot, Claude, and Codex) can make changes directly to your codebase or in an isolated Git worktree. You can choose the isolation mode when you start a new session in the Chat view or the Agents window.

Copilot, Claude, and Codex sessions that run on your machine can work in your current folder or a new Git worktree.

Choice Where changes go Choose it for Considerations
New Worktree A new branch and worktree Parallel tasks that should not modify your active workspace Starts from committed Git state and requires you to integrate the result
Folder Your current folder Small, interactive tasks that should use your current files and uncommitted changes Agent edits appear immediately in your active workspace

When you start a session in the Agents window, select New Worktree and choose the base branch to isolate the session. If you leave New Worktree unselected, the agent works directly on the code in the workspace. Sessions that you start in the Chat view always use the current workspace.

Screenshot of the New Worktree checkbox and base branch control in the Agents window.

Worktree isolation requires a Git repository with at least one commit. A new worktree contains the committed files from the selected base branch. It does not automatically contain uncommitted tracked changes or untracked files from your primary worktree. Commit changes that the agent needs, or use folder isolation when the task depends on your current uncommitted state.

Git-ignored files, such as .env files and installed dependencies, are also absent by default. Use git.worktreeIncludeFiles Open in VS Code Open in VS Code Insiders to specify ignored files and folders that VS Code should copy into new worktrees. Learn more about including files in a worktree.

Worktree sessions use Bypass Approvals because their code changes are separate from your active workspace. Folder sessions offer the permission levels supported by the selected harness. Worktree isolation does not restrict commands, network access, or access outside the worktree. For those protections, configure agent sandboxing.

Use an agent harness

The Local harness runs interactively in the VS Code extension host and works directly in your current workspace. It can use VS Code built-in tools, extension-provided tools, MCP servers, and the models configured in VS Code, including bring your own key models.

Choose Local for interactive tasks that need immediate feedback or access to editor context, such as diagnostics, test results, terminal output, or selections.

Choose a built-in agent role

Local sessions provide these built-in agent roles:

  • Agent: autonomously plans and performs complex coding tasks, edits files, runs commands, and iterates on results.
  • Plan: researches a task and creates a structured implementation plan before code changes. Learn more about planning with agents.

You can switch roles during a session from the agent picker. For specialized workflows, create a custom agent.

Use Copilot CLI from the terminal

VS Code includes a GitHub Copilot CLI terminal profile. Open it from the Terminal profile dropdown, run Chat: New Copilot CLI Session from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)), or enter copilot in an integrated terminal.

When you start a Copilot CLI session in the terminal, VS Code detects it and adds it to the sessions list. Right-click an existing Copilot session and select Resume in Terminal to continue it from the terminal.

Hand off a session

Handoff changes the target for an ongoing session and carries the conversation history and context to the new target. Use handoff when another harness or execution environment is a better fit for the next part of the task.

For example, continue a Copilot session with Claude or Codex to use provider-specific capabilities, send a well-scoped task to a cloud harness for a pull request workflow, or move from the Plan agent to an implementation agent.

To hand off an ongoing session:

  1. Open the session.

  2. In the chat input, open the Session Target dropdown.

  3. Select the target that should continue the work, such as Copilot, Claude, Codex, or Cloud.

VS Code carries the conversation history and context to the selected target. The tools, permissions, and models might change because each target provides different capabilities.

Tip

In Copilot CLI, enter /delegate to continue the work with a cloud agent.

Hand off a plan to implementation

The Plan agent focuses on researching a task and creating a plan without changing code. After you review the plan:

  1. Select Start Implementation.

  2. Choose an available implementation agent.

The implementation agent receives the plan and conversation context and starts implementing it.

Action What it does
Hand off Changes the session target and carries the conversation history and context to the new target.
Fork a session Creates an independent session from a point in the conversation. Learn more about forking sessions.
Switch surfaces Opens the same session in the Chat view or Agents window without changing its target or context.

For background on how handoff works, see Sessions and handoff.