Skip to content

ToolContext

Defined in: src/tools/tool.ts:12

Context provided to tool implementations during execution. Contains framework-level state and information from the agent invocation.

toolUse: ToolUse;

Defined in: src/tools/tool.ts:17

The tool use request that triggered this tool execution. Contains the tool name, toolUseId, and input parameters.


agent: LocalAgent;

Defined in: src/tools/tool.ts:23

The agent instance that is executing this tool. Provides access to agent state, conversation history, and cancellation state.


invocationState: InvocationState;

Defined in: src/tools/tool.ts:34

Per-invocation state shared across hooks and tools for the current agent invocation. Mutable — read and write freely; changes are visible to subsequent hooks, tools, and on AgentResult.invocationState.

Distinct from agent.appState: invocationState is ephemeral and accepts arbitrary values, while appState is durable, JSON-serializable, and deep-copied on read/write.