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_idvalues for addressable agents. - Each addressable agent MUST have an associated client.
- A host MUST be able to resolve
agent_idto 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 -> HostHost -> ClientClient -> 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 routeevent_id: unique in its session; posting the sameevent_idagain returns the stored eventapp_idandpolicy_id(section 6.6)message- optional
context,metadataandstructured_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:
messagesession_id: the event's sessionrequest_id: derived from the session and event ids, so a host that restarts resubmits the same requestapp_id,policy_idand the policy's snapshot- optional
context,structured_outputandmetadata
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_requeststream_responsepost_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: stringsession_id: stringapp_id: string: the application the request acts for. Likemetadata, it is stored with the request and never shown to the modelpolicy_id: string: the policy the request runs underpolicy: 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:
messageMUST be present and MUST be a non-empty string.session_idMUST be present and MUST be a non-empty string.request_id, when present, MUST be 1 to 255 characters of letters, digits,.,_,:or-.app_idandpolicy_idMUST be present and MUST each be 1 to 255 characters of letters, digits,.,_,:,@or-.policyMUST be present and MUST be a policy object.- A request with a
conversationparent MUST carry the parent request'sapp_id,policy_idandpolicy. A host relay enforces this (section 10.5). - A request with a
workflowparent MUST carry the workflow run'sapp_id,policy_idand 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 with409 SESSION_POLICY_MISMATCH. - Requests that share a
session_idMUST 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: stringagent_id: stringsession_id: stringstatus: "accepted"app_id: stringpolicy_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;0by default
Rules:
- The stream MUST start with the first event after
after, which is the request's first event whenafteris0. - 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, orrequest.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: stringinteraction_id: stringresponse: any
Rules:
interaction_idMUST 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 with404 INTERACTION_NOT_FOUND.
The result is a JSON object containing:
ok: trueinteraction_id: string
Example:
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.acceptedMUST be the first event for a request.request.startedMUST be emitted before anyagent.traceor terminal event.request.interaction.createMUST be followed by exactly onerequest.interaction.ackwith the sameinteraction_id.request.interaction.createandrequest.interaction.ackMAY appear zero or more times betweenrequest.startedand 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 asexecute_tool.end),trace_id,session_id,loop_index,step_key,created_at, andpayload.request.completed: theinvoke_agent.endpayload:request_id,agent_id,session_id,status: "ok",trace_id,attributes, and the saved turn, includingresponsewithtext,signals, andmetadata, plusstructured_outputwhen one was requested.request.error:request_id,agent_id,session_id,status: "error",attributes,error, and when knownerror_type,error_code,retryable, andstop_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, andpost_interactiontogether 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 requestdescribe: 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: falseremoves 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_secondscaps every interaction's timeout (section 7.5);nullsets 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 requestagent_id: string: the agent requesting interactionsession_id: string: current sessioninteraction_id: string: unique identifier for this interactiontype: string: one ofapproval,info,choice,browserprompt: string: human-readable question or descriptionschema: object: describes the expected response shapetimeout_seconds: number | null: how long execution will wait;nullfor 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: stringagent_id: stringsession_id: stringinteraction_id: string: matches the originatingrequest.interaction.createresponse: any: the user's response (string for approval and info, array for choice), the default on timeout, ornullon canceltimed_out: true(optional): present when no response arrived in time andresponseis the defaultcancelled: 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.ackcarrying the default response andtimed_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 /healthGET /agent/{agent_id}/describePOST /agent/{agent_id}/session/{session_id}/compactPOST /agent/{agent_id}/requestGET /agent/{agent_id}/request/{request_id}POST /agent/{agent_id}/request/{request_id}/interactionGET /agent/{agent_id}/request/{request_id}/statusPOST /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:
- return
404 ROUTE_NOT_FOUNDifagent_idis not the agent it serves - read the request body as JSON, returning
400 INVALID_JSONif it does not parse - return
400 INVALID_REQUESTfor a non-object body - validate that
messageis a non-empty string, returning400 INVALID_REQUESTotherwise - validate that
session_idis a non-empty string, returning400 INVALID_REQUESTotherwise - if
structured_outputis present, validate it as a JSON schema object, returning400 INVALID_STRUCTURED_OUTPUTotherwise - if
metadatais present, validate that it is an object, returning400 INVALID_REQUESTotherwise - if
contextis present, validate that it is a string, and ifhostis present, validate that it is an object, returning400 INVALID_REQUESTotherwise - if
parentis present, validate it against the shapes in section 6.1, returning400 INVALID_PARENTotherwise - validate that
app_id,policy_idandpolicyare present and well formed (section 6.1), returning400 INVALID_REQUESTotherwise - if
request_idis present, validate it (section 6.1), returning400 INVALID_REQUESTotherwise. If it belongs to a request of this agent, return200 OKwith that request's accepted payload. If it belongs to another agent, return409 REQUEST_ID_CONFLICT - return
409 SESSION_POLICY_MISMATCHif the session already has a request under anotherpolicy_id - call the runtime request-submission operation with
message,session_id,structured_output,metadata,request_id,context,host,parent,app_id,policy_idandpolicy - return
202 Acceptedwith the accepted payload as the body
Example error:
8.3 GET Stream Handling¶
For GET /agent/{agent_id}/request/{request_id}, the server MUST:
- return
404 ROUTE_NOT_FOUNDifagent_idis not the agent it serves - return
404 REQUEST_NOT_FOUNDfor an unknownrequest_id, or one accepted for another agent - read optional
afterfrom the query, returning400 INVALID_REQUESTwhen it is not an integer - respond
200 OKwithContent-Type: text/event-stream - read the request's events in order, starting after the event whose sequence number is
after(from the first event when it is0or absent), writing each as one SSE frame withid:(the event's sequence number),event:anddata:lines - 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:
- return
404 ROUTE_NOT_FOUNDifagent_idis not the agent it serves - return
404 REQUEST_NOT_FOUNDfor an unknownrequest_id, or one accepted for another agent - read the request body as JSON, returning
400 INVALID_JSONor400 INVALID_REQUESTfor a body that does not parse or is not an object - validate that
interaction_idis a non-empty string, returning400 INVALID_REQUESTotherwise - return
404 INTERACTION_NOT_FOUNDif the request never openedinteraction_id - record
responseas the interaction's answer, returning409 INTERACTION_CLOSEDif it already has one (section 6.3), and wake the waiting execution - return
200 OKwith{"ok": true, "interaction_id": ...}
8.5 Request Control Handling¶
For the status and cancel routes, the server MUST:
- return
404 ROUTE_NOT_FOUNDifagent_idis not the agent it serves - return
404 REQUEST_NOT_FOUNDif the runtime does not know the request, or it was accepted for another agent, without running the operation - call the runtime's corresponding operation for
request_id - return
200 OKwith 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: stringtools: one object per registered tool withname,description,parameters,requires_approval, andparallel_safeskills: one object per registered skill withname,description,type, andcontent
8.8 Session Compaction Handling¶
For POST /agent/{agent_id}/session/{session_id}/compact, the server MUST:
- return
404 ROUTE_NOT_FOUNDifagent_idis not the agent it serves - read the body as JSON, returning
400 INVALID_JSONor400 INVALID_REQUESTfor a body that does not parse or is not an object - validate optional
reasonas a non-empty string (default"manual"), returning400 INVALID_REQUESTotherwise - return
400 INVALID_REQUESTwhen the agent keeps no history to compact. Only the companion compacts: its session is a conversation, and compaction writes the board's summary entry - return
200 OKwithsummary_textandtrace_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_idrun 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.erroranderror_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:
- the host resolves
agent_idto the associated client - the client calls
post_request - the per-agent HTTP server accepts the request
- the client calls
stream_response - the per-agent HTTP server streams the lifecycle for that request
- if
request.interaction.createis received, the client callspost_interaction - 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:
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?}. Returns202with the event:{"data": {"session_id", "event_id", "request_id", "seq", "status", ...}}.request_idis derived from the session and event ids, so it is known while the event waits. Anevent_idthe session already has returns200with that event and runs nothing. An unknown policy returns404 POLICY_NOT_FOUND, and a session bound to another policy returns409 SESSION_POLICY_MISMATCH.POST /sessions/{session_id}/eventswith body{event_id, interaction_id, response}answers an interaction of the event's request (section 6.3). Returns200,404 INTERACTION_NOT_FOUNDfor an interaction the request has not opened,400 INVALID_INTERACTION_RESPONSEfor a response its schema does not allow, and409 INTERACTION_CLOSEDfor one closed by another answer, a timeout or a cancel. Repeating the stored answer returns200.GET /sessions/{session_id}/events/{event_id}/stream?after=: the SSE stream of the event's request (section 6.2). Each frame'sid:is its sequence number, andafterresumes 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 oneaftercovers both. While the event waits, the stream holds with anevent.queuedframe. An event cancelled before it started gets oneevent.cancelledframe. The host closes the stream after writingrequest.completed,request.error,request.cancelledorevent.cancelled.GET /sessions/{session_id}/events/{event_id}: the event'sstatus(queued,running,waiting,completed,failedorcancelled), its request's open interactions,responseanderror.GET /sessions/{session_id}/eventsandGET /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 openbrowserinteraction, 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
conversationparent 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
infointeraction), 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 (achoiceinteraction), then routes to it.
10.4 Request Control¶
GET /agent/{agent_id}/request/{request_id}/statusreturnsrequest_idandstatus, the request's recorded lifecycle state:running,completed,failedorcancelled. A request the runtime does not know returns404 REQUEST_NOT_FOUND. This is useful when a stream goes silent after a process crash:runningmeans 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}/cancelcancels 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 withresponse: null(section 7.7). The runtime then appendsrequest.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 returns409 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 UNAUTHORIZEDfor a token that matches no agent. POST /agent/{agent_id}/requestMUST carry aparentof kindconversationwhoseagent_idis the caller, and the caller MUST be the companion. Itssession_idMUST be the parent request's session. Otherwise the relay returns403 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 returns403 FORBIDDEN. agent_idMUST be one of the host's member agents. Otherwise the relay returns403 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_idandpolicyto the parent request's. A value in the body that differs from the parent's returns403 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_MISMATCHfrom the agent is returned as is. POST /workflow/{workflow_id}/runwith 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_keyMUST 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, or404 POLICY_NOT_FOUND.DELETE /policies/{policy_id}deletes it with its resources. It returns409 POLICY_IN_USEwhile 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:
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 OKfor successful stream establishment, health checks, interaction delivery, host responses, and resubmission of a knownrequest_id202 Acceptedfor request submission on the per-agent HTTP server400 Bad Requestfor invalid JSON or invalid field values401 Unauthorizedfor a missing or invalid bearer token403 Forbiddenfor an agent relay call the caller's token or the parent request does not permit (section 10.5)404 Not Foundfor unknown routes, agents, hosts, or request ids409 Conflictfor answering an interaction that already has an answer, arequest_idthat belongs to another agent, a session bound to another policy, deleting a policy in use, or cancelling an event that has ended422 Unprocessable Entityfor host request bodies that fail schema validation500 Internal Server Errorfor unexpected failures
12. Related Protocols¶
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.