Skip to content

StreamedRunResult

The result of an agent run in streaming mode.

  • RunResultBase<TContext, TAgent>
Type Parameter

TContext

TAgent extends Agent<TContext, AgentOutputType>

new StreamedRunResult<TContext, TAgent>(result): StreamedRunResult<TContext, TAgent>
Parameter Type

result

{ signal: AbortSignal; state: RunState<TContext, TAgent>; }

result.signal?

AbortSignal

result.state

RunState<TContext, TAgent>

StreamedRunResult<TContext, TAgent>

RunResultBase<TContext, TAgent>.constructor
currentTurn: number = 0;

The current turn number


maxTurns: undefined | number;

The maximum number of turns that can be run


readonly state: RunState<TContext, TAgent>;

The state of the run.

RunResultBase.state
get cancelled(): boolean

Returns true if the stream has been cancelled.

boolean


get completed(): Promise<void>

Await this promise to ensure that the stream has been completed if you are not consuming the stream directly.

Promise<void>


get currentAgent(): undefined | TAgent

The current agent that is running

undefined | TAgent


get error(): unknown

Error thrown during the run, if any.

unknown


get finalOutput(): undefined | ResolvedAgentOutput<TAgent["outputType"]>

The final output of the agent. If the output type was set to anything other than text, this will be parsed either as JSON or using the Zod schema you provided.

undefined | ResolvedAgentOutput<TAgent["outputType"]>

RunResultBase.finalOutput

get history(): AgentInputItem[]

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

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

AgentInputItem[]

RunResultBase.history

get input():
| string
| AgentInputItem[]

A copy of the original input items.

| string | AgentInputItem[]

RunResultBase.input

get inputGuardrailResults(): InputGuardrailResult[]

Guardrail results for the input messages.

InputGuardrailResult[]

RunResultBase.inputGuardrailResults

get interruptions(): RunToolApprovalItem[]

Any interruptions that occurred during the agent run for example for tool approvals.

RunToolApprovalItem[]

RunResultBase.interruptions

get lastAgent(): undefined | TAgent

The last agent that was run

undefined | TAgent

RunResultBase.lastAgent

get lastResponseId(): undefined | string

The last response ID generated by the model during the agent run.

undefined | string

RunResultBase.lastResponseId

get newItems(): RunItem[]

The run items generated during the agent run. This associates the model data with the agents.

For the model data that can be used as inputs for the next agent run, use the output property.

RunItem[]

RunResultBase.newItems

get output(): AgentOutputItem[]

The new items generated during the agent run. These include things like new messages, tool calls and their outputs, etc.

It does not include information about the agents and instead represents the model data.

For the output including the agents, use the newItems property.

AgentOutputItem[]

RunResultBase.output

get outputGuardrailResults(): OutputGuardrailResult<OutputGuardrailMetadata, "text">[]

Guardrail results for the final output of the agent.

OutputGuardrailResult<OutputGuardrailMetadata, "text">[]

RunResultBase.outputGuardrailResults

get rawResponses(): ModelResponse[]

The raw LLM responses generated by the model during the agent run.

ModelResponse[]

RunResultBase.rawResponses
asyncIterator: AsyncIterator<RunStreamEvent>

AsyncIterator<RunStreamEvent>

AsyncIterable.[asyncIterator]

toStream(): ReadableStream<RunStreamEvent>

Returns the underlying readable stream.

ReadableStream<RunStreamEvent>

A readable stream of the agent run.


toTextStream(): ReadableStream<string>

Returns a readable stream of the final text output of the agent run.

ReadableStream<string>

A readable stream of the final output of the agent run.

toTextStream(options?): Readable

Returns a readable stream of the final text output of the agent run.

Parameter Type Description

options?

{ compatibleWithNodeStreams: true; }

Options for the stream.

options.compatibleWithNodeStreams?

true

Whether to use Node.js streams or web standard streams.

Readable

A readable stream of the final output of the agent run.

toTextStream(options?): ReadableStream<string>

Returns a readable stream of the final text output of the agent run.

Parameter Type Description

options?

{ compatibleWithNodeStreams: false; }

Options for the stream.

options.compatibleWithNodeStreams?

false

Whether to use Node.js streams or web standard streams.

ReadableStream<string>

A readable stream of the final output of the agent run.