@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
78 lines (77 loc) • 2.46 kB
TypeScript
import { RunToolApprovalItem } from './items';
import { UnknownContext } from './types';
import { Usage } from './usage';
type ApprovalRecord = {
approved: boolean | string[];
rejected: boolean | string[];
messages?: Record<string, string>;
stickyRejectMessage?: string;
};
type RunContextJson = {
context: any;
usage: Usage;
approvals: Record<string, ApprovalRecord>;
toolInput?: unknown;
};
/**
* A context object that is passed to the `Runner.run()` method.
*/
export declare class RunContext<TContext = UnknownContext> {
#private;
/**
* The context object you passed to the `Runner.run()` method.
*/
context: TContext;
/**
* The usage of the agent run so far. For streamed responses, the usage will be updated in real-time
*/
usage: Usage;
/**
* Structured input for the current agent tool run, when available.
*/
toolInput?: unknown;
constructor(context?: TContext);
/**
* Retrieve the caller-provided rejection message for a specific tool call.
*
* @param toolName - The name of the tool.
* @param callId - The call ID of the tool invocation.
* @returns The message string if one was provided, `undefined` otherwise.
*/
getRejectionMessage(toolName: string, callId: string, options?: {
functionTool?: boolean;
}): string | undefined;
/**
* Serialize public RunContext state using the released aggregate shape.
*/
toJSON(): RunContextJson;
/**
* Check if a tool call has been approved.
*
* @param approval - Details about the tool call being evaluated.
* @returns `true` if the tool call has been approved, `false` if blocked and `undefined` if not yet approved or rejected.
*/
isToolApproved(approval: {
toolName: string;
callId: string;
}): boolean | undefined;
/**
* Approve a tool call.
*
* @param approvalItem - The tool approval item to approve.
* @param options - Additional approval behavior options.
*/
approveTool(approvalItem: RunToolApprovalItem, { alwaysApprove }?: {
alwaysApprove?: boolean;
}): void;
/**
* Reject a tool call.
*
* @param approvalItem - The tool approval item to reject.
*/
rejectTool(approvalItem: RunToolApprovalItem, { alwaysReject, message, }?: {
alwaysReject?: boolean;
message?: string;
}): void;
}
export {};