NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::a2a::A2AClient Class Reference

A2A client — call a remote agent over JSON-RPC + HTTP. More...

#include <client.h>

Public Types

using EventCallback = std::function< bool(const StreamEvent &)>
 message/stream — send a message and receive SSE-framed status updates as the agent progresses, plus the final Task.
 
using StreamCallback = EventCallback
 

Public Member Functions

 A2AClient (std::string base_url)
 
Task cancel_task (const std::string &task_id)
 tasks/cancel — request cancellation. Returns updated Task.
 
AgentCard fetch_agent_card (bool force=false)
 GET /.well-known/agent-card.json.
 
asio::awaitable< AgentCardfetch_agent_card_async (bool force=false)
 Async variant of fetch_agent_card.
 
Task get_task (const std::string &task_id, int history_length=0)
 tasks/get — fetch the latest snapshot of a task.
 
json rpc_call (const std::string &method, const json &params)
 Lower-level: arbitrary JSON-RPC method.
 
asio::awaitable< json > rpc_call_with_fallback (const std::string &v1_method, const std::string &v03_method, const json &params)
 Two A2A protocol generations are deployed in the wild: v1 (PascalCase, e.g.
 
asio::awaitable< Tasksend_message_async (const MessageSendParams &params)
 Async variant — server's response payload may be either a Message or a Task; we coerce both into a Task with the message in history so callers have one shape to handle.
 
Task send_message_sync (const MessageSendParams &params)
 Send an arbitrary Message (multipart, file, structured data).
 
Task send_message_sync (const std::string &text, const std::string &task_id="", const std::string &context_id="")
 message/send — convenience wrapper around send_message_sync().
 
void set_timeout (std::chrono::seconds t)
 Override the default 30 s request timeout.
 

Detailed Description

A2A client — call a remote agent over JSON-RPC + HTTP.

Thread-safe: every public method acquires its own ephemeral HTTP connection; no shared in-flight state. Reuses neograph::async::async_post for transport.

a2a::A2AClient client("https://agent.example.com");
auto card = client.fetch_agent_card(); // discovery
auto task = client.send_message_sync("Hello!"); // round-trip
std::cout << task.status.state; // TaskState::Completed
A2A client — call a remote agent over JSON-RPC + HTTP.
Definition client.h:44

Definition at line 44 of file client.h.

Member Typedef Documentation

◆ EventCallback

using neograph::a2a::A2AClient::EventCallback = std::function<bool(const StreamEvent&)>

message/stream — send a message and receive SSE-framed status updates as the agent progresses, plus the final Task.

on_event is invoked synchronously on the network thread for each parsed StreamEvent. Return true to keep reading or false to abort early. The final Task (or a status-update with final=true) ends the stream regardless.

Definition at line 98 of file client.h.

◆ StreamCallback

Deprecated:
Renamed to EventCallback to avoid colliding with neograph::StreamCallback (provider.h: void(string)). The shapes are different (return type + argument), so a TU pulling in both <neograph/provider.h> and <neograph/a2a/client.h> would shadow one with the other. Old name kept as an alias for back-compat — prefer EventCallback in new code.

Definition at line 105 of file client.h.

Constructor & Destructor Documentation

◆ A2AClient()

neograph::a2a::A2AClient::A2AClient ( std::string  base_url)
explicit
Parameters
base_urlAgent endpoint URL (e.g. "https://agent.example.com"). The well-known card path is appended on discovery.

Member Function Documentation

◆ fetch_agent_card()

AgentCard neograph::a2a::A2AClient::fetch_agent_card ( bool  force = false)

GET /.well-known/agent-card.json.

Exposes the agent's identity, transports, and skills. Caches the result in-instance — repeat calls are no-ops unless force is set.

◆ rpc_call_with_fallback()

asio::awaitable< json > neograph::a2a::A2AClient::rpc_call_with_fallback ( const std::string &  v1_method,
const std::string &  v03_method,
const json &  params 
)

Two A2A protocol generations are deployed in the wild: v1 (PascalCase, e.g.

"SendMessage") used by a2a-sdk Python ≥1.0.0, and v0.3 (slash-form, e.g. "message/send") used by a2a-js HEAD and pre-v1 deployments. Try v1_method first; on a -32601 "method not found" reply, retry with v03_method on the same params. Other JSON-RPC errors propagate.

◆ send_message_sync()

Task neograph::a2a::A2AClient::send_message_sync ( const std::string &  text,
const std::string &  task_id = "",
const std::string &  context_id = "" 
)

message/send — convenience wrapper around send_message_sync().

Parameters
textPlain text content for a single TextPart.
task_idOptional existing task to continue.
context_idOptional grouping id.

The documentation for this class was generated from the following file: