Skip to content

DefaultToolExecutor

Default tool executor extracted from Runtime.wrapToolsWithEnforcement().

Handles:

  • Enforcement checks via ToolEnforcer
  • Idempotency key generation
  • Context enrichment (experimental_context)
  • Error propagation via HookRunner
new DefaultToolExecutor(config): DefaultToolExecutor;
Parameter Type

config

DefaultToolExecutorConfig

DefaultToolExecutor

buildIdempotencyKey(args): string;

Build a deterministic idempotency key for external side-effect deduplication.

Parameter Type

args

{ agentId: string; sessionId: string; step: number; toolCallId: string; toolName: string; }

args.agentId

string

args.sessionId

string

args.step

number

args.toolCallId

string

args.toolName

string

string

ToolExecutor.buildIdempotencyKey


execute(args): Promise<unknown>;

Execute a single tool call with enforcement checks and context enrichment. Returns the tool’s result or throws if blocked/failed.

Parameter Type

args

{ abortSignal?: AbortSignal; agentId: string; input: unknown; session: Session; step?: number; tool: ExecutableTool; toolCallHistory?: ToolCallRecord[]; toolCallId?: string; toolName: string; turn?: number; userId?: string; }

args.abortSignal?

AbortSignal

args.agentId

string

args.input

unknown

args.session

Session

args.step?

number

args.tool

ExecutableTool

args.toolCallHistory?

ToolCallRecord[]

args.toolCallId?

string

args.toolName

string

args.turn?

number

args.userId?

string

Promise<unknown>

ToolExecutor.execute