Skip to main content

RemoteAgent

What it is

RemoteAgent is the SDK’s client for any A2A-compliant agent — another Svantic agent in your tenant, a public agent on the internet, or an agent you’re running locally during development. It discovers the remote’s agent card, wraps the A2A JSON-RPC transport, and exposes three ways to interact:
  • Structured invocation — call a named capability with typed arguments (invoke_capability).
  • Natural-language prompts — send plain text to a smart agent (send).
  • Streaming — receive incremental A2A events as the remote produces them (send_stream, send_stream_message).
RemoteAgent does not require the caller to be an Agent. You can use it from any Node.js process.

When to use it

Reach for RemoteAgent whenever you need to call another agent:
  • From a standalone script or service that isn’t itself an agent.
  • From inside a capability handler to delegate work to a specialist agent.
  • From a smart agent’s orchestration code when the platform’s own routing isn’t enough.
If you only need to inspect an agent’s card without sending messages (e.g. to build a capability picker), use AgentDiscovery — it skips the full client setup.

Functional usage

Use MessageBuilder + send_stream_message when you need to attach files, session context, or other metadata on the way out. See Calling other agents for the common patterns.

Connecting

RemoteAgent.connect(url, token?)

Fetches the remote agent’s /.well-known/agent-card.json, validates it, and returns a ready-to-use RemoteAgent. Pass an optional bearer token when the remote requires authentication. Throws if the card cannot be fetched or is malformed.

Sending messages

send(message, context_id?)

Send a natural-language message and wait for the complete response. Returns an A2A Message or Task. Use context_id to continue an existing A2A conversation.

send_stream(message, context_id?)

Same as send, but yields streaming A2A events (Message, Task, TaskStatusUpdateEvent, TaskArtifactUpdateEvent) as the remote produces them.

send_stream_message(message)

Stream a fully-formed A2A Message — use this when you need DataParts, FileParts, or custom metadata alongside text. Construct message with MessageBuilder.

Invoking capabilities

invoke_capability(capability, args, session_context?, context_id?, dispatch_auth?)

Invoke a single named capability with structured arguments. Returns the value the remote handler returned — the SDK unwraps the DataPart envelope for you. Parameters:
  • capability — capability name as it appears on the agent card.
  • args — arguments matching the capability’s JSON Schema.
  • session_context (optional){ session_id, tenant_id } forwarded to the remote handler.
  • context_id (optional) — A2A conversation id.
  • dispatch_auth (optional) — dispatch-auth envelope when the remote requires it.

Inspecting the remote

See also