Skip to content

Interface: ToolExecutionContext

@providerprotocol/agents


@providerprotocol/agents / index / ToolExecutionContext

Defined in: src/execution/types.ts:700

Context injected into tools during execution.

Per UAP-1.0 Section 8.4, ExecutionStrategy MUST inject this context when invoking tools that accept a second parameter. This enables tools to inherit agent configuration and propagate sub-agent events.

UAP-1.0 Spec Section 8.4

// Tool implementation receiving context
const myTool: Tool = {
name: 'my_tool',
description: 'Tool that uses execution context',
parameters: { type: 'object', properties: {} },
run: async (params, context?: ToolExecutionContext) => {
console.log('Executing in agent:', context?.agentId);
if (context?.onSubagentEvent) {
// Can spawn sub-agents and propagate events
}
return 'result';
},
};

agentId: string

Defined in: src/execution/types.ts:702

Agent instance ID for context inheritance


optional onSubagentEvent: OnSubagentEvent

Defined in: src/execution/types.ts:708

Callback for propagating sub-agent events to parent


stateId: string

Defined in: src/execution/types.ts:704

Current state snapshot ID for tracing


toolCallId: string

Defined in: src/execution/types.ts:706

Tool call ID from the model response