Skip to content

Function: isContextAwareTool()

@providerprotocol/agents


@providerprotocol/agents / index / isContextAwareTool

isContextAwareTool(tool): boolean

Defined in: src/execution/tool-context.ts:146

Checks if a tool is context-aware (accepts execution context as second parameter).

Context-aware tools have a run function with arity > 1, meaning they accept the optional ToolExecutionContext parameter. This allows them to access agent information and emit sub-agent events.

Tool

The tool to check

boolean

true if the tool’s run function accepts more than one parameter

import { isContextAwareTool } from '@providerprotocol/agents/execution';
const standardTool = {
name: 'simple',
run: async (params) => 'result', // arity = 1
};
const contextTool = {
name: 'advanced',
run: async (params, context) => 'result', // arity = 2
};
isContextAwareTool(standardTool); // false
isContextAwareTool(contextTool); // true