What is AHP?
The Agent Host Protocol lets several clients attach to one agent session and see the same thing.
Start a conversation with a coding agent in your editor, and the session lives in the editor’s process. Close it and the session goes with it. AHP moves the session into a standalone host that clients connect to, so the same conversation is reachable from a second window, a second machine, or a phone — with history, pending approvals, and in-flight turns intact.
VS Code ships the reference host. It runs coding agents independently of the editor and speaks AHP to whatever attaches:
code agent host --port 51234 --without-connection-tokenHow state gets to you
Section titled “How state gets to you”Clients do not poll, and they do not receive state. They receive actions, and derive state by running the same reducers the host runs.
flowchart LR H[Agent host] -->|ordered actions| A[Client A] H -->|ordered actions| B[Client B] A --> RA[reducers] --> SA[(state)] B --> RB[reducers] --> SB[(state)]
Two clients converge because they apply identical transformations to the same ordered stream. That is why this package hand-ports the reducers rather than inventing its own: they have to match the host’s behaviour exactly, and they are verified against the same fixtures every other AHP client uses.
Three ideas
Section titled “Three ideas”Channels. Every resource is a URI you subscribe to — the root catalogue, a session, a chat, a terminal. Every message carries its channel, so routing never needs to understand the payload.
Reducers.
Pure functions from (state, action) to state.
No side effects, no clock reads except one carefully injected seam.
Reconciliation. Your own actions apply locally before the server sees them, then reconcile against its authoritative echo. That is what makes typing feel instant while keeping the server the source of truth.
What this client is not
Section titled “What this client is not”It is not a host. It speaks the client half of the protocol; nothing here runs an agent or owns authoritative state.
It also does not wrap an agent runtime. AHP is agent-agnostic — a host typically delegates to an ACP-compatible backend, and the spec describes AHP as “a mutex over ACP”: it serialises a one-to-one agent conversation so many clients can watch and take turns without conflict.