Raw capture โ€” raw/agent-host-protocol.md


url: https://microsoft.github.io/agent-host-protocol/ title: Agent Host Protocol (AHP) author: Microsoft date_fetched: 2026-07-25 date_published: 2026


Agent Host Protocol

AHP is a portable, standalone server protocol that gives multiple clients a synchronized view of AI agent sessions. It achieves this through immutable state, pure reducers, and write-ahead reconciliation. Released under the MIT License, Copyright ยฉ 2026 Microsoft.

Problem

An agent session is traditionally bound to a single application. "The conversation, the turns, the pending tool approvals โ€” they're tied to a single app or harness." AHP transforms a session into a shared resource, allowing it to "live once and be driven from anywhere."

Architecture

AHP follows the lineage of LSP (Language Server Protocol) and DAP (Debug Adapter Protocol). A single Agent Host sits between multiple clients and multiple agents. The host holds "authoritative session state ยท sequencing ยท reconciliation." Clients communicate via AHP; agent backends integrate directly.

Four client types (IDE, Web, CLI, Mobile) and four agent backends (Copilot, Claude, Codex, ACP).

Key Concepts

  1. Synchronized multi-client state โ€” Any number of clients can attach to a single session at once.
  2. Total ordering via monotonic sequence โ€” The host stamps each mutation with a monotonic sequence and broadcasts it to every subscribed client.
  3. Envelope-based messaging โ€” Every change is one envelope, totally ordered.
  4. Optimistic apply + reconcile โ€” Client applies its own action locally immediately, then cross-references the server's echo (stamped with an origin field) back to its optimistic copy.

Wire Protocol

Channel Model

Channel URI Pattern Content
Root ahp-root:// Agents catalog, terminals catalog, host config, session catalogue events
Session ahp-session:/<uuid> Per-session state, chats catalog, active clients, customizations
Chat ahp-chat:/<cid> Per-chat conversation, turns, streaming, tool calls
Terminal per-terminal PTY state, data flow, claims, command detection
Telemetry ahp-otlp: OpenTelemetry logs, traces, metrics
Resource Watch separate File/resource change watching

Message Categories

State Model

Each state-bearing channel maintains an immutable, Redux-style state tree changed only by actions flowing through pure reducers. Subscriptions return snapshots with resource, state, and fromSeq. Subsequent action envelopes incrementally update the state.

Actions โ€” "Discriminated union of typed mutations. The sole mechanism for state change." Delivered inside ActionEnvelopes with channel, action, serverSeq, origin.

Reducers โ€” "Pure functions: (state, action) โ†’ newState. Run identically on server and client."

Design Decisions

Status

DRAFT โ€” "Breaking changes to wire types, actions, and state shapes are expected." No backward compatibility until production status.