Skip to content

The VS Code Agent Harness: How the Coding Loop Works

What Is the Coding Harness?

Every conversation about AI-assisted coding eventually arrives at the same question: which model is best? That question is less useful than it appears, because the model is only one component of an agentic coding experience. What developers actually interact with is the coding harness — the system layer that assembles context, exposes tools, runs the agent loop, interprets tool calls, and turns a model's text output into concrete editor actions.

The harness is not a thin wrapper. In Visual Studio Code, it is the product. When a new model ships, it must fit into an existing harness built and tuned over months of real-world use. The system prompt, tool definitions, loop logic, and context assembly all predate any individual model. The model gets better at filling in the blanks; the harness defines what the blanks are.

This matters because GitHub Copilot in VS Code supports models from multiple providers — switching models or adding a new provider does not change the underlying harness. Users experience the same chat interface, the same tool picker, the same terminal integration, regardless of which model is running underneath.

Three Core Responsibilities

The VS Code harness has three distinct responsibilities, each of which shapes what the agent can and cannot do.

Context Assembly

Before any request reaches the model, the harness builds the prompt. That prompt is not simply the user's query — it includes:

  • A system message with behavioral instructions (tuned per model and per model version)
  • The user's query for this turn
  • Workspace structure: languages detected, frameworks in use, open editors
  • Conversation history from prior turns in the session
  • Tool results from prior rounds in the current turn
  • Custom instructions defined by the user or workspace configuration
  • Memory from earlier sessions (where available)

The harness decides what the model sees. These decisions directly determine output quality. A model that lacks the right workspace context will suggest changes that don't match codebase structure; a model that can see open editors and recent terminal output can make much more targeted edits. Two models running under the same harness with different context assembly configurations will behave very differently on identical user queries.

Tool Exposure

The harness declares the tools the model is allowed to call, each with: - A JSON schema the model must follow when invoking the tool - A description the model uses to decide when and whether to invoke it

Standard tools in the VS Code harness include: read_file, replace_string_in_file (or apply_patch for GPT models), run_in_terminal, and semantic_search. The available tool set is not fixed — it varies per request based on: which model is in use (some tools are model-gated), user confirmation requirements for sensitive operations, the user's tool picker configuration, and contributions from MCP servers and VS Code extensions. Custom agent modes defined in .agent.md files can restrict the tool set to a specific subset for a given workflow.

Tool Execution

When the model emits a tool call — a JSON object like {"name": "run_in_terminal", "arguments": {"command": "npm test"}} — the harness validates the arguments, executes the tool, handles errors, formats the result, and feeds it back in the next iteration. None of this happens inside the model. The model only produces text describing what it wants done. The harness is the executor. Tool results re-enter the prompt as observations for the model's next decision.

The Agent Loop

The agent loop is the orchestration mechanism that turns a model's outputs into a sustained working session. Its structure is: think → act → observe → think again.

VS Code uses three distinct terms for the layers of this loop:

  • Turn: A single user-visible exchange. The user sends one message; the agent eventually produces one response. A turn is what appears in the chat UI.
  • Round: One pass through the loop — build the prompt, call the model, receive output (text and/or tool calls), execute any tool calls, record results, decide whether to continue.
  • Run: The full execution of all rounds within a single turn.

A single turn may involve many rounds. A representative sequence: the model searches files in round 1, reads relevant code in round 2, proposes an edit in round 3, runs tests in round 4, reads the failure output in round 5, and revises the edit in round 6 — all within a single user turn before the final response appears.

Prompt rebuilding on every round: The harness rebuilds the full prompt on each iteration, so the model always sees the current workspace state. If a file was edited three rounds ago, the prompt in round 4 reflects that edit. This prevents the model from acting on stale observations.

Loop-control bounds: The loop is not open-ended. VS Code enforces a tool-call limit, checks for user cancellation between rounds, and runs stop hooks — extension points that inspect agent state and either allow the loop to finish or push it to continue.

Summarization: When accumulated conversation history grows too large for the context window, the harness compresses earlier rounds into a summary so the model can keep working without losing the thread of the session.

Per-Model Harness Differences

GitHub Copilot in VS Code supports models from multiple providers, and the harness adapts to each. The differences are not cosmetic — they affect which tools work, how the loop behaves, and what the system prompt says.

Documented per-model differences:

  • Claude models use replace_string_in_file for code edits; GPT models use apply_patch. Both produce correct edits when used with their respective schemas, but the two tools are not interchangeable across model families.
  • Gemini requires explicit reminders in the system prompt to use tool-calling rather than narrating actions as prose, and breaks on orphaned tool calls left in conversation history.
  • Some models support extended thinking with reasoning-effort controls (high / medium / low). For these, the harness exposes effort controls and the system prompt includes guidance on when to reason deeply.
  • System prompt length: some models perform best with concise behavioral instructions; others require verbose, structured directives to stay on track. Choosing the wrong length degrades output quality even on capable models.
  • Different Claude checkpoints (Sonnet 4, 4.5, Opus) each receive different system prompts, tuned independently for each checkpoint's behavioral characteristics.

When a new model ships, integration is not simply adding a dropdown entry. The team validates tool schemas, retunes system prompts and defaults, and runs full agent sessions before release. Model providers often grant early access to pre-release checkpoints so harness tuning can begin before general availability.

VSC-Bench: The Product Evaluation Suite

Public model benchmarks (SWE-bench, Terminal-Bench) provide useful reference points but have documented limitations at frontier quality levels:

  • SWE-bench focuses on public bug-fixing tasks; contamination risk increases as models memorize known gold patches.
  • Terminal-Bench tasks can resemble isolated shell puzzles rather than the multi-file, multi-tool workflows developers bring to an editor.

The VS Code team built VSC-Bench, an internal evaluation suite covering VS Code-specific developer tasks that public benchmarks don't cover:

  • Custom agent modes
  • Extension workflows
  • MCP and tool use
  • Terminal and browser interaction
  • Multi-turn conversations
  • Multi-language coding (TypeScript, Python, C++, and others)

Evaluation dimensions: solution correctness, agent effort, token efficiency, and latency. Each task runs in a reproducible containerized workspace — the harness launches VS Code, opens the workspace, sends one or more user prompts, lets the agent respond with text and tool calls, and evaluates outcomes. This gives a realistic view of the full agent loop, not just final code output quality.

An example finding from 40 VSC-Bench runs across eight model-effort configurations: the xhigh reasoning effort used more tokens than high but resolved slightly fewer tasks — evidence that it had passed the effort sweet spot where additional thinking no longer converts to better outcomes. This kind of finding informs which effort setting becomes the default for a given model.

PR-Level Benchmark Gating

Benchmarks also gate harness changes before they merge into the codebase. Any PR touching a core tool, system prompt, or agent loop logic must pass benchmark evaluation before landing. The automated workflow:

  1. Adding a ~requires-eval-assessment label to a PR triggers an automated evaluation flow.
  2. The PR is built and shipped as a versioned eval agent to an npm feed on a dev tag.
  3. The published agent is benchmarked against VSC-Bench.
  4. Results are posted back on the PR via a Logic App relay.

This means a regression in agent behavior blocks a PR the same way a test failure does — even if the code change is syntactically correct and passes unit tests. Evaluation is a first-class step in the PR lifecycle.

MCP and Extension Integration

The tool exposure model integrates naturally with MCP servers and VS Code extensions. Both can contribute new tools that slot into the agent loop through the same mechanism as built-in tools — JSON schema declaration and harness-mediated execution. Users can toggle individual tools on and off in the tool picker.

This extensibility allows teams to give the agent access to domain-specific APIs (database clients, CI/CD systems, internal search) without requiring VS Code to hard-code those integrations. Extension-contributed tools receive the same validation, execution, and error-handling treatment as native tools.

Developer Introspection

The harness is inspectable via three built-in mechanisms:

  • Tools UI in Chat: shows which tools are available for the current request, including which are enabled and which are gated.
  • Chat Debug View: displays the prompts, tool calls, and results behind each agent run — useful for diagnosing why an agent made a particular decision.
  • VS Code source code: the harness is open source and can be read directly.

These introspection points are useful both for developers building on the harness (via MCP or extensions) and for end users trying to understand agent behaviour in complex sessions.

Changelog

2026-05-20 — Page created from code.visualstudio.com blog May 15, 2026 (Type B official vendor docs, confidence 78)