Skip to main content
AionInvocationContext extends Google ADK’s InvocationContext with aion_runtime_context: the inbound A2A state for the current invocation — inbox, typed event, and distribution payload — without requiring direct access to server internals.

Import

from aion.adk.authoring.invocation import AionInvocationContext

Typing the Context

ADK passes the invocation context to _run_async_impl as the base InvocationContext. Type it as AionInvocationContext to get IDE support for the Aion-specific field:
from aion.adk.authoring.invocation import AionInvocationContext


class MyAgent(BaseAgent):
    async def _run_async_impl(self, ctx: AionInvocationContext):
        runtime = ctx.aion_runtime_context
        ...

Aion Fields

FieldTypeDescription
aion_runtime_contextAionRuntimeContext | NoneInbound A2A state for the current invocation. None when the agent runs outside of Aion
aion_runtime_context is the entry point for the inbox, typed event, and distribution payload. See AionRuntimeContext for the full field reference.
async def _run_async_impl(self, ctx: AionInvocationContext):
    if ctx.aion_runtime_context is None:
        return  # running outside Aion

    inbox = ctx.aion_runtime_context.inbox
    event = ctx.aion_runtime_context.event
    distribution = ctx.aion_runtime_context.get_distribution()

ADK Base Fields

AionInvocationContext inherits all standard ADK InvocationContext fields. The ones most relevant when writing Aion agents:
FieldTypeDescription
artifact_serviceBaseArtifactService | NoneArtifact storage for the current invocation. Used internally by emit_artifact and Thread.post()
sessionSessionADK session for the current invocation
app_namestrAgent application name
user_idstrUser identifier for the current session