StreamedRunResult
The result of an agent run in streaming mode.
Extends
Section titled “Extends”RunResultBase
<TContext
,TAgent
>
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
|
|
Implements
Section titled “Implements”AsyncIterable
<RunStreamEvent
>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StreamedRunResult<TContext, TAgent>(result): StreamedRunResult<TContext, TAgent>
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
{ |
|
|
|
|
Returns
Section titled “Returns”StreamedRunResult
<TContext
, TAgent
>
Overrides
Section titled “Overrides”RunResultBase<TContext, TAgent>.constructor
Properties
Section titled “Properties”currentTurn
Section titled “currentTurn”currentTurn: number = 0;
The current turn number
maxTurns
Section titled “maxTurns”maxTurns: undefined | number;
The maximum number of turns that can be run
readonly state: RunState<TContext, TAgent>;
The state of the run.
Inherited from
Section titled “Inherited from”RunResultBase.state
Accessors
Section titled “Accessors”cancelled
Section titled “cancelled”Get Signature
Section titled “Get Signature”get cancelled(): boolean
Returns true if the stream has been cancelled.
Returns
Section titled “Returns”boolean
completed
Section titled “completed”Get Signature
Section titled “Get Signature”get completed(): Promise<void>
Await this promise to ensure that the stream has been completed if you are not consuming the stream directly.
Returns
Section titled “Returns”Promise
<void
>
currentAgent
Section titled “currentAgent”Get Signature
Section titled “Get Signature”get currentAgent(): undefined | TAgent
The current agent that is running
Returns
Section titled “Returns”undefined
| TAgent
Get Signature
Section titled “Get Signature”get error(): unknown
Error thrown during the run, if any.
Returns
Section titled “Returns”unknown
finalOutput
Section titled “finalOutput”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”undefined
| ResolvedAgentOutput
<TAgent
["outputType"
]>
Inherited from
Section titled “Inherited from”RunResultBase.finalOutput
history
Section titled “history”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”RunResultBase.history
Get Signature
Section titled “Get Signature”get input(): | string | AgentInputItem[]
A copy of the original input items.
Returns
Section titled “Returns”| string
| AgentInputItem
[]
Inherited from
Section titled “Inherited from”RunResultBase.input
inputGuardrailResults
Section titled “inputGuardrailResults”Get Signature
Section titled “Get Signature”get inputGuardrailResults(): InputGuardrailResult[]
Guardrail results for the input messages.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”RunResultBase.inputGuardrailResults
interruptions
Section titled “interruptions”Get Signature
Section titled “Get Signature”get interruptions(): RunToolApprovalItem[]
Any interruptions that occurred during the agent run for example for tool approvals.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”RunResultBase.interruptions
lastAgent
Section titled “lastAgent”Get Signature
Section titled “Get Signature”get lastAgent(): undefined | TAgent
The last agent that was run
Returns
Section titled “Returns”undefined
| TAgent
Inherited from
Section titled “Inherited from”RunResultBase.lastAgent
lastResponseId
Section titled “lastResponseId”Get Signature
Section titled “Get Signature”get lastResponseId(): undefined | string
The last response ID generated by the model during the agent run.
Returns
Section titled “Returns”undefined
| string
Inherited from
Section titled “Inherited from”RunResultBase.lastResponseId
newItems
Section titled “newItems”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”RunItem
[]
Inherited from
Section titled “Inherited from”RunResultBase.newItems
output
Section titled “output”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”RunResultBase.output
outputGuardrailResults
Section titled “outputGuardrailResults”Get Signature
Section titled “Get Signature”get outputGuardrailResults(): OutputGuardrailResult<OutputGuardrailMetadata, "text">[]
Guardrail results for the final output of the agent.
Returns
Section titled “Returns”OutputGuardrailResult
<OutputGuardrailMetadata
, "text"
>[]
Inherited from
Section titled “Inherited from”RunResultBase.outputGuardrailResults
rawResponses
Section titled “rawResponses”Get Signature
Section titled “Get Signature”get rawResponses(): ModelResponse[]
The raw LLM responses generated by the model during the agent run.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”RunResultBase.rawResponses
Methods
Section titled “Methods”[asyncIterator]()
Section titled “[asyncIterator]()”asyncIterator: AsyncIterator<RunStreamEvent>
Returns
Section titled “Returns”AsyncIterator
<RunStreamEvent
>
Implementation of
Section titled “Implementation of”AsyncIterable.[asyncIterator]
toStream()
Section titled “toStream()”toStream(): ReadableStream<RunStreamEvent>
Returns the underlying readable stream.
Returns
Section titled “Returns”ReadableStream
<RunStreamEvent
>
A readable stream of the agent run.
toTextStream()
Section titled “toTextStream()”Call Signature
Section titled “Call Signature”toTextStream(): ReadableStream<string>
Returns a readable stream of the final text output of the agent run.
Returns
Section titled “Returns”ReadableStream
<string
>
A readable stream of the final output of the agent run.
Call Signature
Section titled “Call Signature”toTextStream(options?): Readable
Returns a readable stream of the final text output of the agent run.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
{ |
Options for the stream. |
|
|
Whether to use Node.js streams or web standard streams. |
Returns
Section titled “Returns”Readable
A readable stream of the final output of the agent run.
Call Signature
Section titled “Call Signature”toTextStream(options?): ReadableStream<string>
Returns a readable stream of the final text output of the agent run.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
{ |
Options for the stream. |
|
|
Whether to use Node.js streams or web standard streams. |
Returns
Section titled “Returns”ReadableStream
<string
>
A readable stream of the final output of the agent run.