AgentRun
Defined in: agent/src/agent/agent.run.ts:97
Drives a single agent run over the OpenAI chat API: streams model output, executes tool calls, and appends everything to the latest prompt in the transcript. When an action interrupts, the run suspends and can be continued via AgentRun.resume or AgentRun.reject. Emits AgentRunEvents. All state lives on the prompt, so a run reconstructed over persisted prompts behaves like the original.
Extends
Section titled “Extends”EventEmitter<AgentRunEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AgentRun(options): AgentRun;Defined in: agent/src/agent/agent.run.ts:101
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
AgentRunOptions |
Returns
Section titled “Returns”AgentRun
Overrides
Section titled “Overrides”EventEmitter<AgentRunEvents>.constructorAccessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get state(): AgentRunState;Defined in: agent/src/agent/agent.run.ts:116
The run’s current position, read from the prompt itself: interrupted
when a tool call’s latest interrupt has no resolution yet, ready
otherwise. Works on a freshly constructed run over persisted prompts.
Returns
Section titled “Returns”Methods
Section titled “Methods”emit()
Section titled “emit()”emit<K>(event, ...args): void;Defined in: core/src/utils/utils.eventemitter.ts:62
Invokes all listeners for event synchronously, without awaiting async listeners.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof AgentRunEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
K |
…args |
Parameters<AgentRunEvents[K]> |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EventEmitter.emitemitAsync()
Section titled “emitAsync()”emitAsync<K>(event, ...args): Promise<void>;Defined in: core/src/utils/utils.eventemitter.ts:73
Invokes all listeners for event and awaits them concurrently via Promise.all.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof AgentRunEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
K |
…args |
Parameters<AgentRunEvents[K]> |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”EventEmitter.emitAsyncon<K>( event, callback, options?): () => void;Defined in: core/src/utils/utils.eventemitter.ts:21
Registers callback for event. Returns an unsubscribe function; passing
options.abortSignal also removes the listener when that signal aborts.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof AgentRunEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
K |
callback |
EventListener<Parameters<AgentRunEvents[K]>> |
options |
OnOptions |
Returns
Section titled “Returns”() => void
Inherited from
Section titled “Inherited from”EventEmitter.ononce()
Section titled “once()”once<K>( event, callback, options?): () => void;Defined in: core/src/utils/utils.eventemitter.ts:45
Like on, but the listener is removed after firing once.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof AgentRunEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
K |
callback |
EventListener<Parameters<AgentRunEvents[K]>> |
options |
OnOptions |
Returns
Section titled “Returns”() => void
Inherited from
Section titled “Inherited from”EventEmitter.oncereject()
Section titled “reject()”reject(error): Promise<AgentRunResult>;Defined in: agent/src/agent/agent.run.ts:149
Answer the pending interrupt: skip the suspended tool call, recording error as its failure, then continue.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
error |
unknown |
Returns
Section titled “Returns”Promise<AgentRunResult>
resume()
Section titled “resume()”resume(data?): Promise<AgentRunResult>;Defined in: agent/src/agent/agent.run.ts:143
Answer the pending interrupt: re-run the suspended tool call with data as its resumption, then continue.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data? |
unknown |
Returns
Section titled “Returns”Promise<AgentRunResult>
run(): Promise<AgentRunResult>;Defined in: agent/src/agent/agent.run.ts:135
Run the agent: call the model and execute tool calls until no more are
requested, then resolve as completed (or interrupted if an action
suspends the run). Throws when the run is already suspended — use
AgentRun.resume or AgentRun.reject instead.
Returns
Section titled “Returns”Promise<AgentRunResult>