Skip to main content

Calling other agents

This guide covers how to call another A2A agent — another Svantic agent, a public third-party agent, or a local agent you’re developing against. The main tool is RemoteAgent. It handles discovery, authentication, and the A2A protocol so you can focus on the call.

One-shot structured call

Use invoke_capability when you know exactly which capability you want and the shape of its arguments:
The SDK unwraps the A2A DataPart envelope for you — result is whatever the remote handler returned.

Natural-language prompt

Use send when you want the remote agent to plan its own work (only useful against smart agents):
response is an A2A Message or Task. Inspect .parts to extract text or data parts.

Streaming responses

send_stream yields A2A events as they arrive — use it for anything that emits intermediate progress (plans, tool calls, partial outputs):
Event types: Message, Task, TaskStatusUpdateEvent, TaskArtifactUpdateEvent.

Rich messages (files, context, metadata)

Use MessageBuilder when plain text isn’t enough — attachments, session context, form replies, direct routing:
Upload files to Svantic first (POST /files/upload) and pass the returned file_id — the platform resolves it to LLM-native format at call time.

Continuing a conversation

Pass a context_id (usually the Svantic session_id) to keep turns on the same conversation thread:

Inspecting before calling

Use AgentDiscovery to fetch just the agent card:
RemoteAgent discovers internally, so you don’t need AgentDiscovery to call — use it only when inspection is the goal (e.g. building a capability picker).

Authenticating

Most calls to Svantic-hosted agents go through your own agent’s session (the caller’s JWT is forwarded automatically when you’re inside a capability handler or smart-agent turn). For standalone scripts calling a remote that requires auth, pass a bearer token:

Error handling

invoke_capability, send, and the stream methods reject or throw on transport, auth, or remote-side errors. Catch and inspect the message — the SDK preserves the A2A error payload in the thrown Error.

See also