Skip to content

feat: expose raw finish reason - #11338

Merged
lgrammel merged 26 commits into
mainfrom
lg/XLnRPx9o
Dec 20, 2025
Merged

feat: expose raw finish reason#11338
lgrammel merged 26 commits into
mainfrom
lg/XLnRPx9o

Conversation

@lgrammel

@lgrammel lgrammel commented Dec 20, 2025

Copy link
Copy Markdown
Collaborator

Background

When providers add new finish reasons to their API that we do not know about, they get exposed as 'unknown' / 'other'. To enable users to add custom handling until we update the providers, we need to expose the raw finish reason from the provider. This feature is also useful to distinguish mapped finish reasons further, e.g. some providers have several finish reasons that get mapped to a single code.

Summary

  • return rawFinishReason from streamText and generateText
  • merge unknown finish reason into other
  • add raw finish reason to specification
  • use PromiseLike in StreamTextResult

Manual Verification

  • run examples/ai-core/src/generate-text/openai.ts
  • run examples/ai-core/src/stream-text/openai.ts
  • run examples/ai-core/src/generate-text/anthropic.ts
  • run examples/ai-core/src/stream-text/anthropic.ts

Tasks

  • spec
  • providers
  • functions
  • reference docs
  • guide docs
  • migration guide
  • changeset

Future Work

  • codemod: removed unknown finish reason
  • add rawFinishReason to generateObject, streamObject, streamUI

@ghost ghost added the documentation Improvements or additions to documentation label Dec 20, 2025
@lgrammel lgrammel changed the title 1 feat: expose raw finish reason Dec 20, 2025
@lgrammel
lgrammel marked this pull request as ready for review December 20, 2025 14:50
@lgrammel
lgrammel merged commit cbf52cd into main Dec 20, 2025
18 checks passed
@lgrammel
lgrammel deleted the lg/XLnRPx9o branch December 20, 2025 14:57
nicoalbanese added a commit that referenced this pull request Dec 22, 2025
Submodule action broken due to unclosed string from #11338.
tsuzaki430 added a commit to tsuzaki430/ai that referenced this pull request Dec 22, 2025
tsuzaki430 added a commit to tsuzaki430/ai that referenced this pull request Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation task-merge-tracking-no-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants