A2aAgent

class A2aAgent(val agentUrl: String, headers: Map<String, String> = emptyMap(), httpClient: A2AHttpClient = AndroidA2AHttpClient())(source)

One remote A2A agent, reached through the official A2A Java SDK (JSON-RPC binding, A2A 1.0) and its Android HTTP client.

Parameters

agentUrl

the agent's base URL (its card is read from /.well-known/agent-card.json) or the card's URL.

headers

sent with every request, e.g. Authorization.

Constructors

Link copied to clipboard
constructor(agentUrl: String, headers: Map<String, String> = emptyMap(), httpClient: A2AHttpClient = AndroidA2AHttpClient())

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun A2aAgent.asSubAgent(card: AgentCard, name: String = subAgentName(card.name())): SubAgent

This remote agent as a SubAgent for dev.ai.elements.core.agent.SubAgents: the orchestrator delegates to it with delegate_task, and its reply streams into the UI like any sub-agent's.

Link copied to clipboard
suspend fun cancel(taskId: String)

Ask the agent to cancel taskId.

Link copied to clipboard
suspend fun card(): AgentCard

The agent card (fetched once).

Link copied to clipboard
suspend fun cardOrNull(timeoutMs: Long, retryAfterMs: Long): AgentCard?

The card if it arrives within timeoutMs, else null — for listing agents at the start of a turn without waiting on one that is unreachable. The fetch keeps going in the background, so a slow agent's card is ready next time; an agent that failed is not asked again for retryAfterMs. Unlike wrapping card in a timeout, this returns on time even while the HTTP client is stuck in a blocking connect.

Link copied to clipboard
fun send(message: Message): Flow<ClientEvent>

Send message and stream what the agent answers: a Message, or a Task followed by its status and artifact updates. The flow completes when the agent's stream ends; cancelling it stops reading.