Skip to content

RunContext

A context object that is passed to the Runner.run() method.

Type Parameter Default type

TContext

UnknownContext

new RunContext<TContext>(context?): RunContext<TContext>;
Parameter Type

context

TContext

RunContext<TContext>

context: TContext;

The context object you passed to the Runner.run() method.


optional toolInput: unknown;

Structured input for the current agent tool run, when available.


usage: Usage;

The usage of the agent run so far. For streamed responses, the usage will be updated in real-time

approveTool(approvalItem, options?): void;

Approve a tool call.

Parameter Type Description

approvalItem

RunToolApprovalItem

The tool approval item to approve.

options

{ alwaysApprove?: boolean; }

Additional approval behavior options.

options.alwaysApprove?

boolean

void


getRejectionMessage(toolName, callId): string | undefined;

Retrieve the caller-provided rejection message for a specific tool call.

Parameter Type Description

toolName

string

The name of the tool.

callId

string

The call ID of the tool invocation.

string | undefined

The message string if one was provided, undefined otherwise.


isToolApproved(approval): boolean | undefined;

Check if a tool call has been approved.

Parameter Type Description

approval

{ callId: string; toolName: string; }

Details about the tool call being evaluated.

approval.callId

string

approval.toolName

string

boolean | undefined

true if the tool call has been approved, false if blocked and undefined if not yet approved or rejected.


rejectTool(approvalItem, __namedParameters?): void;

Reject a tool call.

Parameter Type Description

approvalItem

RunToolApprovalItem

The tool approval item to reject.

__namedParameters

{ alwaysReject?: boolean; message?: string; }

__namedParameters.alwaysReject?

boolean

__namedParameters.message?

string

void


toJSON(): RunContextJson;

RunContextJson