A2A guide
Hybridbox exposes an A2A gateway for agent-oriented function discovery, session management, and function execution.1. Discover the agent card
Fetch the agent card first. It advertises gateway identity, auth, the function list URL, the JSON-RPC endpoint, and session bootstrap URLs.2. Authenticate or create a session
Most useful functions need a bearer session. Login returns bothsession_id and session_token; use the token in the Authorization header and pass the session ID in execute requests.
Login request:
session_id and session_token exactly like a user session:
3. List available functions
Use/v1/functions to list pseudo-functions visible to the current session.
4. Execute code through /v1/execute
Use code mode for function execution. A request can contain one call or multiple calls. Code requests run synchronously by default.
One function call:
- one function call per line
- variables and expression reuse
ifstatementsforloopsrange(...)- sequential execution in source order
responses[]contains every function call result in order.result.last_valuecontains the result from the last successful function call.- If a call fails, the response includes completed calls before the failure and identifies the failed call index.
5. /v1/execute vs /rpc
Both surfaces can execute the same code path, but they are meant for different clients.
/v1/executeis the direct HTTP execution endpoint. Use it when your client just wants to run Hybridbox functions./rpcis the A2A JSON-RPC message surface. Use it when your client speaks A2Amessage/sendand wants requests wrapped as JSON-RPC messages.
6. Subscribe to WebSocket notifications
Use WebSockets for live notifications about A2A sessions and tasks. WebSockets are notification-only; command execution still happens through/v1/execute or /rpc.
Mint a WebSocket ticket
Before opening a socket, mint a short-lived, single-use WebSocket ticket from your normal A2A session token:- The public ticket endpoint does not accept a TTL override.
- The current ticket lifetime is 1 minute; treat
expires_atas authoritative. - Each ticket is single-use and bound to the returned
session_id. Mint a fresh ticket for each connection attempt. - Only WebSocket tickets are valid for WebSocket authentication. Do not use
session_tokenorhbx_live_...service-account tokens asws_ticket, in the WebSocket URL, or inAuthorizationduring the WebSocket upgrade.
Open the socket
Browser clients pass the ticket asws_ticket while keeping session_id in the query string:
Authorization header replaces only ws_ticket; session_id is still required in the query string.
Origin headers are rejected unless the deployment explicitly allows missing origins for non-browser clients.
Send the first client message
Immediately after the upgrade succeeds, send the first client message.session_id is required and must match the query-string session ID. last_sequence is optional and is used for replay/resume.
Fresh stream:
error event with code INVALID_CLIENT_MESSAGE and closes the socket.
Server event envelope
Server events use this envelope:type: event namesession_id: owning A2A sessiontask_id: optional task referencerequest_id: optional execution request correlation IDevent_id: unique event identifiersequence: replay/resume sequence number;session.readyandpinguse0timestamp: server UTC timestamppayload: event-specific data
session.ready: subscription accepted and live delivery is activesession.replaced: another socket connected for the same session and replaced the old socketping: server keepaliveerror: protocol-level error payload withcodeandmessagetask.queued,task.running,task.completed,task.failed,task.cancelled: task lifecycle notificationstask.progress: reserved progress event type for long-running producers
Keepalive
The server sends aping event about every 20 seconds. Reply with:
Replay and replacement
Replay useslast_sequence from the first client message. If replay is available, the server sends missed events starting at last_sequence + 1, then sends session.ready. Replay is backed by a bounded Redis window of the last 100 events with a 15 minute TTL.
If the requested sequence is older than the retained replay window, the server sends an error event with code REPLAY_NOT_AVAILABLE. Poll task state over HTTP, then reconnect without assuming missed events were delivered.
Only one active socket is kept per session_id. A new connection for the same session replaces the old one. The old socket receives session.replaced with payload { "reason": "replaced" } and is then closed.
Function catalog
Open the function catalog when you need callable names, compact signatures, arguments, return fields, auth metadata, and public API route mappings.Function catalog
Browse generated function references by domain.