> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aion.to/llms.txt
> Use this file to discover all available pages before exploring further.

# Invocation Context

> AionInvocationContext — ADK invocation context extended with Aion runtime data.

`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

```python theme={null}
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:

```python theme={null}
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

| Field                  | Type                         | Description                                                                              |
| ---------------------- | ---------------------------- | ---------------------------------------------------------------------------------------- |
| `aion_runtime_context` | `AionRuntimeContext \| None` | Inbound 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](/sdk/python/messaging/runtime-context) for the full field reference.

```python theme={null}
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:

| Field              | Type                          | Description                                                                                         |
| ------------------ | ----------------------------- | --------------------------------------------------------------------------------------------------- |
| `artifact_service` | `BaseArtifactService \| None` | Artifact storage for the current invocation. Used internally by `emit_artifact` and `Thread.post()` |
| `session`          | `Session`                     | ADK session for the current invocation                                                              |
| `app_name`         | `str`                         | Agent application name                                                                              |
| `user_id`          | `str`                         | User identifier for the current session                                                             |

## Related Pages

* [AionRuntimeContext](/sdk/python/messaging/runtime-context)
* [Thread](/sdk/google-adk/api/thread)
* [Message](/sdk/google-adk/api/message)
* [Streaming API](/sdk/google-adk/api/streaming-api)
