Aller au contenu principal

SDK / ctx contract

Runtime context passed to every tool and every workflow.

The attributes below are the whole surface the code sees, and their reach is not uniform: ctx.workspace, ctx.notify and ctx.stt are None on every binary this project ships, and ctx.mail raises outside the desktop application. Each service page states its own reach. Use type hints to get IDE autocomplete::

@tool("greet", "Greet a known user.", action="read_personal")
async def greet(ctx: Ctx, name: str) -> dict:
user = await ctx.memory.recall(f"user.{name}")
...

Services​

ServiceTypeSummary
ctx.llmLlmProxyctx.llm - LLM backend access.
ctx.memoryMemoryInterfaceTri-mode memory: episodic events, semantic key-value, procedural triggers.
ctx.toolsToolProxyTool invocation surface - native registry + MCP routing.
ctx.mailMailInterfaceDurable, at-least-once inter-agent messaging surface.
ctx.datasourcesDatasourcesInterfaceRuntime access to the YAML datasources the context was given.
ctx.templatesTemplatesInterfaceRuntime Jinja2 template rendering.
ctx.secretsSecretsInterfaceRead-only access to the credentials the context was granted.
ctx.eventsEventsInterfacePublic typed events for streaming, ReAct observability, error reporting.
ctx.loggerLoggerctx.logger - structured logging via stdlib logging.
ctx.profileProfileInterface | NoneUser profile surface.
ctx.workspaceWorkspaceContextSnapshot of the workspace at task start.
ctx.sttSttInterfaceAudio transcription surface backed by apollia-stt.
ctx.notifyNotifyInterfaceNotification surface (desktop, webhook, future channels).
ctx.budgetBudgetViewRuntime step budget tracking, read-only from the agent's perspective.
ctx.is_resumedboolTrue when this run resumes a task that paused on a human.
ctx.input_responseInputResponse | NoneThe operator's response to the pause being resumed, None on a first run. See apollia.hitl.

See also Content types and helpers for the multi-modal message shapes.