Skip to content

Host-to-Agent Protocol (H2A)

Status: Draft

Version: 0.11.0

Last Updated: 2026-11-29

1. Overview

The Host-to-Agent Protocol (H2A) defines an interoperability protocol for interaction between host applications and agents.

In the H2A model, each addressable agent is exposed as a runtime endpoint and has an associated client used to communicate with it. A host keeps track of the available clients and uses them to interact with one or more agents on behalf of user applications.

The protocol semantics are defined independently of any specific transport. This document defines one binding: HTTP plus Server-Sent Events (SSE) for the per-agent endpoint.

H2A assumes a user-facing application interacts with a host, and the host acts as the bridge to one or more agents. H2A therefore standardizes the host-to-client and client-to-agent lifecycle that user-facing hosts depend on, rather than agent internals or tool interoperability.

2. Goals, Non-Goals, And Positioning

2.1 Goals

  • Define a deterministic host-to-agent request lifecycle.
  • Define canonical request and event envelopes.
  • Allow multiple transport bindings while preserving one protocol core.
  • Support host-managed deployments that expose one or more agents behind one host.
  • Leave room for future extensions without making them part of the core topology.

2.2 Non-Goals

  • H2A does not standardize an agent reasoning model.
  • H2A does not standardize model-provider APIs.
  • H2A does not standardize tool invocation protocols or external context access.
  • H2A does not require peer-to-peer agent meshes.
  • H2A does not define a universal UI protocol.

2.3 Positioning

H2A is complementary to MCP. MCP is primarily concerned with tool, resource, and context interoperability between AI applications and external systems. H2A is concerned with host-to-agent execution, lifecycle, and transport semantics.

H2A is adjacent to agent-to-agent protocols such as A2A. H2A is host-to-agent first. Agent-to-agent delegation MAY be layered on top of H2A in future revisions, but that is not the primary v1 topology.

3. Architecture And Conformance

3.1 Roles

H2A defines the following roles:

  • User Application: a UI, client, automation, or orchestration surface that talks to a host.
  • Host: the protocol participant that exposes H2A operations, manages sessions, and brokers access to one or more agents.
  • Client: a protocol-facing component associated with one agent and used by a host to invoke that agent over an H2A binding.
  • Agent: an execution target selected by a host and exposed as an addressable runtime endpoint.

3.2 Topology

H2A is host-centric in v1:

  • A host MAY expose one agent or many agents.
  • A user application SHOULD address the host, not agents directly.
  • A host MUST expose stable agent_id values for addressable agents.
  • Each addressable agent MUST have an associated client.
  • A host MUST be able to resolve agent_id to the associated client.
  • A host-facing client MUST target exactly one agent at a time.
  • Agent-to-agent relationships are out of core scope.

In a typical deployment:

  • an agent is exposed over its own HTTP plus SSE server
  • a client communicates with exactly one agent endpoint
  • the host tracks the set of available clients and selects the appropriate client for a requested agent_id

Illustrative runtime topology:

flowchart TD
    U["User application<br/>(web · service · app)"] --> H["Host<br/>(Deployable service)"]
    H --> R["Agent Registry"]
    R --> C1["Client for <br/>Agent A"]
    R --> C2["Client for <br/>Agent B"]
    C1 --> A1["Agent A runtime"]
    C2 --> A2["Agent B runtime"]
    A1 --> E1["Agent A loop"]
    A2 --> E2["Agent B loop"]

3.3 Conformance

An implementation claiming H2A conformance MUST implement the H2A request flow defined by this specification and the HTTP plus SSE binding.

H2A conformance is defined in terms of hosts, agents, clients, and protocol behavior rather than a deployment boundary.

4. Protocol Structure

At a high level, H2A standardizes three communication standards:

  • User Application -> Host
  • Host -> Client
  • Client -> Agent

4.1 User Application To Host

The user application talks to a host that accepts events (messages posted to a session), exposes each event's streamed request events, delivers interaction responses, and cancels events. Section 10 defines the HTTP binding for this layer.

4.2 Host To Client

The host resolves agent_id to the associated client and uses that client to create requests, consume request streams, deliver interaction responses, and control requests for one agent.

4.3 Client To Agent

The client reaches one agent runtime through its per-agent HTTP plus SSE server (section 8).

5. Lifecycle

H2A request flow proceeds through the three communication standards in sequence.

5.1 User Application To Host

The user application posts work to the host as an event in a session (section 10.2). The session's id is part of the route, POST /sessions/{session_id}/events, and the user application chooses it: a new id starts a session, and an existing one continues it.

An event includes:

  • session_id: the session it belongs to, from the route
  • event_id: unique in its session; posting the same event_id again returns the stored event
  • app_id and policy_id (section 6.6)
  • message
  • optional context, metadata and structured_output, passed on to the request

A session's first event binds it to that event's policy_id. The host stores the event, returns the id of the request it runs as, and runs a session's events one at a time. Each runs as a request on the host's companion, which routes it to one of the host's member agents or workflows (section 10.3).

The user application consumes the event's lifecycle from the host through the event's stream, answers its interactions and cancels it, all addressed by session_id and event_id.

5.2 Host To Client

The host resolves the companion's client and submits the event's request with:

  • message
  • session_id: the event's session
  • request_id: derived from the session and event ids, so a host that restarts resubmits the same request
  • app_id, policy_id and the policy's snapshot
  • optional context, structured_output and metadata

When the companion routes the message to an agent, it submits that agent's request in the same session with a conversation parent (section 6.1). In a host whose agents run in separate processes it does so through the agent relay (section 10.5). The host follows the companion's request, then the routed request, and relays both to the event's stream.

5.3 Client To Agent

The client turns the host request into one request for exactly one agent runtime.

session_id MUST be a non-empty string. The runtime does not assign a default session. The runtime records a request.accepted event and starts execution, then returns the accepted payload containing request_id, agent_id, session_id, and status.

Requests that share a session_id are not serialized. Each accepted request starts executing immediately as its own durable execution.

5.4 Agent Execution And Streaming

After acceptance, the runtime executes the request and records its lifecycle as an ordered, durable event sequence. Each stored event is named after the OpenTelemetry span it opens or closes (section 6.4). The agent server publishes each one under a frame name, the client consumes those frames, and the host relays them back to the user application.

Illustrative request flow:

sequenceDiagram
    participant App as User Application
    participant Host
    participant Companion as Companion runtime
    participant Agent as Routed agent runtime
    participant Store as Event Store

    App->>Host: POST /sessions/{session_id}/events {event_id, app_id, policy_id, message, ...}
    Host-->>App: 202 {session_id, event_id, request_id, status: queued}
    App->>Host: GET /sessions/{session_id}/events/{event_id}/stream
    Host->>Companion: post_request(message, session_id, request_id)
    Companion->>Store: invoke_agent.start / mash.context_load.* / chat.end (route)
    Companion->>Agent: post_request(message, session_id, parent: conversation)
    Companion->>Store: invoke_agent.end (routed)
    Agent->>Store: invoke_agent.start / chat.* / execute_tool.* / invoke_agent.end
    Store-->>Host: the companion's frames, then the routed request's
    Host-->>App: SSE request.started / agent.trace / request.completed

5.5 Completion And Retention

An execution attempt ends with one terminal event: request.completed, request.error, or request.cancelled.

Events are stored durably and are not discarded after completion. A stream opened at any time, including after the request has finished, replays the request's events from the first one.

6. Host To Client Interaction

This section defines the second communication standard: Host -> Client.

At this layer, H2A centers interaction on three operations:

  • post_request
  • stream_response
  • post_interaction

These three operations are sufficient for a host to submit work to one agent, observe the resulting lifecycle until completion, and answer interactions along the way. Section 6.5 lists the control operations a client also provides.

6.1 post_request

post_request creates one asynchronous request for one agent.

Inputs:

  • message: string
  • session_id: string
  • app_id: string: the application the request acts for. Like metadata, it is stored with the request and never shown to the model
  • policy_id: string: the policy the request runs under
  • policy: object: a snapshot of that policy (sandbox, browser_sites, wait_max_seconds), taken when the request is started (section 6.6)
  • optional structured_output: object: a JSON schema the final response must satisfy
  • optional metadata: object: opaque caller context stored with the request and readable by tools; it is never shown to the model
  • optional request_id: string: the id to give the request, so a caller that retries submission reaches the same request
  • optional context: string: prompt text added to the request
  • optional parent: object: the request or workflow step that issued this request

parent has one of two shapes:

{"kind": "conversation", "request_id": "req_1", "agent_id": "companion",
 "session_id": "s-1", "started_by": "companion", "parent_request_id": "req_1",
 "route": {"choice": "research", "picked_by": "classifier"}}
{"kind": "workflow", "workflow_id": "changelog", "run_id": "run_9",
 "task_id": "summarize"}

A conversation parent names the companion request that routed a user's message to this agent; the request runs in that request's session, reads the session's entries, and records route in its own entry. started_by MUST equal agent_id and parent_request_id MUST equal request_id; the runtime records them as the request's started_by and parent_request_id. A workflow parent names the workflow, run and step, and its ids are recorded on every event of the request. A request with neither reads no earlier turns: its context is its system prompt and message.

Rules:

  • message MUST be present and MUST be a non-empty string.
  • session_id MUST be present and MUST be a non-empty string.
  • request_id, when present, MUST be 1 to 255 characters of letters, digits, ., _, : or -.
  • app_id and policy_id MUST be present and MUST each be 1 to 255 characters of letters, digits, ., _, :, @ or -. policy MUST be present and MUST be a policy object.
  • A request with a conversation parent MUST carry the parent request's app_id, policy_id and policy. A host relay enforces this (section 10.5).
  • A request with a workflow parent MUST carry the workflow run's app_id, policy_id and policy snapshot.
  • A session's requests MUST share one policy_id. A request for a session that already has a request under another policy is rejected with 409 SESSION_POLICY_MISMATCH.
  • Requests that share a session_id MUST be accepted. The runtime does not wait for an earlier request in the same session to finish; a host that wants one at a time queues them (section 10.2).

The accepted payload contains:

  • request_id: string
  • agent_id: string
  • session_id: string
  • status: "accepted"
  • app_id: string
  • policy_id: string

Example:

{
  "message": "Plan the next release.",
  "session_id": "sess_123",
  "app_id": "slack-bot",
  "policy_id": "acme-ws",
  "policy": {"sandbox": true, "browser_sites": null, "wait_max_seconds": 86400}
}

Accepted payload:

{
  "request_id": "req_123",
  "agent_id": "planner",
  "session_id": "sess_123",
  "status": "accepted",
  "app_id": "slack-bot",
  "policy_id": "acme-ws"
}

6.2 stream_response

stream_response consumes the event stream for one previously accepted request.

Inputs:

  • request_id: string
  • optional after: integer: the sequence number of the last event the caller has; 0 by default

Rules:

  • The stream MUST start with the first event after after, which is the request's first event when after is 0.
  • The client MUST yield events in the order they were recorded, each with its sequence number, so a caller whose stream broke reads on with after.
  • Each event MUST have a name and a JSON object payload.
  • The stream ends once the client has yielded a terminal event: request.completed, request.error, or request.cancelled.

Example SSE frame:

event: request.started
data: {"request_id":"req_123","agent_id":"planner","session_id":"sess_123","status":"started"}

6.3 post_interaction

post_interaction delivers a user response to a request that is waiting on an interaction.

Inputs:

  • request_id: string
  • interaction_id: string
  • response: any

Rules:

  • interaction_id MUST be a non-empty string.
  • The response is recorded as the interaction's answer, which the agent publishes as request.interaction.ack, and the waiting execution continues with it.
  • An interaction takes one answer: the user's response, the timeout default (section 7.5), or the cancel ack (section 7.7), whichever is recorded first. A response for an interaction that already has one is rejected with 409 INTERACTION_CLOSED, and one for an interaction the request never opened with 404 INTERACTION_NOT_FOUND.

The result is a JSON object containing:

  • ok: true
  • interaction_id: string

Example:

{
  "interaction_id": "itr_abc123",
  "response": "approve"
}

6.4 Event Contract

Every recorded runtime event is published under one of these names:

Event Terminal Meaning
request.accepted No The request was recorded, its trace_id was assigned, and execution was started
request.started No Execution began loading the request's context
agent.trace No Any other recorded event: context loaded, a model call starting, streaming or ending, a tool call starting or ending, a step completed
request.interaction.create No Execution is waiting for a response (section 7)
request.interaction.ack No The waiting execution received a response, timed out, or was cancelled
request.completed Yes The request finished and its turn was saved
request.error Yes The request failed
request.cancelled Yes The request was cancelled

Rules:

  • request.accepted MUST be the first event for a request.
  • request.started MUST be emitted before any agent.trace or terminal event.
  • request.interaction.create MUST be followed by exactly one request.interaction.ack with the same interaction_id.
  • request.interaction.create and request.interaction.ack MAY appear zero or more times between request.started and the terminal event.
  • A request MUST end with exactly one terminal event. A cancelled or failed request stays ended.

Stored events are named after the OpenTelemetry span they open or close, and the agent maps each to a frame:

Stored event Frame
invoke_agent.start request.accepted
mash.context_load.start request.started
mash.interaction.start request.interaction.create
mash.interaction.end request.interaction.ack
invoke_agent.end request.completed, request.error or request.cancelled, by its status
mash.context_load.end, chat.start, chat.delta, chat.end, execute_tool.start, execute_tool.end, mash.step.end agent.trace

Every .end event carries status: "ok", "error" or "cancelled". OpenTelemetry attributes, such as gen_ai.request.model, gen_ai.usage.input_tokens and gen_ai.tool.name, are under attributes in the payload.

Payloads:

  • request.accepted, request.started: request_id, agent_id, session_id, status ("accepted" or "started").
  • agent.trace: event_type (the stored event, such as execute_tool.end), trace_id, session_id, loop_index, step_key, created_at, and payload.
  • request.completed: the invoke_agent.end payload: request_id, agent_id, session_id, status: "ok", trace_id, attributes, and the saved turn, including response with text, signals, and metadata, plus structured_output when one was requested.
  • request.error: request_id, agent_id, session_id, status: "error", attributes, error, and when known error_type, error_code, retryable, and stop_reason.
  • request.cancelled: request_id, agent_id, session_id, status: "cancelled", attributes.

Transient errors (rate limits, timeouts, network errors, provider overload) in model calls and tool calls are retried automatically at the step level before request.error is emitted. retryable reports the original classification of the error that ended the request.

6.5 Client Contract

For one addressable agent:

  • one client MUST target exactly one agent_id
  • one client MUST use exactly one base URL for that agent
  • post_request, stream_response, and post_interaction together form the asynchronous request contract

A client also provides these operations:

  • get_request_status: report the execution state of a request (section 10.4)
  • cancel_request: stop a running request
  • describe: list the agent's tools and skills (section 8.7)
  • compact_session: write a conversation's board summary; only the companion compacts (section 8.8)

Request submission is idempotent on request_id. When post_request names a request_id that already belongs to a request of the same agent, the runtime returns that request's accepted payload and does not start a new execution. Its stream then replays from the first event. A request_id that belongs to another agent is rejected. Without request_id, every submission creates a new request.

6.6 Request Identity

Every request carries an app_id, a policy_id and a policy snapshot. The app scopes memory: an agent's conversation search reaches the request's session or every session of its app, and app-level memory is keyed by app_id. The policy owns the resources the request's tools act in (in the reference host, a sandbox and a browser profile) and sets three rules the runtime applies from the snapshot:

  • sandbox: false removes the sandbox tools from the request's tool list.
  • browser_sites, when a list, is intersected with the agent's own browser sites; an empty intersection removes the browser tools.
  • wait_max_seconds caps every interaction's timeout (section 7.5); null sets no cap.

The snapshot is taken once, when the request starts, so changing the policy does not affect running requests.

7. Interactions

An interaction is a mid-execution pause where the agent requests information or approval from the host before continuing. Interactions enable human-in-the-loop workflows without breaking the streaming event model.

7.1 Interaction Types

H2A defines four interaction types:

Type Schema Description
approval { "type": "enum", "options": ["approve", "deny", "skip"] } Request permission before running tools that require approval
info { "type": "text" } Request free-form text input from the user
choice { "type": "multi_select", "options": [...] } Request one or more selections from a set of options
browser { "type": "enum", "options": ["done", "cancel"] } Hand a browser to a person to sign in; the payload carries no link, and the host mints one on request (section 10.2)

An approval interaction covers every tool call the agent planned in that step. A response of "deny" or "skip" denies all of them, and each call returns an error result to the agent in place of running.

7.2 request.interaction.create

Emitted when execution starts waiting for a response.

event: request.interaction.create
data: {"request_id":"req_123","agent_id":"planner","session_id":"sess_123","interaction_id":"itr_abc123","type":"approval","prompt":"Approve execution of: deploy?","schema":{"type":"enum","options":["approve","deny","skip"]},"timeout_seconds":300}

Fields:

  • request_id: string: the parent request
  • agent_id: string: the agent requesting interaction
  • session_id: string: current session
  • interaction_id: string: unique identifier for this interaction
  • type: string: one of approval, info, choice, browser
  • prompt: string: human-readable question or description
  • schema: object: describes the expected response shape
  • timeout_seconds: number | null: how long execution will wait; null for an interaction with no deadline

7.3 request.interaction.ack

Emitted after the waiting execution receives a response, times out, or is cancelled.

event: request.interaction.ack
data: {"request_id":"req_123","agent_id":"planner","session_id":"sess_123","interaction_id":"itr_abc123","response":"approve"}

Fields:

  • request_id: string
  • agent_id: string
  • session_id: string
  • interaction_id: string: matches the originating request.interaction.create
  • response: any: the user's response (string for approval and info, array for choice), the default on timeout, or null on cancel
  • timed_out: true (optional): present when no response arrived in time and response is the default
  • cancelled: true (optional): present when the request was cancelled while waiting

7.4 Interaction Flow

sequenceDiagram
    participant Host
    participant Client as Agent Client
    participant Agent as Agent Runtime

    Agent-->>Client: request.interaction.create
    Client-->>Host: request.interaction.create event
    Host->>Host: Present interaction to user
    Host->>Client: post_interaction(request_id, interaction_id, response)
    Client->>Agent: POST interaction {interaction_id, response}
    Agent->>Agent: record the answer, wake the waiting execution
    Agent-->>Client: ok
    Agent-->>Client: request.interaction.ack
    Client-->>Host: request.interaction.ack event
    Note over Agent: Execution resumes

7.5 Timeout Behavior

An interaction's timeout is its type's timeout capped by the request policy's wait_max_seconds. A browser interaction has no timeout of its own: its timeout is the cap, and with no cap it waits until answered or cancelled.

If no response arrives within timeout_seconds:

  • Execution continues with the default response for the type: "deny" for approval, "" for info, [] for choice, "cancel" for browser.
  • The agent MUST emit request.interaction.ack carrying the default response and timed_out: true.

7.6 Durability

Interaction waiting MUST be durable. If the agent runtime restarts while waiting, it MUST resume waiting for the same interaction_id without re-emitting request.interaction.create. A response delivered before waiting resumes MUST be received once it does. This enables interactions that span hours or days.

7.7 Cancellation

If a request is cancelled while waiting on an interaction, the agent MUST emit request.interaction.ack for that interaction with response: null and cancelled: true, followed by request.cancelled.

8. Client To Agent HTTP Server

This section defines the HTTP plus SSE binding for the third communication standard: Client -> Agent.

Each agent is exposed by one HTTP server that handles health checks, request creation, request event streaming, and interaction delivery.

8.1 Endpoint Shape

The HTTP plus SSE binding defines these endpoints for one agent:

  • GET /health
  • GET /agent/{agent_id}/describe
  • POST /agent/{agent_id}/session/{session_id}/compact
  • POST /agent/{agent_id}/request
  • GET /agent/{agent_id}/request/{request_id}
  • POST /agent/{agent_id}/request/{request_id}/interaction
  • GET /agent/{agent_id}/request/{request_id}/status
  • POST /agent/{agent_id}/request/{request_id}/cancel

Equivalent route shapes are permitted if they preserve the same semantics.

8.2 POST Request Handling

For POST /agent/{agent_id}/request, the server MUST:

  1. return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves
  2. read the request body as JSON, returning 400 INVALID_JSON if it does not parse
  3. return 400 INVALID_REQUEST for a non-object body
  4. validate that message is a non-empty string, returning 400 INVALID_REQUEST otherwise
  5. validate that session_id is a non-empty string, returning 400 INVALID_REQUEST otherwise
  6. if structured_output is present, validate it as a JSON schema object, returning 400 INVALID_STRUCTURED_OUTPUT otherwise
  7. if metadata is present, validate that it is an object, returning 400 INVALID_REQUEST otherwise
  8. if context is present, validate that it is a string, and if host is present, validate that it is an object, returning 400 INVALID_REQUEST otherwise
  9. if parent is present, validate it against the shapes in section 6.1, returning 400 INVALID_PARENT otherwise
  10. validate that app_id, policy_id and policy are present and well formed (section 6.1), returning 400 INVALID_REQUEST otherwise
  11. if request_id is present, validate it (section 6.1), returning 400 INVALID_REQUEST otherwise. If it belongs to a request of this agent, return 200 OK with that request's accepted payload. If it belongs to another agent, return 409 REQUEST_ID_CONFLICT
  12. return 409 SESSION_POLICY_MISMATCH if the session already has a request under another policy_id
  13. call the runtime request-submission operation with message, session_id, structured_output, metadata, request_id, context, host, parent, app_id, policy_id and policy
  14. return 202 Accepted with the accepted payload as the body

Example error:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "message is required"
  }
}

8.3 GET Stream Handling

For GET /agent/{agent_id}/request/{request_id}, the server MUST:

  1. return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves
  2. return 404 REQUEST_NOT_FOUND for an unknown request_id, or one accepted for another agent
  3. read optional after from the query, returning 400 INVALID_REQUEST when it is not an integer
  4. respond 200 OK with Content-Type: text/event-stream
  5. read the request's events in order, starting after the event whose sequence number is after (from the first event when it is 0 or absent), writing each as one SSE frame with id: (the event's sequence number), event: and data: lines
  6. stop once the runtime reports the request terminal and the terminal event has been written, or the client disconnects

When no new events arrive for 15 seconds and the request is not terminal, the server writes an SSE keep-alive comment (: keep-alive).

8.4 POST Interaction Handling

For POST /agent/{agent_id}/request/{request_id}/interaction, the server MUST:

  1. return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves
  2. return 404 REQUEST_NOT_FOUND for an unknown request_id, or one accepted for another agent
  3. read the request body as JSON, returning 400 INVALID_JSON or 400 INVALID_REQUEST for a body that does not parse or is not an object
  4. validate that interaction_id is a non-empty string, returning 400 INVALID_REQUEST otherwise
  5. return 404 INTERACTION_NOT_FOUND if the request never opened interaction_id
  6. record response as the interaction's answer, returning 409 INTERACTION_CLOSED if it already has one (section 6.3), and wake the waiting execution
  7. return 200 OK with {"ok": true, "interaction_id": ...}

8.5 Request Control Handling

For the status and cancel routes, the server MUST:

  1. return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves
  2. return 404 REQUEST_NOT_FOUND if the runtime does not know the request, or it was accepted for another agent, without running the operation
  3. call the runtime's corresponding operation for request_id
  4. return 200 OK with the operation's result as the body, without the host's {data} envelope

status returns request_id and the request's recorded state: running, completed, failed or cancelled. cancel stops a running request at its next step boundary (section 7.7) and appends request.cancelled; a request already terminal is left unchanged. A cancelled or failed request stays ended.

8.6 Authentication

A server MAY be configured with a bearer token. When it is, every route except GET /health MUST require Authorization: Bearer <token> and return 401 UNAUTHORIZED when the header is missing or does not match. The client sends the token on every call.

8.7 Describe Handling

For GET /agent/{agent_id}/describe, the server MUST return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves, and otherwise 200 OK with:

  • agent_id: string
  • tools: one object per registered tool with name, description, parameters, requires_approval, and parallel_safe
  • skills: one object per registered skill with name, description, type, and content

8.8 Session Compaction Handling

For POST /agent/{agent_id}/session/{session_id}/compact, the server MUST:

  1. return 404 ROUTE_NOT_FOUND if agent_id is not the agent it serves
  2. read the body as JSON, returning 400 INVALID_JSON or 400 INVALID_REQUEST for a body that does not parse or is not an object
  3. validate optional reason as a non-empty string (default "manual"), returning 400 INVALID_REQUEST otherwise
  4. return 400 INVALID_REQUEST when the agent keeps no history to compact. Only the companion compacts: its session is a conversation, and compaction writes the board's summary entry
  5. return 200 OK with summary_text and trace_id, each empty when the board has no entries since its last summary

8.9 Runtime Requirements Behind The Server

The runtime attached to one agent HTTP server MUST provide:

  • request submission
  • lookup of an existing request's accepted payload by request_id
  • request existence checks
  • ordered event reads for one request, from a cursor, together with whether the request is terminal

Reading new events and terminality in one operation guarantees that a server which stops on terminality has already written the terminal event.

The runtime execution model MAY vary internally. The reference behavior is:

  • every accepted request starts a durable execution immediately
  • requests that share a session_id run concurrently; they are not serialized
  • each step of the execution records its output as events, so a runtime restart rebuilds the request's state from them and runs only the work with no recorded end; a request that does not finish after repeated restarts ends with request.error and error_type: "recovery_limit"

9. Per-Agent HTTP Binding

H2A is per-agent at the HTTP transport boundary.

  • Each agent MUST have its own HTTP server instance or an equivalent per-agent endpoint surface.
  • Each server instance MUST bind exactly one runtime and exactly one agent_id.
  • A host with multiple agents MUST maintain one client per agent server.
  • Separate processes or containers are not required by the protocol.

A Mash host runs each agent's server as a subprocess on a localhost port and keeps one client per agent.

When an agent runtime starts its HTTP server, it MUST bind a host and port, associate the server with exactly one agent_id, and provide a base URL that clients use for post_request, stream_response, and post_interaction.

The resulting interaction model is:

  1. the host resolves agent_id to the associated client
  2. the client calls post_request
  3. the per-agent HTTP server accepts the request
  4. the client calls stream_response
  5. the per-agent HTTP server streams the lifecycle for that request
  6. if request.interaction.create is received, the client calls post_interaction
  7. the per-agent HTTP server delivers the response and execution resumes

10. User Application To Host HTTP Binding

This section defines the HTTP binding for the first communication standard. Routes are relative to the host's API prefix (/api/v1 by default).

10.1 Envelope

Successful responses wrap the result in {"data": ...}. Errors return:

{
  "error": {
    "code": "REQUEST_NOT_FOUND",
    "message": "...",
    "details": {}
  }
}

A body that fails schema validation returns 422 VALIDATION_ERROR with the validation errors in details. A missing or blank required field, or an unknown one, returns 400 INVALID_REQUEST.

10.2 Events

Every input to a host is an event in a session. The user application names the session in the route. A session is created by its first event and bound to that event's policy_id. The host runs a session's events one at a time, in arrival order, each as one request on the companion (section 10.3); the rest wait. When the event's request ends, or the request the companion routed it to, the host records its response or error on the event.

  • POST /sessions/{session_id}/events: body {event_id, app_id, policy_id, message, context?, metadata?, structured_output?}. Returns 202 with the event: {"data": {"session_id", "event_id", "request_id", "seq", "status", ...}}. request_id is derived from the session and event ids, so it is known while the event waits. An event_id the session already has returns 200 with that event and runs nothing. An unknown policy returns 404 POLICY_NOT_FOUND, and a session bound to another policy returns 409 SESSION_POLICY_MISMATCH.
  • POST /sessions/{session_id}/events with body {event_id, interaction_id, response} answers an interaction of the event's request (section 6.3). Returns 200, 404 INTERACTION_NOT_FOUND for an interaction the request has not opened, 400 INVALID_INTERACTION_RESPONSE for a response its schema does not allow, and 409 INTERACTION_CLOSED for one closed by another answer, a timeout or a cancel. Repeating the stored answer returns 200.
  • GET /sessions/{session_id}/events/{event_id}/stream?after=: the SSE stream of the event's request (section 6.2). Each frame's id: is its sequence number, and after resumes after it. The companion's frames come first; when it routed the message, its terminal frame is left out and the routed request's frames follow, numbered on from the companion's, so one after covers both. While the event waits, the stream holds with an event.queued frame. An event cancelled before it started gets one event.cancelled frame. The host closes the stream after writing request.completed, request.error, request.cancelled or event.cancelled.
  • GET /sessions/{session_id}/events/{event_id}: the event's status (queued, running, waiting, completed, failed or cancelled), its request's open interactions, response and error.
  • GET /sessions/{session_id}/events and GET /events: the events of a session, or of every session, in arrival order.
  • POST /sessions/{session_id}/events/{event_id}/interactions/{interaction_id}/handoff: for an open browser interaction, mints a short-lived link to the browser and returns {url, expires_at}.

The host is the trust boundary for app_id and policy_id: the user application authenticates to the host and asserts them, and the host passes them, with the policy's snapshot, to the companion. The relay copies them from the companion's request onto the request it routes (section 10.5).

10.3 Host Members

A host serves one set of member agents and workflows, fixed by its deploy, and GET /host returns them. Every event's request runs on the companion, which routes among them. A host MAY register agents and workflows that are not members, such as built-in ones; the companion never routes to those.

A host MAY record an id of its own on the sessions, events and requests it writes, for instance one per boot. The user application never sends it, and the host checks no event against it.

The companion reads the conversation's board and classifies the message with one structured output call whose only field is an enum of the member agent ids, the member workflow ids, about and unclear. Then it:

  • for an agent: submits that agent's request in the event's session, with a conversation parent and a request id derived from its own, and ends. The routed request reads the board and writes its entry. The event's response is the routed request's.
  • for a workflow: fills the workflow's input with a second structured output call, asks the user for each required field it could not fill (an info interaction), runs the workflow and waits for it, writes one board entry with the outcome, and ends with it as its reply.
  • for about: replies with the members' descriptions, with no model call.
  • for unclear: asks the user to pick an agent (a choice interaction), then routes to it.

10.4 Request Control

  • GET /agent/{agent_id}/request/{request_id}/status returns request_id and status, the request's recorded lifecycle state: running, completed, failed or cancelled. A request the runtime does not know returns 404 REQUEST_NOT_FOUND. This is useful when a stream goes silent after a process crash: running means the request continues once the agent's runtime restarts.
  • GET /agent/{agent_id}/request/{request_id}/events?after=: the SSE stream of one request on its own, such as the one the companion routed.
  • POST /sessions/{session_id}/events/{event_id}/cancel cancels an event. A waiting event is cancelled before it starts. A running event's request stops at its next step boundary. The step in flight finishes and is recorded. If the request is waiting on an interaction, that interaction is acked with response: null (section 7.7). The runtime then appends request.cancelled, and the host cancels the request the companion routed the event to through its own agent; one whose agent is disabled is skipped. An event that has ended returns 409 EVENT_TERMINAL.

10.5 Agent Relay

A host whose agents run in separate processes MAY expose a relay that the companion uses to start the request it routes a message to, and to start and read the workflow runs it routes to. The relay speaks the client-to-agent binding of section 8 under its own prefix (/h2a in the reference host), so an agent calls it with an ordinary H2A client.

  • Each agent authenticates with its own bearer token. The relay returns 401 UNAUTHORIZED for a token that matches no agent.
  • POST /agent/{agent_id}/request MUST carry a parent of kind conversation whose agent_id is the caller, and the caller MUST be the companion. Its session_id MUST be the parent request's session. Otherwise the relay returns 403 FORBIDDEN.
  • The relay looks up the parent request. A parent request it does not know returns 400 INVALID_PARENT, and one that belongs to another agent returns 403 FORBIDDEN.
  • agent_id MUST be one of the host's member agents. Otherwise the relay returns 403 FORBIDDEN. The relay reads the members from the host, never from the body, so an agent cannot reach past them.
  • The relay sets the forwarded request's app_id, policy_id and policy to the parent request's. A value in the body that differs from the parent's returns 403 FORBIDDEN. The companion cannot act for another app or under another policy through the requests it routes.
  • An allowed request is forwarded to the agent's client. A 409 SESSION_POLICY_MISMATCH from the agent is returned as is.
  • POST /workflow/{workflow_id}/run with body {parent: {request_id}, input, dedup_key?} starts a workflow run for the companion's request. The workflow MUST be one of the host's member workflows, and the run acts for the parent request's app and policy. dedup_key MUST begin with the parent request id; a key that names a queued or running run returns that run. GET /workflow/{workflow_id}/runs/{run_id}?parent_request_id= reads it.

10.6 Policies

A policy is the resource boundary an event runs in (section 6.6). The user application defines it before its first event names it.

  • PUT /policies/{policy_id} with body {sandbox, browser_sites, wait_max_seconds} creates the policy or replaces it whole. Requests already running keep their snapshot.
  • GET /policies/{policy_id} returns it, or 404 POLICY_NOT_FOUND.
  • DELETE /policies/{policy_id} deletes it with its resources. It returns 409 POLICY_IN_USE while a session on the policy has a queued or running event.

11. Error Model

Transport and validation errors MUST be returned as JSON objects of the form:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "message is required"
  }
}

The host binding adds a details object (section 10.1).

Request execution failures after acceptance MUST be emitted as request.error events rather than converted into a different HTTP response. Transient errors (rate limits, timeouts, network errors, provider overload) in model calls and tool calls are retried automatically at the step level before request.error is emitted. The request.error payload SHOULD include error_code and retryable fields so clients can distinguish transient failures (retries exhausted) from permanent ones.

HTTP status codes used by the bindings:

  • 200 OK for successful stream establishment, health checks, interaction delivery, host responses, and resubmission of a known request_id
  • 202 Accepted for request submission on the per-agent HTTP server
  • 400 Bad Request for invalid JSON or invalid field values
  • 401 Unauthorized for a missing or invalid bearer token
  • 403 Forbidden for an agent relay call the caller's token or the parent request does not permit (section 10.5)
  • 404 Not Found for unknown routes, agents, hosts, or request ids
  • 409 Conflict for answering an interaction that already has an answer, a request_id that belongs to another agent, a session bound to another policy, deleting a policy in use, or cancelling an event that has ended
  • 422 Unprocessable Entity for host request bodies that fail schema validation
  • 500 Internal Server Error for unexpected failures

This section is informative.

12.1 MCP

MCP is complementary to H2A. MCP focuses on tools, resources, prompts, and external context interoperability and includes explicit initialization and capability negotiation. H2A focuses on host-to-agent execution, lifecycle, and transport semantics.

12.2 A2A

Google A2A is the closest adjacent public protocol. It emphasizes agent-to-agent communication, task lifecycle, structured messages, artifacts, and long-running execution. H2A is narrower and host-to-agent first.