The shape of per-session state created by the agent's
state factory. Defaults to DefaultSessionState; annotate the
context (ctx: ToolContext<MyState>) to get real checking.
SQL database scoped to this app. Available when storage is enabled
(aai storage enable, or Settings → Database in the studio); accessing
it otherwise throws.
Environment variables available to this agent's tools (from .env under
aai dev, aai secret in production). Custom keys a tool depends on
should be declared in AgentDef.requiredEnv so a missing value
fails at deploy time.
One-shot LLM generation, executed on the host (like db).
Defaults to the agent's pipeline llm; pass llm in the options to use
another provider (its API key must be in the agent's env). Throws when
no LLM is configured or named. Pass a Zod schema for typed structured
output (GenerateFn).
Read-only snapshot of conversation messages so far.
Unique identifier for the current session. Useful for correlating logs across concurrent sessions.
OptionalsignalCooperative cancellation signal. Aborts when the turn that issued this
tool call is cancelled (barge-in, reset, or session stop). Long-running
tools should pass it to fetch etc. so their work stops promptly;
absent in execution contexts that don't support cancellation.
Mutable per-session state created by the agent's state factory.
Push a custom event to the connected browser client. Fire-and-forget: events whose name exceeds MAX_CLIENT_EVENT_NAME_LENGTH or whose serialized payload exceeds MAX_CLIENT_EVENT_PAYLOAD_BYTES are dropped (with a warning log), not thrown.
Context passed to tool
executefunctions.Provides access to the session environment, state, database, and conversation history from within a tool's execute handler.
Example