Header menu logo Nao

ToolContext Type

Runtime context handed to a tool's Execute (and to the orchestrator) so it can request approval for sensitive resource access dynamically — based on its own input or intermediate results — locate the session's file folder, and launch background work. The runtime builds one per session/turn and threads it explicitly; library and test code can use `ToolContext.allowAll`.

Record fields

Record Field Description

AsyncAgents

Full Usage: AsyncAgents

Field type: Set<string>

Names of agents flagged async. When the orchestrator delegates to one of these, it spawns a background task (a sub-session) instead of running it inline.

Field type: Set<string>

FilesKey

Full Usage: FilesKey

Field type: string

Session key whose file folder backs file operations in this context. Usually the same as SessionKey, but a task sub-session points this at its parent session so the user's attachments and the files the task generates share one folder.

Field type: string

RequestPermission

Full Usage: RequestPermission

Field type: ResourceAccess -> string -> bool -> Task<bool>

Request approval to access a resource, with a human-readable reason. The final argument forces an interactive prompt even for resources that would otherwise be auto-allowed (e.g. paths inside the workspace sandbox); already-granted rules still suppress the prompt. Returns true when allowed. The runtime answers from already-granted session/global rules or by prompting the user live.

Field type: ResourceAccess -> string -> bool -> Task<bool>

SessionKey

Full Usage: SessionKey

Field type: string

The session this execution belongs to ("userId/sessionId"); "" when unscoped.

Field type: string

SpawnTask

Full Usage: SpawnTask

Field type: TaskSpec -> Task<string>

Launch a background task owned by this session, returning its task id. The default is a no-op signalling "no async task host available" by returning an empty id.

Field type: TaskSpec -> Task<string>

TurnId

Full Usage: TurnId

Field type: string

Id of the turn currently being processed ("" when none).

Field type: string

Type something to start searching.