GitHub

Content type: News

5 min read

GitHub creates open protocol for AI agents that survive device switching

News
Reading
5 min
In short

The Agent Host Protocol was born inside VS Code and today also runs in the Copilot app and GitHub's cloud, allowing you to start an agent task on one device and continue on another without losing context.

GitHub published a technical engineering report explaining how it built the Agent Host Protocol (AHP), an open standard that lets you start an AI agent session on one device and continue exactly where you left off on another. The idea addresses a problem that became more visible as models started working on their own for hours or days: developers don't need to watch every step, but they do need to be able to check progress from anywhere, without the agent "dying" along with the window that started it.

The problem: one integration per client didn't scale

Copilot started out as a VS Code extension, with its own embedded harness. That worked, but it tied the agent's lifecycle to the editor window's lifecycle. Closing the window killed the agent. Updating VS Code restarted everything. Connecting to a remote machine created a new extension host locked to the version of the workbench installed there.

Meanwhile, the Copilot app and GitHub's mobile apps for iOS and Android were being developed in parallel, each building its own isolated integration with agents running in the cloud. Each integration solved the problem for one specific product, but a developer who wanted to bring their agents to a custom editor, a terminal, or a homegrown tool ran into the lack of a common standard. Without a shared protocol, each client saw a different set of agents, history, and state.

Channels and reducers: how AHP works under the hood

The protocol needed to let multiple clients talk to the same set of agents at the same time: starting a session in the cloud from a phone and continuing on a laptop, tolerating network drops, reconnections, and concurrent mutations. At the same time, AHP avoids dictating how an agent should behave (unlike what the Language Server Protocol and the Debug Adapter Protocol did in their respective domains), because the agent field still changes too fast to lock that behavior into a standard.

The final design is built around URI-identified "channels," the coarsest unit of functionality in the protocol. Every server must implement the root, session, and chat channels; additional channels cover terminal support, MCP extensions, or reporting via OTel. Inside each channel there's a reducer-based state object: the server arbitrates the state, and each client sends a sequence of actions that mutate that state or trigger side effects, such as sending a chat message.

Diagram of the Agent Host Protocol showing three clients (VS Code, Copilot App, and phone) exchanging dispatchAction and action with the host, whose ahp-root, ahp-session, and ahp-chat channels keep an ordered action log that feeds a reducer to generate the next state
Diagram of the Agent Host Protocol showing three clients (VS Code, Copilot App, and phone) exchanging dispatchAction and action with the host, whose ahp-root, ahp-session, and ahp-chat channels keep an ordered action log that feeds a reducer to generate the next state. Reprodução: blog.github.com.

This model brings three practical advantages, according to GitHub's report:

  • Reconnection and replay are simple on bad networks: the client resends the action queue, shows the correct loading state, and waits for the server to confirm.
  • Clients and servers are easier to debug, because the action flow is explicit.
  • The reducer pattern fits well with popular UI frameworks like React.

Two implementations, two languages

Putting AHP into production required rewriting much of what already existed. The VS Code Copilot Chat extension had been growing for more than three years and reached 400,000 lines of TypeScript, not counting tests, but it was structured around the lifecycle of a VS Code window and depended entirely on the editor's extension API (something that wouldn't exist in a standalone agent host process). The solution found was to use the Copilot SDK, which was already in development, as the base for the new agent stack, work that started in early 2026.

In parallel, GitHub had already had cloud agents for a few years and wanted to coordinate sessions across the Copilot app, its own devices, and cloud sandboxes (the same N:M problem AHP was designed to solve). The requirements were different from VS Code's, though: GitHub's host needs to run in the cloud, over a much wider variety of infrastructure and security constraints. That's why the two implementations were born in different languages: VS Code's in TypeScript, GitHub's in Rust.

Having two independent hosts worked as a stress test for the protocol itself. After months working separately, the teams mapped out where each implementation had extended AHP on its own. Some of those extensions were legitimately GitHub-specific, such as metadata linking sessions to project boards. Others revealed real gaps in the protocol, like the initial difficulty representing output from shell-type tools that didn't come from a PTY. And there were also wrong assumptions, such as the VS Code client assuming a fixed structure for session URIs coming from the agent host.

What changes for developers

Today AHP already sustains the same session continuity across VS Code, the Copilot app, and GitHub's cloud sandboxes: an agent started on any of these surfaces shares the same protocol. The relevant point for anyone building software is that AHP is open and was designed to be easy to implement outside of GitHub.

Ready-made libraries exist in Rust, TypeScript, Kotlin, Swift, .NET, and Go for anyone who wants to write their own client or server for the protocol. The report cites concrete examples of people who have already built on top of it: a macropad that shows the agent's state in real time, smartwatch apps, and Kanban-style task management tools connected via AHP.

To try it out in practice, you can:

  1. In the Copilot app, enable Experimental > Direct Connections and then Environments > Add Agent Host Protocol Host.
  2. In VS Code, use Add Remote Agent Host in the Agents window.
  3. Spin up a standalone instance of VS Code's agent host by running code agent host in the terminal.
  4. Query the endpoints of the host already built into the editor with code agent endpoints.

What's still open

GitHub describes AHP as an open standard and invites the community to send questions and suggestions through its own GitHub repository. That means the protocol is still evolving, and gaps like the ones found between the VS Code and GitHub implementations (shell output without a PTY, assumptions about URI structure) are likely to keep showing up as more third-party clients adopt the standard.

For teams that currently maintain homegrown integrations with AI agents, tied to the specific API of one editor or app, AHP offers an alternative: building against an independently versioned protocol, instead of reimplementing the same bridge every time a new client appears.

Translated from the Brazilian Portuguese original · Read the original