Type Alias: ContextAwareToolRun()
@providerprotocol/agents / index / ContextAwareToolRun
Type Alias: ContextAwareToolRun()
Section titled “Type Alias: ContextAwareToolRun()”ContextAwareToolRun = (
params,context?) =>Promise<unknown>
Defined in: src/execution/types.ts:740
Type for a tool run function that accepts execution context as a second parameter.
Tools can optionally accept ToolExecutionContext for sub-agent inheritance and event propagation. The context parameter is optional to maintain compatibility with standard tools.
Parameters
Section titled “Parameters”params
Section titled “params”Record<string, unknown>
The tool parameters from the model
context?
Section titled “context?”Optional execution context for agent features
Returns
Section titled “Returns”Promise<unknown>
Promise resolving to the tool result
Example
Section titled “Example”const contextAwareRun: ContextAwareToolRun = async (params, context) => { if (context?.onSubagentEvent) { // This tool can spawn sub-agents context.onSubagentEvent({ type: 'subagent_start', subagentId: 'sub-123', subagentType: 'explorer', parentToolCallId: context.toolCallId, prompt: 'Explore the codebase', timestamp: Date.now(), }); } return 'result';};