1. Inbound Messages
1.1 Agent Invocation
BothSendMessage and SendStreamingMessage use the same execution path: the agent’s
run_async() is always driven as an async event stream.
SendMessage(blocking=true) — collects all events and returns the finalTask.SendMessage(blocking=false) — returns after the first event, continues processing in background withstatus="working".SendStreamingMessage— yields events as they arrive and streams them to the client via SSE.
SendMessageRequest payload; only the response mode differs.
1.2 Part Type Mapping
Inbound A2A message parts are transformed into ADKContent as follows:
| A2A Part | ADK Representation |
|---|---|
Part(text=...) | types.Part(text=...) |
Part(raw=...) | types.Part(inline_data=types.Blob(mime_type=..., data=...)) |
Part(url=...) | types.Part(file_data=types.FileData(mime_type=..., file_uri=...)) |
Part(data=...) | types.Part(text=json.dumps(data)) |
mime_type attribute → guess from filename →
fallback to application/octet-stream.
If the message contains no usable parts, the plain text input from the request is used as a fallback.
1.3 Accessing Inbound Context — ctx.a2a_inbox
When an inbound A2A Message arrives, Aion Server makes it available through ctx.a2a_inbox on
the invocation context:
a2a_inbox contains:
| Field | Type | Description |
|---|---|---|
task | Task | The current A2A Task |
message | Message | The full inbound A2A Message, including non-text parts |
metadata | dict | SendMessageRequest-level metadata (distribution/network, trace info) |
2. Outbound Messages
Valid responses to an A2ASendMessage call are a Message or a Task.
Aion Server constructs the response using the following precedence:
(1) a2a_outbox (authoritative)
Set a2a_outbox in event.actions.state_delta to provide an explicit A2A response. It must be an
A2AOutbox instance wrapping either a Message or a Task:
task_idandcontext_idare set to current values managed by Aion Server.- Canonical routing and identity metadata (e.g.
aion:network, sender IDs) is server-controlled.
- If
a2a_outbox.messageis set → append to current Task history. - If
a2a_outbox.taskis set → treat as a patch to the server’s Task: server merges or extendshistoryandartifacts; providedmetadatamerges shallowly; server-controlled keys take precedence.
(2) Fallback: accumulated delta text
If noa2a_outbox is set and the stream ended while still in partial mode (no closing non-partial
event followed), Aion Server emits the accumulated delta text as the final response message.
This fallback only applies when the last event was partial and no non-partial event closed the
stream.
If you need to return a comprehensive A2A response (e.g., data parts, rich metadata, multiple
artifacts), use a2a_outbox rather than relying on the streaming fallback.
3. Summary
- Read
ctx.a2a_inboxto access the inbound A2A Task, Message, and metadata. - Optionally set
a2a_outboxinevent.actions.state_deltaas anA2AOutboxinstance for full-fidelity A2A responses. - Yield partial events for real-time text streaming.