package a2a-client
A2A (Agent2Agent) protocol client for OCaml 5 / Eio (v1.0, v0.3 compatible)
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.3.0.tar.gz
md5=7bf58c1e200b0edbe84dc0f5d305dd2c
sha512=6c4f24e96ddea9a9c8664916323f1f8f3f970cf7714de2182cf849c8c0a983539b0364d019daf3648f42b1d90c357f69993b68c9df8117319709e2f415832c12
doc/CHANGES.html
0.3.0
- Pull-based streaming:
open_streaming_messageandopen_task_subscriptionreturn anEvent_stream.tread withEvent_stream.next. They return once the agent has accepted the request and sent its first event, so refusals, HTTP errors and agent errors (also in-band ones) are known before anything is relayed. Events are read only as the caller takes them;Event_stream.closeor leaving the switch releases the connection. Reconnection works as for the push form, which is unchanged. ?accumulate:falseon streaming calls tracks only the task's id, context, status and metadata, so memory stays constant on long streams.- Folding stream events is linear: 0.2.2 copied the task history on every status update and the parts of an artifact on every appended chunk, which was quadratic in the number of events.
connectandof_agent_cardtake?rewrite_endpointto use another URL than the one the Agent Card advertises, andrebase_endpoint ~ontomoves it onto the host the card was fetched from (agents in containers often advertise their bind address).- New library
a2a-client.testing: a scripted agent behind aTransport.t, with typed replies encoded for any protocol version and binding. Error.Code.to_reason, the inverse ofof_reason.
Breaking changes, so that decoded values carry their meaning in the type instead of being checked later:
Protocol.t(V1_0 Jsonrpc,V1_0 Http_json,V0_3) replacescreate ?protocol_version ?binding; 0.3 over HTTP+JSON can no longer be written.protocol clientreturns it;connectkeeps?protocol_versionand?bindingsas preferences.Agent_interface.protocol_bindingandprotocol_versionareKnown _ | Unknown of stringinstead of strings, parsed when the card is decoded.- Absent values are
options instead of"":Message.message_id, thecontext_idof status and artifact update events, andnext_page_token. - Agent capabilities are
bool(absent meansfalse). - Push notification configs are split into
Push_notification_config.t(url, token, authentication, id), as sent with a message, andTask_push_notification_config.t(task_idand that config). A config whosetaskIdis missing no longer decodes. - URLs are
Uri.t: interface and push config URLs, URL parts, and the URLs of an Agent Card (provider, documentation, icon, OAuth and OpenID Connect). wait_for_taskandsend_message_and_waittake?poll:Poll.tinstead of?interval ?max_interval ?backoff.A2a_client_testing.agenttakes?protocol.- The opam file carries the version, so pins and lock files show which release is used.
- The package is on the opam repository:
opam install a2a-client.
0.2.2
- The HTTP and connection pool tests run over an in-memory Eio network instead of loopback TCP sockets, so they pass where binding a socket is not permitted (e.g. in the opam sandbox on macOS).
0.2.1
- Require cohttp-eio, cohttp and http >= 6.2.1. Earlier versions have a different
Cohttp_eio.Client.make ~httpstype and do not compile.
0.2.0
- HTTP+JSON (REST) binding for protocol 1.0, selected from the Agent Card (
~bindings) or withcreate ~binding:Http_json. REST errors (google.rpc.Statuswith anErrorInforeason) becomeRpc_errors with the same codes as JSON-RPC errors. New moduleProtocol_binding, newbindingaccessor, andError.Code.of_reason. list_tasks(ListTasks) with filters and cursor pagination.- Push notification configs:
create_task_push_notification_config,get_…,list_…,delete_…, andpush_notification_configinSend_message_configuration(also with protocol 0.3). get_extended_agent_card(GetExtendedAgentCard, 0.3agent/getAuthenticatedExtendedCard) andwith_agent_card.- Stream resumption:
~reconnect:(Reconnect.make ())re-attaches a broken stream withSubscribeToTask(withLast-Event-IDand backoff), and falls back toGetTaskif the task ended meanwhile. Off by default. Transport.pooled: HTTP/1.1 keep-alive connection pool scoped to aSwitch, with a retry on stale connections. Responses not read to the end are drained in the background so their connections can be reused.Transport.methgains`DELETE;Transporthas an interface file.- Capability checks against the Agent Card also cover push notifications and the extended Agent Card.
Error.Code.to_string (Other n)is now"error n", as it also covers REST errors.- Behaviour change:
connect,of_agent_cardandselect_interfacenow also pickHTTP+JSONinterfaces, in the card's order. Pass~bindings:[ Jsonrpc ]to keep JSON-RPC only. - Breaking:
Send_message_configuration.thas a new fieldpush_notification_config; build the record withmake. - Backward compatibility with A2A v0.3. The protocol version is negotiated from the Agent Card (1.x preferred, then 0.3.x) or set with
~protocol_version. Existing code needs no changes. - Agent Cards in the v0.3 layout (
url,preferredTransport,additionalInterfaces,security,type-tagged security schemes,supportsAuthenticatedExtendedCard) are decoded. - New modules
Protocol_versionandCodec_v0_3; newversionaccessor. select_interfacefalls back to a v0.3 JSON-RPC interface instead of failing withNo_compatible_interface.- Breaking: the public API is narrowed to what applications use.
JsonrpcandSseare no longer exported, andCodecexposes only the protocol conversions (internal helpers andCodec.to_stringare gone; useCodec.decode_json/decode_string).LifecycleexposesOutcomeandapply.
0.1.0
Initial release.
- A2A protocol v1.0 client over the JSON-RPC binding (cohttp-eio, Eio).
- Agent Card discovery and JSON-RPC interface selection.
SendMessage,GetTask,CancelTask,SendStreamingMessage,SubscribeToTask.- Incremental Server-Sent Events parser.
- Task lifecycle helpers:
Outcome,wait_for_task,send_message_and_wait.