Interface: StreamTextResult
Defined in: packages/agentos/src/api/streamText.ts:110
The object returned immediately by streamText.
Consumers may iterate textStream for raw token deltas, fullStream for
all event types, or simply await the promise properties for aggregated
results once the stream has drained.
Properties
cacheDiagnostics
cacheDiagnostics:
Promise<CacheDiagnostics|null>
Defined in: packages/agentos/src/api/streamText.ts:179
Cache-diagnostics verdict of the FINAL step (Anthropic beta; see
GenerateTextOptions.cacheDiagnostics). Resolves when the stream
completes: null when the run did not opt in, when the provider sent no
verdict, or when the compared requests did not diverge; a populated
cacheMissReason names the earliest divergence. Settled in the
generator's cleanup too, so awaiting after early abandonment never hangs.
finishReason
finishReason:
Promise<StreamFinishReason>
Defined in: packages/agentos/src/api/streamText.ts:170
Resolves to the reason the FINAL model step stopped emitting, on the same cadence as usage (when the stream completes):
'stop'— natural end of turn (or an unknown provider vocabulary).'length'— the provider's output token cap cut the text off; the assembled reply is TRUNCATED mid-thought. Hosts that persist or cache streamed prose as canonical should branch on this before doing so (wilds-ai narrator truncation guard, 2026-07-08).'tool-calls'— the run ended with outstanding tool calls and no final text (maxSteps exhaustion).'error'— the stream emitted anerrorpart.
Historically the streaming surface discarded the provider's reason
and fabricated 'stop'; the provider layer always had it (final
chunk choices[0].finishReason; Anthropic maps max_tokens →
length in its adapter). Settled via the generator's cleanup on
early abandonment too, so awaiting it after a partial consume does
not hang — though like text/usage it is only meaningful after a
full drain. The prompt-shim tool-emulation path reports 'stop'
(its internal calls do not thread per-step reasons).
fullStream
fullStream:
AsyncIterable<StreamPart>
Defined in: packages/agentos/src/api/streamText.ts:114
Async iterable that yields all StreamPart events in order.
model
model:
Promise<string>
Defined in: packages/agentos/src/api/streamText.ts:147
Resolves to the resolved model id once the stream has started.
provider
provider:
Promise<string>
Defined in: packages/agentos/src/api/streamText.ts:145
Resolves to the resolved provider id (e.g. openrouter, anthropic)
once the stream has started. Available eagerly because routing happens
before the first chunk; exposed as a Promise so the type lines up with
the rest of this contract and so callers don't see undefined while the
stream is still spinning up. Used by wilds-ai's [llm-call] telemetry
line for per-step latency attribution (production fix 2026-05-05:
narrator-stream rows were logging provider=unknown model=unknown,
which made model-routing audits significantly harder).
providerMessageId
providerMessageId:
Promise<string|null>
Defined in: packages/agentos/src/api/streamText.ts:187
Provider message id (msg_...) of the FINAL step; null when the run
did not opt into cache diagnostics or the provider sent no id. Persist it
and pass it back as the next request's
cacheDiagnostics.previousMessageId to thread the comparison across
turns (the wilds-ai narrator threads it per session).
responseModel
responseModel:
Promise<string|undefined>
Defined in: packages/agentos/src/api/streamText.ts:126
Provider-reported model id of the final step (may differ from the
requested/resolved id across aliases and fallback hops; spec batch-1
C1). Settles on every terminal path — normal completion, fallback,
error, early abandonment — and is undefined when no chunk reported a
model id. The existing model-related fields keep their meaning.
serviceTier
serviceTier:
Promise<string|undefined>
Defined in: packages/agentos/src/api/streamText.ts:132
Provider-reported service tier the final step actually ran at (OpenAI;
spec batch-1 C2). Settles on every terminal path; undefined when no
chunk reported a tier.
text
text:
Promise<string>
Defined in: packages/agentos/src/api/streamText.ts:116
Resolves to the fully assembled assistant reply when the stream completes.
textStream
textStream:
AsyncIterable<string>
Defined in: packages/agentos/src/api/streamText.ts:112
Async iterable that yields only raw text-delta strings (filters out non-text parts).
toolCalls
toolCalls:
Promise<ToolCallRecord[]>
Defined in: packages/agentos/src/api/streamText.ts:134
Resolves to the ordered list of ToolCallRecords when the stream completes.
usage
usage:
Promise<TokenUsage>
Defined in: packages/agentos/src/api/streamText.ts:118
Resolves to aggregated TokenUsage when the stream completes.