AgentRunResult
AgentRunResult<
Tools,TOutput> =object
Defined in: packages/core/src/agent/types.ts:272
Result of one agent.run / agent.stream turn (possibly several model requests).
text / output: the final model response. Intermediate tool-call requests
are in messages / newMessages and as agent_tool_call / agent_tool_result
events — not in text. A tool whose execute returns an AsyncIterable (streaming
progress, e.g. a long-running shell command) emits an agent_tool_result per yielded
value plus one more (see that event’s own doc comment), each preliminary: true except
the last — none of the preliminary ones reach messages / newMessages or the model
itself, only the final one does.
output: typed payload from AgentDefinition.outputSchema
(or a per-call override). When no schema is set, this is the same string as text.
When a schema is set, this is the AI SDK’s complete parse of the final answer
text. A schema plus tools does not send a JSON response format on the tool
loop (that combination makes some models skip the tools and emit a minimal
object). If that loop stops with text that is not schema JSON, one tool-free
follow-up call parses into output, and text is that follow-up. The run
rejects with NoObjectGeneratedError — raw model text on the error’s text
field, and on agent_failed — when the answer is not JSON matching the
schema. Zod field defaults apply only to a JSON object that parsed; they do
not turn prose or a partial parse into a successful result. A stopWhen
that ends on a tool call fails the same way and does not run the follow-up.
Type Parameters
Section titled “Type Parameters”Tools extends ToolSet = ToolSet
TOutput
Section titled “TOutput”TOutput = string
Properties
Section titled “Properties”memoryScope
Section titled “memoryScope”memoryScope:
string
Defined in: packages/core/src/agent/types.ts:281
Scope this episode persisted to (caller-supplied or a generated id).
messages
Section titled “messages”messages:
ModelMessage[]
Defined in: packages/core/src/agent/types.ts:275
newMessages
Section titled “newMessages”newMessages:
ModelMessage[]
Defined in: packages/core/src/agent/types.ts:277
All model/tool messages appended during this turn (every request).
output
Section titled “output”output:
TOutput
Defined in: packages/core/src/agent/types.ts:274
sdk:
AgentSdkStreamResult<Tools>
Defined in: packages/core/src/agent/types.ts:283
Raw AI SDK stream result for this episode.
text:
string
Defined in: packages/core/src/agent/types.ts:273
turns:
number
Defined in: packages/core/src/agent/types.ts:279
Number of AI SDK steps (model requests) made during this turn.
usage?
Section titled “usage?”
optionalusage?:TokenUsage
Defined in: packages/core/src/agent/types.ts:288
Provider-reported token totals for this episode (streamText.totalUsage).
Absent when the provider did not report usage.