Function: normalizeStreamFinishReason()
normalizeStreamFinishReason(
raw):StreamFinishReason
Defined in: packages/agentos/src/api/streamText.ts:82
Normalize a provider-reported finish reason onto the canonical StreamFinishReason union.
Providers disagree on vocabulary: OpenAI-compatible hosts emit
length / tool_calls / stop; Anthropic's adapter maps its raw
stop_reason before it reaches this layer but raw max_tokens /
tool_use / end_turn are accepted here too so a provider that
skips that mapping still normalizes. Unknown strings and null/undefined
degrade to 'stop' — the pre-existing semantics of the streaming
surface, which fabricated 'stop' unconditionally.
Parameters
raw
string | null | undefined