How does GitHub keep agent sessions alive when you switch from phone to laptop?

GitHub has published an open protocol that lets an AI agent session survive a closed window, a device change, or a network drop. The same session can now be picked up in VS Code, the Copilot app, or a mobile phone without rebuilding the integration for each client.

Why the old extension model broke

GitHub Copilot began life as a VS Code extension. That extension bundled its own harness, so the agent's lifetime was tied to a single editor window. Close the window and the agent disappeared. Update VS Code and every agent stopped while the application restarted. Connect to a remote machine and you received a brand‑new extension host locked to the workbench version on that machine.

At the same time the Copilot desktop app and the iOS and Android apps were being built. Each product wrote its own integration with cloud agents to achieve session continuity. Every integration solved the problem for one product, yet developers still wanted to pull their agents into a terminal, a custom tool, or any other client they chose. A separate integration per client does not scale.

How the protocol moves state between clients

The Agent Host Protocol (AHP) is oriented around URI‑identified channels. Every server must implement the root, session, and chat channels; additional channels can provide terminal support, MCP additions, or OTel reporting. Inside each channel sits a reducer‑based state object. The server is the arbiter of that state. Each client sends a sequence of actions that either mutate the state or trigger side effects such as sending a chat message.

This design gives three practical properties. Three. Reconnection and replay in poor network conditions are easy: a client sends all queued actions, shows a loading state, and waits for the server to reconcile and acknowledge them before confirming. Clients and servers are straightforward to debug. Reducer‑based state also plays nicely with popular UI frameworks like React.

The protocol deliberately avoids encoding how agents work. The agent landscape evolves quickly, so AHP focuses on how you want to interact with them. Escape hatches exist via custom methods and _meta data on objects for out‑of‑band signaling, similar to the approach used by MCP.

Two hosts, five clients, one wire format

Adopting AHP in VS Code required a new harness and agentic stack. The Copilot Chat extension had grown to over 400,000 lines of TypeScript and depended entirely on the VS Code extension API. Neither that lifetime nor those APIs would be available in a standalone agent host process. The Copilot SDK, developed in parallel, became the foundation for the new stack.

GitHub's own agent host had different requirements. VS Code runs its host locally and can drop it onto other compute over SSH, containers, WSL, or Dev Tunnels. The GitHub Agent Host needed to run in the cloud across a wider variety of infrastructure and security constraints. That is why the two implementations are written in different languages: VS Code's in TypeScript, GitHub's in Rust.

Having two independent implementations served as an acid test for the protocol. After months of separate work the teams inventoried the ways each had extended the protocol. Some extensions stay GitHub‑specific, such as metadata linking to project boards. Others revealed gaps — early versions could not accurately represent shell‑type tool output that lacked a PTY. A few were bad assumptions, like VS Code's client expecting a particular session URI structure. A protocol with only one implementation is not truly portable; cross‑implementation testing made AHP portable in practice.

Today the same continuity works across all VS Code and GitHub surfaces. Agent sessions running locally in the Copilot app, in cloud sandboxes, and in VS Code share the underlying protocol.

What you can connect today

AHP libraries are available in Rust, TypeScript, Kotlin, Swift, .NET, and Go. Agents can build clients and servers with little prompting. A macropad on an engineer's desk reflects agent state in real time; others have built smartwatch apps and Kanban‑style task tools against the protocol.

You can connect to an agent host you implement in the Copilot app by enabling Experimental > Direct Connections, then going to Environments > Add Agent Host Protocol Host. In VS Code the entry point is Add Remote Agent Host in the Agents window. A standalone version of VS Code's agent host spawns with code agent host in the terminal, and code agent endpoints prints the endpoints for the host running inside your editor. Samples are provided to help you and your agent get started. The protocol is an open standard; questions and suggestions are welcome on GitHub.

The sources this article was written from

  • "GitHub Blog
    https://github.blog/engineering/engineering-principles/building-the-agent-host-protocol-for-sessions-that-continue-across-devices/"

Read next