コンテンツにスキップ

RunState

このコンテンツはまだ日本語訳がありません。

Serializable snapshot of an agent’s run, including context, usage and trace. While this class has publicly writable properties (prefixed with _), they are not meant to be used directly. To read these properties, use the RunResult instead.

Manipulation of the state directly can lead to unexpected behavior and should be avoided. Instead, use the approve and reject methods to interact with the state.

Type Parameter

TContext

TAgent extends Agent<any, any>

new RunState<TContext, TAgent>(
context,
originalInput,
startingAgent,
maxTurns): RunState<TContext, TAgent>;
Parameter Type

context

RunContext<TContext>

originalInput

| string | AgentInputItem[]

startingAgent

TAgent

maxTurns

number | null

RunState<TContext, TAgent>

_agentToolInvocation:
| Readonly<{
toolArguments?: string;
toolCallId?: string;
toolName: string;
}>
| undefined;

Runtime-only metadata for the current nested agent-tool invocation.


_context: RunContext<TContext>;

Run context tracking approvals, usage, and other metadata.


_conversationId: string | undefined;

Conversation identifier when the server manages conversation history.


_currentAgent: TAgent;

The agent currently handling the conversation.


_currentAgentSpan:
| Span<AgentSpanData>
| undefined;

Active tracing span for the current agent if tracing is enabled.


_currentStep:
| {
newAgent: any;
type: "next_step_handoff";
}
| {
output: string;
type: "next_step_final_output";
}
| {
type: "next_step_run_again";
}
| {
data: Record<string, any>;
type: "next_step_interruption";
}
| undefined = undefined;

Next step computed for the agent to take.


_currentTurn: number = 0;

Current turn number in the conversation.


_currentTurnBlockedSessionStartIndex: number | undefined;

First current-turn index governed by the sparse blocked-output session suffix.


_currentTurnDeferredSessionItemIndexes: Set<number>;

Current-turn item indexes intentionally deferred when a blocked output persisted only a replay-safe subset. A later accepted resume replaces the sparse suffix in original order.


_currentTurnInProgress: boolean = false;

Whether the current turn has already been counted (useful when resuming mid-turn).


_currentTurnPersistedItemCount: number;

Number of _generatedItems already flushed to session storage for the current turn.

Persisting the entire turn on every save would duplicate responses and tool outputs. Instead, saveToSession appends only the delta since the previous write. This counter tracks how many generated run items from this turn were already written so the next save can slice off only the new entries. When a turn is interrupted (e.g., awaiting tool approval) and later resumed, we rewind the counter before continuing so the pending tool output still gets stored.


_currentTurnSessionHistoryTransactionCanReplaceAcceptedOutput

Section titled “_currentTurnSessionHistoryTransactionCanReplaceAcceptedOutput”
_currentTurnSessionHistoryTransactionCanReplaceAcceptedOutput: boolean | undefined;

Whether the current live batch may later replace its sparse suffix with accepted output.


_currentTurnSessionHistoryTransactionInputItems

Section titled “_currentTurnSessionHistoryTransactionInputItems”
_currentTurnSessionHistoryTransactionInputItems:
| AgentInputItem[]
| undefined;

Normalized session input frozen before the current transaction-aware model request.


_currentTurnSessionHistoryTransactionSessionId

Section titled “_currentTurnSessionHistoryTransactionSessionId”
_currentTurnSessionHistoryTransactionSessionId: string | undefined;

Logical session bound to the current turn before a transaction-aware tool effect can occur.


_currentTurnSessionReasoningItemIdPolicy:
| ReasoningItemIdPolicy
| undefined;

Effective reasoning-item ID policy frozen for the current transaction-aware session turn.


_finalOutputSource: FinalOutputSource | undefined;

Indicates how the final output was produced for the current run. This value is not serialized.


_generatedItems: RunItem[];

Items generated by the agent during the run.


_inputGuardrailResults: InputGuardrailResult[];

Results from input guardrails applied to the run.


_lastModelSettings:
| ModelSettings
| undefined;

Effective model settings used for the most recent model call.


_lastProcessedResponse: ProcessedResponse<TContext> | undefined = undefined;

Parsed model response after applying guardrails and tools.


_lastTurnResponse:
| ModelResponse
| undefined;

Last model response for the previous turn.


_maxTurns: number | null;

Maximum allowed turns before forcing termination.


_modelResponses: ModelResponse[];

Responses from the model so far.


_noActiveAgentRun: boolean = true;

Whether the run has an active agent step in progress.


_originalInput:
| string
| AgentInputItem[];

Original user input prior to any processing.


_outputGuardrailResults: OutputGuardrailResult<any, any>[];

Results from output guardrails applied to the run.


_pendingAgentToolRunAliases: Map<string, string>;

Legacy pending-run keys mapped to their canonical category-aware keys.


_pendingAgentToolRuns: Map<string, string>;

Serialized pending nested agent runs keyed by tool name and call id.


_pendingLegacyCompactionSessionItems:
| AgentInputItem[]
| undefined;

Compaction marker and persisted suffix that an ordinary session must reconcile once after a pre-1.16 snapshot is restored. The field remains serialized until reconciliation succeeds.


_pendingSessionHistoryTransaction:
| {
alreadyPersistedCount: number;
deferredItemIndexes: number[];
operationId: string;
persistedItemCount: number;
replaceRunItemIndexes: number[];
runItemIndexes: number[];
transactionKind: "blocked_append" | "accepted_replace";
}
| undefined;

Transaction reconstruction data awaiting confirmation from the session backend. Its generated-item indexes, operation identity, and post-commit bookkeeping remain stable across retries on the same live RunState; input stays in the separately frozen current-turn snapshot.


_previousResponseId: string | undefined;

Latest response identifier returned by the server for server-managed conversations.


_reasoningItemIdPolicy:
| ReasoningItemIdPolicy
| undefined;

Runtime options that control how run items are converted into model turn input. This value is serialized so resumed runs keep the same turn-input behavior.


_sandbox:
| {
backendId: string;
currentAgentKey: string;
currentAgentName: string;
sessionsByAgent: Record<string, {
backendId: string;
currentAgentKey: string;
currentAgentName: string;
preservedOwnedSession?: boolean;
reuseLiveSession?: boolean;
sessionState: {
backendId: string;
exposedPorts?: Record<string, any>;
manifest: Record<string, any>;
providerState: Record<string, any>;
snapshot?: Record<string, any> | null;
snapshotFingerprint?: string | null;
snapshotFingerprintVersion?: string | null;
version: 1 | 2 | 3;
workspaceReady: boolean;
};
}>;
sessionState: {
backendId: string;
exposedPorts?: Record<string, any>;
manifest: Record<string, any>;
providerState: Record<string, any>;
snapshot?: Record<string, any> | null;
snapshotFingerprint?: string | null;
snapshotFingerprintVersion?: string | null;
version: 1 | 2 | 3;
workspaceReady: boolean;
};
}
| undefined = undefined;

Persisted sandbox session metadata for sandbox-agent resume.


_serializedCurrentStep:
| {
newAgent: any;
type: "next_step_handoff";
}
| {
output: string;
type: "next_step_final_output";
}
| {
type: "next_step_run_again";
}
| {
data: Record<string, any>;
type: "next_step_interruption";
}
| undefined;

Current step reconstructed from serialized state. This reference is not serialized and is cleared implicitly when the live runner installs another step.


_sessionHistoryTransactionId: string;

Stable per-run identifier used to derive idempotent session history transaction IDs.


_toolInputGuardrailResults: ToolInputGuardrailResult[];

Results from tool input guardrails applied during tool execution.


_toolOutputGuardrailResults: ToolOutputGuardrailResult[];

Results from tool output guardrails applied during tool execution.


_toolSearchRuntimeToolsByAgent: Map<Agent<any, any>, ToolSearchRuntimeToolState<TContext>>;

Runtime-only tool_search-loaded tools, scoped by agent object and preserved across turns for the lifetime of this in-memory run.


_toolUseTracker: AgentToolUseTracker;

Tracks what tools each agent has used.


_trace: Trace | null = null;

Trace associated with this run if tracing is enabled.

get currentAgent(): TAgent;

Returns the agent currently handling the run.

TAgent


get history(): AgentInputItem[];

The history of the agent run. This includes the input items and the new items generated during the run.

This can be used as inputs for the next agent run.

AgentInputItem[]


get usage(): Usage;

The usage aggregated for this run. This includes per-request breakdowns when available.

Usage

approve(approvalItem, options?): void;

Approves a tool call requested by the agent through an interruption and approval item request.

To approve the request use this method and then run the agent again with the same state object to continue the execution.

By default it will only approve the current tool call. To allow the tool to be used multiple times throughout the run, set the alwaysApprove option to true.

Parameter Type Description

approvalItem

RunToolApprovalItem

The tool call approval item to approve.

options

{ alwaysApprove?: boolean; }

Options for the approval.

options.alwaysApprove?

boolean

Approve this tool for all future calls in this run.

void


clearPendingAgentToolRun(toolName, callId): void;
Parameter Type

toolName

string

callId

string

void


clearTrace(): void;

Clears the restored trace and current agent span from this run state.

Use this before resuming a serialized state when the resumed run should attach to the current ambient trace instead of the trace persisted in the state.

void


getInterruptions(): RunToolApprovalItem[];

Returns all interruptions if the current step is an interruption otherwise returns an empty array.

RunToolApprovalItem[]


getPendingAgentToolRun(toolName, callId): string | undefined;
Parameter Type

toolName

string

callId

string

string | undefined


getToolSearchRuntimeTools(agent): Tool<TContext>[];
Parameter Type

agent

Agent<any, any>

Tool<TContext>[]


getToolSearchRuntimeToolsForOutput(agent, toolSearchOutput): Tool<TContext>[];
Parameter Type Description

agent

Agent<any, any>

toolSearchOutput

{ call_id?: string | null; callId?: string | null; execution?: "client" | "server"; id?: string; providerData?: Record<string, any>; status?: string; tools: Record<string, any>[]; type: "tool_search_output"; }

toolSearchOutput.call_id?

string | null

toolSearchOutput.callId?

string | null

toolSearchOutput.execution?

"client" | "server"

toolSearchOutput.id?

string

An ID to identify the item. This is optional by default. If a model provider absolutely requires this field, it will be validated on the model level.

toolSearchOutput.providerData?

Record<string, any>

Additional optional provider specific data. Used for custom functionality or model provider specific fields.

toolSearchOutput.status?

string

toolSearchOutput.tools

Record<string, any>[]

toolSearchOutput.type

"tool_search_output"

Tool<TContext>[]


hasPendingAgentToolRun(toolName, callId): boolean;
Parameter Type

toolName

string

callId

string

boolean


recordToolSearchRuntimeTools(
agent,
toolSearchOutput,
tools): void;
Parameter Type Description

agent

Agent<any, any>

toolSearchOutput

{ call_id?: string | null; callId?: string | null; execution?: "client" | "server"; id?: string; providerData?: Record<string, any>; status?: string; tools: Record<string, any>[]; type: "tool_search_output"; }

toolSearchOutput.call_id?

string | null

toolSearchOutput.callId?

string | null

toolSearchOutput.execution?

"client" | "server"

toolSearchOutput.id?

string

An ID to identify the item. This is optional by default. If a model provider absolutely requires this field, it will be validated on the model level.

toolSearchOutput.providerData?

Record<string, any>

Additional optional provider specific data. Used for custom functionality or model provider specific fields.

toolSearchOutput.status?

string

toolSearchOutput.tools

Record<string, any>[]

toolSearchOutput.type

"tool_search_output"

tools

Tool<TContext>[]

void


reject(approvalItem, options?): void;

Rejects a tool call requested by the agent through an interruption and approval item request.

To reject the request use this method and then run the agent again with the same state object to continue the execution.

By default it will only reject the current tool call. To reject the tool for all future calls throughout the run, set the alwaysReject option to true.

When message is provided, it is used as the rejection text sent to the model. Otherwise, toolErrorFormatter (if configured) or the SDK default is used.

Parameter Type Description

approvalItem

RunToolApprovalItem

The tool call approval item to reject.

options

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

Options for the rejection.

options.alwaysReject?

boolean

Reject this tool for all future calls in this run.

options.message?

string

The rejection text sent to the model. If not provided, toolErrorFormatter (if configured) or the SDK default is used.

void


resetTurnPersistence(): void;

Resets the counter that tracks how many items were persisted for the current turn.

void


rewindTurnPersistence(count): void;

Rewinds the persisted item counter when pending approvals require re-writing outputs.

Parameter Type

count

number

void


setConversationContext(conversationId?, previousResponseId?): void;

Updates server-managed conversation identifiers as a single operation.

Parameter Type

conversationId?

string

previousResponseId?

string

void


setCurrentAgent(agent): void;

Switches the active agent handling the run.

Parameter Type

agent

TAgent

void


setCurrentAgentSpan(span?): void;

Updates the agent span associated with the current run.

Parameter Type

span?

Span<AgentSpanData>

void


setPendingAgentToolRun(
toolName,
callId,
serializedState,
aliases?): void;
Parameter Type Default value

toolName

string

undefined

callId

string

undefined

serializedState

string

undefined

aliases

readonly string[]

[]

void


setReasoningItemIdPolicy(policy?): void;

Updates runtime options for converting run items into turn input.

Parameter Type

policy?

ReasoningItemIdPolicy

void


toJSON(options?): object;

Serializes the run state. By default, tracing API keys are omitted to prevent accidental persistence of secrets. Pass includeTracingApiKey: true only when you intentionally need to migrate a run along with its tracing credentials (e.g., to rehydrate in a separate process that lacks the original environment variables).

Parameter Type

options

{ includeTracingApiKey?: boolean; }

options.includeTracingApiKey?

boolean

object

$schemaVersion:
| "1.0"
| "1.1"
| "1.2"
| "1.3"
| "1.4"
| "1.5"
| "1.6"
| "1.7"
| "1.8"
| "1.9"
| "1.10"
| "1.11"
| "1.12"
| "1.13"
| "1.14"
| "1.15"
| "1.16"
| "1.17"
| "1.18";
context: object;
approvals: Record<string, {
approved: boolean | string[];
messages?: Record<string, string>;
rejected: boolean | string[];
stickyRejectMessage?: string;
}>;
context: Record<string, any>;
optional functionApprovals?: object[];
optional legacyFunctionApprovals?: Record<string, {
approved: boolean | string[];
messages?: Record<string, string>;
rejected: boolean | string[];
stickyRejectMessage?: string;
}>;
optional toolInput?: any;
usage: object = usageSchema;
inputTokens: number;
optional inputTokensDetails?: Record<string, number>[];
outputTokens: number;
optional outputTokensDetails?: Record<string, number>[];
requests: number;
optional requestUsageEntries?: object[];
totalTokens: number;
optional conversationId?: string;
currentAgent: object = serializedAgentSchema;
optional identity?: string;
name: string;
optional currentAgentSpan?: SerializedSpanType | null;
optional currentStep?:
| {
newAgent: any;
type: "next_step_handoff";
}
| {
output: string;
type: "next_step_final_output";
}
| {
type: "next_step_run_again";
}
| {
data: Record<string, any>;
type: "next_step_interruption";
};
currentTurn: number;
optional currentTurnBlockedSessionStartIndex?: number;
optional currentTurnDeferredSessionItemIndexes?: number[];
optional currentTurnExecutedWithSessionBinding?: true;
optional currentTurnInProgress?: boolean;
optional currentTurnPersistedItemCount?: number;
optional currentTurnSessionInputItems?: (
| {
content: (
| {
providerData?: Record<string, any>;
refusal: string;
type: "refusal";
}
| {
providerData?: Record<string, any>;
text: string;
type: "output_text";
}
| {
audio: | string
| {
id: string;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: "explicit";
};
providerData?: Record<string, any>;
transcript?: string | null;
type: "audio";
}
| {
image: string;
providerData?: Record<string, any>;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
}
| {
content: | string
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
}
| {
audio: | string
| {
id: ...;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
transcript?: string | null;
type: "audio";
})[];
id?: string;
providerData?: Record<string, any>;
role: "user";
type?: "message";
}
| {
content: string;
id?: string;
providerData?: Record<string, any>;
role: "system";
type?: "message";
}
| {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
}
| {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: string | Uint8Array<...>;
mediaType?: string;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: string | Uint8Array<...>;
filename: string;
mediaType: string;
}
| {
filename?: string;
url: string;
}
| {
filename?: string;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
callId: string;
id?: string;
output: {
data: string;
providerData?: Record<string, any>;
type: "computer_screenshot";
};
providerData?: Record<string, any>;
type: "computer_call_result";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
}
| {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
}
| {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
}
| {
id?: string;
providerData?: Record<string, any>;
type: "unknown";
})[];
generatedItems: (
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
content: (
| {
providerData?: Record<string, any>;
refusal: string;
type: "refusal";
}
| {
providerData?: Record<string, any>;
text: string;
type: "output_text";
}
| {
audio: | string
| {
id: string;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: "explicit";
};
providerData?: Record<string, any>;
transcript?: string | null;
type: "audio";
}
| {
image: string;
providerData?: Record<string, any>;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
};
type: "message_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
};
type: "tool_search_call_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
};
type: "tool_search_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: | {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: ... | ... | ... | ... | ...;
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: ...[];
type: "keypress";
}
| {
path: ...[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
};
type: "tool_call_item";
}
| {
agent: {
identity?: string;
name: string;
};
customData?: Record<string, any>;
executionStatus?: "executed";
output: string;
rawItem: | {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: ... | ...;
mediaType?: ... | ...;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: ... | ...;
filename: string;
mediaType: string;
}
| {
filename?: ... | ...;
url: string;
}
| {
filename?: ... | ...;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
text: string;
type: "input_text";
}
| {
detail?: ... | ...;
image?: ... | ... | ...;
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
type: "input_image";
}
| {
file?: ... | ... | ... | ...;
filename?: ... | ...;
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
callId: string;
id?: string;
output: {
data: string;
providerData?: Record<string, any>;
type: "computer_screenshot";
};
providerData?: Record<string, any>;
type: "computer_call_result";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
};
type: "tool_call_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
};
type: "reasoning_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
};
type: "compaction_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
};
type: "handoff_call_item";
}
| {
rawItem: {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: string | Uint8Array<...>;
mediaType?: string;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: string | Uint8Array<...>;
filename: string;
mediaType: string;
}
| {
filename?: string;
url: string;
}
| {
filename?: string;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
};
sourceAgent: {
identity?: string;
name: string;
};
targetAgent: {
identity?: string;
name: string;
};
type: "handoff_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
functionToolStateKey?: string;
rawItem: | {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: ... | ... | ... | ... | ...;
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: ...[];
type: "keypress";
}
| {
path: ...[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
};
toolName?: string;
type: "tool_approval_item";
})[];
inputGuardrailResults: object[];
optional lastModelResponse?: object;
output: (
| {
content: (
| {
providerData?: Record<..., ...>;
refusal: string;
type: "refusal";
}
| {
providerData?: Record<..., ...>;
text: string;
type: "output_text";
}
| {
audio: | string
| {
id: ...;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
transcript?: string | null;
type: "audio";
}
| {
image: string;
providerData?: Record<..., ...>;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
}
| {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
}
| {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: ... | ...;
mediaType?: ... | ...;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: ... | ...;
filename: string;
mediaType: string;
}
| {
filename?: ... | ...;
url: string;
}
| {
filename?: ... | ...;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
text: string;
type: "input_text";
}
| {
detail?: ... | ...;
image?: ... | ... | ...;
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
type: "input_image";
}
| {
file?: ... | ... | ... | ...;
filename?: ... | ...;
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: ... | ... | ... | ... | ...;
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: ...[];
type: "keypress";
}
| {
path: ...[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
}
| {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
}
| {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
}
| {
id?: string;
providerData?: Record<string, any>;
type: "unknown";
})[];
optional providerData?: Record<string, any>;
optional requestId?: string;
optional responseId?: string;
usage: object = usageSchema;
inputTokens: number;
lastModelResponse.usage.inputTokensDetails?
Section titled “lastModelResponse.usage.inputTokensDetails?”
optional inputTokensDetails?: Record<string, number>[];
outputTokens: number;
lastModelResponse.usage.outputTokensDetails?
Section titled “lastModelResponse.usage.outputTokensDetails?”
optional outputTokensDetails?: Record<string, number>[];
requests: number;
lastModelResponse.usage.requestUsageEntries?
Section titled “lastModelResponse.usage.requestUsageEntries?”
optional requestUsageEntries?: object[];
totalTokens: number;
optional lastProcessedResponse?: object;
optional applyPatchActions?: object[];
computerActions: object[];
functions: object[];
lastProcessedResponse.functionToolsNotFound?
Section titled “lastProcessedResponse.functionToolsNotFound?”
optional functionToolsNotFound?: object[];
handoffs: object[];
lastProcessedResponse.mcpApprovalRequests?
Section titled “lastProcessedResponse.mcpApprovalRequests?”
optional mcpApprovalRequests?: object[];
newItems: (
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
content: (
| {
providerData?: ... | ...;
refusal: string;
type: "refusal";
}
| {
providerData?: ... | ...;
text: string;
type: "output_text";
}
| {
audio: ... | ...;
format?: ... | ... | ...;
promptCacheBreakpoint?: ... | ...;
providerData?: ... | ...;
transcript?: ... | ... | ...;
type: "audio";
}
| {
image: string;
providerData?: ... | ...;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
};
type: "message_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
};
type: "tool_search_call_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
};
type: "tool_search_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: | {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
action?: | {
type: "screenshot";
}
| {
button: ... | ... | ... | ... | ...;
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: ...[];
type: "keypress";
}
| {
path: ...[];
type: "drag";
};
actions?: (... | ... | ... | ... | ... | ... | ... | ... | ...)[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: ... | ...;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
};
type: "tool_call_item";
}
| {
agent: {
identity?: string;
name: string;
};
customData?: Record<string, any>;
executionStatus?: "executed";
output: string;
rawItem: | {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: ... | ...;
text: string;
type: "text";
}
| {
detail?: ... | ... | ... | ... | ...;
image?: ... | ... | ... | ... | ...;
providerData?: ... | ...;
type: "image";
}
| {
file: ... | ... | ... | ...;
providerData?: ... | ...;
type: "file";
}
| (... | ... | ...)[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
callId: string;
id?: string;
output: {
data: string;
providerData?: Record<..., ...>;
type: "computer_screenshot";
};
providerData?: Record<string, any>;
type: "computer_call_result";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
};
type: "tool_call_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
};
type: "reasoning_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
};
type: "compaction_item";
}
| {
agent: {
identity?: string;
name: string;
};
rawItem: {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
};
type: "handoff_call_item";
}
| {
rawItem: {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<..., ...>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | ... & ...;
image?: | string
| {
data: ...;
mediaType?: ...;
}
| {
url: ...;
}
| {
fileId: ...;
};
providerData?: Record<..., ...>;
type: "image";
}
| {
file: | string
| {
data: ...;
filename: ...;
mediaType: ...;
}
| {
filename?: ...;
url: ...;
}
| {
filename?: ...;
id: ...;
};
providerData?: Record<..., ...>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: ...;
providerData?: ...;
text: ...;
type: ...;
}
| {
detail?: ...;
image?: ...;
promptCacheBreakpoint?: ...;
providerData?: ...;
type: ...;
}
| {
file?: ...;
filename?: ...;
promptCacheBreakpoint?: ...;
providerData?: ...;
type: ...;
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
};
sourceAgent: {
identity?: string;
name: string;
};
targetAgent: {
identity?: string;
name: string;
};
type: "handoff_output_item";
}
| {
agent: {
identity?: string;
name: string;
};
functionToolStateKey?: string;
rawItem: | {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
action?: | {
type: "screenshot";
}
| {
button: ... | ... | ... | ... | ...;
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: ...[];
type: "keypress";
}
| {
path: ...[];
type: "drag";
};
actions?: (... | ... | ... | ... | ... | ... | ... | ... | ...)[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: ... | ...;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
};
toolName?: string;
type: "tool_approval_item";
})[];
optional shellActions?: object[];
toolsUsed: string[];
maxTurns: number | null;
modelResponses: object[];
noActiveAgentRun: boolean;
originalInput:
| string
| (
| {
content: (
| {
providerData?: Record<string, any>;
refusal: string;
type: "refusal";
}
| {
providerData?: Record<string, any>;
text: string;
type: "output_text";
}
| {
audio: | string
| {
id: string;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: "explicit";
};
providerData?: Record<string, any>;
transcript?: string | null;
type: "audio";
}
| {
image: string;
providerData?: Record<string, any>;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
}
| {
content: | string
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
}
| {
audio: | string
| {
id: ...;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
transcript?: string | null;
type: "audio";
})[];
id?: string;
providerData?: Record<string, any>;
role: "user";
type?: "message";
}
| {
content: string;
id?: string;
providerData?: Record<string, any>;
role: "system";
type?: "message";
}
| {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
}
| {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: string | Uint8Array<...>;
mediaType?: string;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: string | Uint8Array<...>;
filename: string;
mediaType: string;
}
| {
filename?: string;
url: string;
}
| {
filename?: string;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
callId: string;
id?: string;
output: {
data: string;
providerData?: Record<string, any>;
type: "computer_screenshot";
};
providerData?: Record<string, any>;
type: "computer_call_result";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
}
| {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
}
| {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
}
| {
id?: string;
providerData?: Record<string, any>;
type: "unknown";
})[];
outputGuardrailResults: object[];
pendingAgentToolRunAliases: Record<string, string>;
pendingAgentToolRuns: Record<string, string>;
optional pendingLegacyCompactionSessionItems?: (
| {
content: (
| {
providerData?: Record<string, any>;
refusal: string;
type: "refusal";
}
| {
providerData?: Record<string, any>;
text: string;
type: "output_text";
}
| {
audio: | string
| {
id: string;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: "explicit";
};
providerData?: Record<string, any>;
transcript?: string | null;
type: "audio";
}
| {
image: string;
providerData?: Record<string, any>;
type: "image";
})[];
id?: string;
phase?: "commentary" | "final_answer";
providerData?: Record<string, any>;
role: "assistant";
status: "in_progress" | "completed" | "incomplete";
type?: "message";
}
| {
content: | string
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
}
| {
audio: | string
| {
id: ...;
};
format?: string | null;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
transcript?: string | null;
type: "audio";
})[];
id?: string;
providerData?: Record<string, any>;
role: "user";
type?: "message";
}
| {
content: string;
id?: string;
providerData?: Record<string, any>;
role: "system";
type?: "message";
}
| {
callId: string;
code: string;
fingerprint: string;
id?: string;
providerData?: Record<string, any>;
type: "program";
}
| {
callId: string;
id?: string;
output: string;
providerData?: Record<string, any>;
status: "completed" | "incomplete";
type: "program_output";
}
| {
arguments?: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
id?: string;
name: string;
output?: string;
providerData?: Record<string, any>;
status?: string;
type: "hosted_tool_call";
}
| {
arguments: string;
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "function_call";
}
| {
arguments: unknown;
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
type: "tool_search_call";
}
| {
call_id?: string | null;
callId?: string | null;
execution?: "client" | "server";
id?: string;
providerData?: Record<string, any>;
status?: string;
tools: Record<string, any>[];
type: "tool_search_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
name: string;
namespace?: string;
output: | string
| {
providerData?: Record<string, any>;
text: string;
type: "text";
}
| {
detail?: "low" | "high" | "auto" | string & object;
image?: | string
| {
data: string | Uint8Array<...>;
mediaType?: string;
}
| {
url: string;
}
| {
fileId: string;
};
providerData?: Record<string, any>;
type: "image";
}
| {
file: | string
| {
data: string | Uint8Array<...>;
filename: string;
mediaType: string;
}
| {
filename?: string;
url: string;
}
| {
filename?: string;
id: string;
};
providerData?: Record<string, any>;
type: "file";
}
| (
| {
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
text: string;
type: "input_text";
}
| {
detail?: string;
image?: | string
| {
id: ...;
};
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_image";
}
| {
file?: | string
| {
id: ...;
}
| {
url: ...;
};
filename?: string;
promptCacheBreakpoint?: {
mode: ...;
};
providerData?: Record<..., ...>;
type: "input_file";
})[];
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "function_call_result";
}
| {
action?: | {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
};
actions?: (
| {
type: "screenshot";
}
| {
button: "left" | "right" | "wheel" | "back" | "forward";
type: "click";
x: number;
y: number;
}
| {
type: "double_click";
x: number;
y: number;
}
| {
scroll_x: number;
scroll_y: number;
type: "scroll";
x: number;
y: number;
}
| {
text: string;
type: "type";
}
| {
type: "wait";
}
| {
type: "move";
x: number;
y: number;
}
| {
keys: string[];
type: "keypress";
}
| {
path: object[];
type: "drag";
})[];
callId: string;
id?: string;
providerData?: Record<string, any>;
status: "in_progress" | "completed" | "incomplete";
type: "computer_call";
}
| {
callId: string;
id?: string;
output: {
data: string;
providerData?: Record<string, any>;
type: "computer_screenshot";
};
providerData?: Record<string, any>;
type: "computer_call_result";
}
| {
action: {
commands: string[];
maxOutputLength?: number;
timeoutMs?: number;
};
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
maxOutputLength?: number;
output: object[];
providerData?: Record<string, any>;
status?: "in_progress" | "completed" | "incomplete";
type: "shell_call_output";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
operation: | {
diff: string;
path: string;
type: "create_file";
}
| {
diff: string;
moveTo?: string;
path: string;
type: "update_file";
}
| {
path: string;
type: "delete_file";
};
providerData?: Record<string, any>;
status: "in_progress" | "completed";
type: "apply_patch_call";
}
| {
caller?: | {
type: "direct";
}
| {
callerId: string;
type: "program";
};
callId: string;
id?: string;
output?: string;
providerData?: Record<string, any>;
status: "completed" | "failed";
type: "apply_patch_call_output";
}
| {
content: object[];
id?: string;
providerData?: Record<string, any>;
rawContent?: object[];
type: "reasoning";
}
| {
created_by?: string;
encrypted_content: string;
id?: string;
providerData?: Record<string, any>;
type: "compaction";
}
| {
id?: string;
providerData?: Record<string, any>;
type: "unknown";
})[];
optional pendingSessionHistoryTransaction?: object;
pendingSessionHistoryTransaction.alreadyPersistedCount
Section titled “pendingSessionHistoryTransaction.alreadyPersistedCount”
alreadyPersistedCount: number;
pendingSessionHistoryTransaction.deferredItemIndexes
Section titled “pendingSessionHistoryTransaction.deferredItemIndexes”
deferredItemIndexes: number[];
pendingSessionHistoryTransaction.operationId
Section titled “pendingSessionHistoryTransaction.operationId”
operationId: string;
pendingSessionHistoryTransaction.persistedItemCount
Section titled “pendingSessionHistoryTransaction.persistedItemCount”
persistedItemCount: number;
pendingSessionHistoryTransaction.replaceRunItemIndexes
Section titled “pendingSessionHistoryTransaction.replaceRunItemIndexes”
replaceRunItemIndexes: number[];
pendingSessionHistoryTransaction.runItemIndexes
Section titled “pendingSessionHistoryTransaction.runItemIndexes”
runItemIndexes: number[];
pendingSessionHistoryTransaction.transactionKind
Section titled “pendingSessionHistoryTransaction.transactionKind”
transactionKind: "blocked_append" | "accepted_replace";
optional previousResponseId?: string;
optional reasoningItemIdPolicy?: "omit" | "preserve";
optional sandbox?: object;
backendId: string;
currentAgentKey: string;
currentAgentName: string;
sessionsByAgent: Record<string, {
backendId: string;
currentAgentKey: string;
currentAgentName: string;
preservedOwnedSession?: boolean;
reuseLiveSession?: boolean;
sessionState: {
backendId: string;
exposedPorts?: Record<string, any>;
manifest: Record<string, any>;
providerState: Record<string, any>;
snapshot?: Record<string, any> | null;
snapshotFingerprint?: string | null;
snapshotFingerprintVersion?: string | null;
version: 1 | 2 | 3;
workspaceReady: boolean;
};
}>;
sessionState: object = sandboxSessionStateEnvelopeSchema;
backendId: string;
optional exposedPorts?: Record<string, any>;
manifest: Record<string, any>;
providerState: Record<string, any>;
optional snapshot?: Record<string, any> | null;
optional snapshotFingerprint?: string | null;
sandbox.sessionState.snapshotFingerprintVersion?
Section titled “sandbox.sessionState.snapshotFingerprintVersion?”
optional snapshotFingerprintVersion?: string | null;
version: 1 | 2 | 3;
workspaceReady: boolean;
toolInputGuardrailResults: object[];
toolOutputGuardrailResults: object[];
toolUseTracker: Record<string, string[]>;
trace:
| {
group_id: string | null;
id: string;
metadata: Record<string, any>;
object: "trace";
tracing_api_key?: string | null;
workflow_name: string;
}
| null;

toString(options?): string;

Serializes the run state to a string.

This method is used to serialize the run state to a string that can be used to resume the run later.

Parameter Type

options

{ includeTracingApiKey?: boolean; }

options.includeTracingApiKey?

boolean

string

The serialized run state.


static fromString<TContext, TAgent>(initialAgent, str): Promise<RunState<TContext, TAgent>>;

Deserializes a run state from a string.

This method is used to deserialize a run state from a string that was serialized using the toString method.

Type Parameter

TContext

TAgent extends Agent<any, any>

Parameter Type

initialAgent

TAgent

str

string

Promise<RunState<TContext, TAgent>>


static fromStringWithContext<TContext, TAgent>(
initialAgent,
str,
context,
options?): Promise<RunState<TContext, TAgent>>;
Type Parameter

TContext

TAgent extends Agent<any, any>

Parameter Type

initialAgent

TAgent

str

string

context

RunContext<TContext>

options

{ contextStrategy?: ContextOverrideStrategy; }

options.contextStrategy?

ContextOverrideStrategy

Promise<RunState<TContext, TAgent>>