Skip to main content
Engineering ••12 min read•

Agent Host Protocol Moves the Transport, Not the State

The Agent Host Protocol as a build spec: the state your app must externalize before sessions hop devices, and what a roaming session costs to secure.

The Agent Host Protocol makes the agent session, not the model, the portable unit of state that can continue across devices and hosts.

GitHub's Agent Host Protocol announcement reads like a feature launch: start a session on your laptop, check in from your phone, keep working after you close the window. The durable payload is less photogenic. The protocol elevates the session, not the model, to the unit of portable state, and that elevation forces engineering decisions the announcement never names. Four categories of state (externalized context, scoped credentials, a side-effect ledger, and rebindable tool definitions) must move out of any app that wants its sessions to hop devices or hosts. Read as a build spec, the Agent Host Protocol also tells you what a roaming session costs to run and to secure. Adoption is a pricing decision on run cost and attack surface, not a feature vote.

Stay in the loop.

Get the latest posts and exclusive content delivered to your inbox.

Join 15 readers. No spam. Unsubscribe in one click, anytime.

What the Agent Host Protocol standardizes, and what it leaves to you

GitHub introduced the Agent Host Protocol as an open protocol for connecting coding agents to hosts, meaning editors, terminals, and cloud environments, with one key property: clients can attach to and detach from running sessions from multiple devices. The stated motivation is modest and honest. Agent tasks now run for hours or days, and people need to check in from anywhere, as GitHub's engineering post puts it. The interesting engineering is what had to be true underneath that sentence.

The public spec standardizes the transport layer: JSON-RPC 2.0 style messaging (the same request-and-notification grammar as the JSON-RPC 2.0 spec), session lifecycle, permission request and response flows, and progress and awareness notifications, so a phone client can render what a laptop started. The protocol is organized around URI-identified channels (root, session, and chat at minimum), each holding a reducer-based state object with the server as arbiter; clients send sequenced actions that mutate state or trigger side effects. That choice is what makes reconnection and replay under flaky networks tractable. The AHP specification overview and the session channel spec are worth reading directly.

What the spec does not standardize is the durable state behind the wire. There is no session-state schema. How context persists, where credentials are vaulted, how side effects are tracked: all of that remains an implementation responsibility. That boundary is the most useful thing in the announcement, because it is exactly the line your team has to engineer.

The architecture echoes the Language Server Protocol. LSP decoupled language tooling from editors so any editor could drive any language server; AHP decouples agents from surfaces so any client can drive any agent session. And, like LSP, it stays out of the domain on purpose. GitHub's team notes that the agent world is evolving too quickly to encode how agents work, so AHP standardizes how you interact with them, not what they do.

This also settles the Agent Host Protocol versus MCP question people keep asking. They are complementary. MCP standardizes how an agent reaches tools and data; AHP standardizes how a client reaches and supervises an agent session across hosts and devices. An agent can speak MCP to its tools while a host speaks AHP to its clients, and neither layer needs to know about the other.

Three questions follow, and the rest of this piece answers them: what state must leave your app before sessions can travel, what a roaming session costs to run, and what it costs to secure.

Where session state lives today, and why it is trapped

Model portability is a solved problem. Every serious inference API takes a model name and a context and returns tokens; the capability travels with the account, not the machine. Session state does not. It hides in per-machine places: in-process memory that dies with the window, local dotfiles, terminal scrollback, per-machine tool result caches, environment-specific credential files.

Even the best CLI agents behave this way. Claude Code's resume flag reattaches to a session, but the session lives on the machine that started it, because that is where the transcript and its caches sit. That is simply what happens when nothing forces the state out, and it is the default state of agent session management today.

The scale of the trapped-state problem is visible in GitHub's own numbers. The Copilot Chat extension that bundled its own harness in VS Code had grown past 400,000 lines of TypeScript, by GitHub's account, and its lifetime was tied to a single editor window. Close the window and the agent was gone. Update the editor and every agent stopped. A protocol kills the N-clients-times-M-integrations half of that problem, but only the integration half. The state half is yours.

So separate the two problems the announcement blends. Check-in from anywhere is a UX problem, solved by transport and notifications. A session that hops devices is a state-schema problem, solved by externalizing whatever the transport needs to rehydrate. You can adopt the first. You have to build the second.

The four kinds of state a portable session must externalize

Strip the wire format away and ask what any portable agent session needs, protocol or not. Four categories of state must leave the app that started the session before an agent session handoff across devices or hosts is possible.

State categoryWhat it holdsWhere it must liveFailure if it stays app-local
Externalized contextTranscript, summaries, file references, tool resultsDurable store reachable from any hostSession dies with the process; resume works only on the origin machine
Scoped, expiring credentialsPer-session tokens, refresh path, permission grantsHost-side vault plus a session-bound referenceLong-lived ambient tokens travel with the session as portable loot
Side-effect ledgerIdempotency keys, completion status, affected resourcesAppend-only store the agent consults before actingA resumed agent re-executes writes it already performed
Rebindable tool definitionsTool identity, binding endpoints, permission requirementsDeclarative, host-resolvable registryBindings break, or silently resolve differently, on the new host

The point worth internalizing: this contract is AHP-independent. Any portable session needs these four things whether you adopt the protocol, build your own, or never move state across devices at all and simply want resumable agents after a crash. AHP is one wire format for moving some of it; the contract is the underlying physics of agent state management. Teams that never adopt AHP still benefit from building it, which is why the derivation matters more than the launch.

Designing the side-effect ledger so a resumed agent cannot re-execute

Idempotency keys for agent tool calls record completed writes in an append-only ledger so a resumed agent never re-executes an action like a deploy.

Why resume without a ledger means re-execute

The mechanism is easy to misjudge. After a context gap, a plain context window has no reliable signal separating actions the agent planned from actions the agent completed. The transcript says "deploy to production." The agent wakes up on your phone, reads that plan, and has no record that the deploy already fired. So it fires it again.

Importing the payments fix

The design is a direct import from payments, where the identical double-execution problem was solved years ago. Stripe's idempotency keys exist precisely because networks drop responses after requests succeed: you send a key with each write, the server records the key with the outcome, and a retry returns the recorded outcome instead of a second charge. Agent tool calls are the same shape with a higher blast radius, and idempotency keys for agent tool calls transfer directly.

Walk the failure end to end without the ledger. An agent on your laptop finishes a build, opens a PR, and queues a deploy as its next step. You close the lid. The session syncs to your phone an hour later and you say continue. The resumed agent re-reads its plan, sees deploy pending, and runs it, except the deploy fired before the gap. With a ledger, the pre-action read shows that deploy completed under a known key, and the agent moves to verification instead.

Concretely: make every mutating tool call carry a client-generated idempotency key, append a record (key, tool, argument hash, status, affected resources) before execution, mark it completed or failed after, and on resume, read the ledger before the agent acts. Keep it append-only and tamper-evident, a property that pays off again in the security section.

Scoped, expiring credentials for a session that travels

Ambient credentials are the state category that turns portability into breach velocity. The common pattern in agent setups is a long-lived bearer token sitting in a config file or environment block, valid for weeks, scoped to everything the agent might need. That is tolerable when the session never leaves one machine. When session state travels, the token travels with it, and anything that exfiltrates the session state exfiltrates live access.

The replacement is a per-session design for scoped credentials: short-lived, narrowly scoped access tokens with a refresh path, provisioned when a session starts, bound to that session, and revoked when it ends. The device authorization grant flow fits naturally here, because the typical roaming path is exactly a phone attaching to a session that started elsewhere.

Divide what travels from what stays. The session record carries a reference and the refresh path; the vault holding actual secrets and the capability to mint tokens stays host-side. A leaked session record then yields a revocable reference, not a master key.

What a roaming session costs to run

The dominant run cost of a roaming session is usually operational, not per-token. The bill components, sorted by what drives them:

CostScales withNotes
Durable host uptimeSession durationHosts stay warm for hours or days, idle or not
Context storageSession durationTranscripts and tool results grow monotonically
State re-syncAttach frequencyEvery attach ships current state to the new client
Context replayResume frequencyStateless APIs require re-supplying the context
Lifecycle managementBothTimeouts, orphan cleanup, concurrent mutation

Statelessness is the hidden line item. Inference APIs keep no server-side session, so resuming an agent session on another device means re-supplying its context, every time. OpenAI's prompt caching shows the standard mitigation, cached prefixes that can cut the input cost of repeated context. The caveat is locality: caches are generally not portable across providers, and a host or region hop can bust them, so a session that changes hosts can pay to rebuild context from scratch. Budget for the worst case and treat cache hits as a discount.

Multi-client attach is also a concurrency problem wearing a UX costume. Two devices issuing instructions to one session is a distributed-systems problem: someone must sequence the actions and reconcile conflicts. AHP's reducer-plus-server-arbiter design exists precisely for this, which is a genuine reason to prefer the protocol over a hand-rolled attach mechanism for long-running agent sessions.

What a roaming session costs to secure

Securing roaming agent sessions means treating the traveling session record as sensitive data with live access attached.

A session that travels is an exfiltration target that travels with it. Treat the session record as sensitive data with live capability attached, because that is what securing roaming agent sessions actually means. Four threats and their pairings:

  • Synced context. Transcripts carry secrets, file contents, and internal URLs. Mitigate with redaction at the sync boundary, encryption at rest, and retention limits.
  • Replayable bearer credentials. The fix is the previous section: scoped, short-lived, revocable tokens instead of ambient ones.
  • Confused deputy on rebind. Rebindable tool definitions can resolve differently on a new host; a tool named deploy may bind to a different pipeline with different permissions. Re-verify bindings and permissions at attach time, not just at session start.
  • Attach-channel hijack. When any device can attach, any device-shaped attack is an entry point. Mitigate with device trust and per-attach authorization.

These map onto OWASP's LLM Top 10: sensitive information disclosure for synced context, excessive agency for confused-deputy rebinds, and the identity categories for attach-channel compromise. A roaming session does not create new risk categories. It raises the severity of existing ones by making the target portable.

An adopt, build, or wait rubric for engineering teams

Team archetypeCallRationale
Single-surface CLI, sub-hour tasksBuild the contract, defer the wire protocolUsers work in one place; the four-state contract still pays off for crash resume
Platform team running cloud environmentsAdopt AHP-shaped interfaces nowSessions already outlive surfaces; attach, notify, and permission flows are your roadmap anyway
Multi-vendor enterpriseAdopt for interoperabilityClient choice and host choice are the point; GitHub lists libraries in Rust, TypeScript, Kotlin, Swift, .NET, and Go

The failure modes of deferring each state category are the honest cost of waiting:

  • Context stays local. Sessions are unrecoverable after a crash, there is no cross-device story, and debugging depends on one machine.
  • Credentials stay ambient. Every incident involving the dev box becomes an incident involving every session it ever ran.
  • No ledger. The double-execution failure is a when, not an if, and it lands on writes with consequences: deploys, PRs, purchases.
  • Hard-coded bindings. Host changes break silently, or worse, resolve to the wrong target.

The minimal moves pay off even if you never adopt AHP: make mutating tools idempotent, externalize context to a durable store, and replace ambient tokens with scoped ones. Those three buy crash resume, incident containment, and double-execution immunity with no protocol required. The Agent Host Protocol decision then reduces to what it always was: whether your users' sessions are worth a standard wire format this quarter, or whether the state work, which you have to do anyway, buys you time to wait.

Stay in the loop.

Get the latest posts and exclusive content delivered to your inbox.

Join 15 readers. No spam. Unsubscribe in one click, anytime.

About the author

Rachel Brennan

AI Research Editor

Rachel tracks AI research so the rest of us don't have to. With a background in NLP and a habit of reproducing papers, she turns new models and methods into ideas you can actually use.

Related Posts