Skip to content

Comments

fix(ai): Unexpected reasoning-start event in extract reasoning middleware#7107

Merged
lgrammel merged 1 commit intovercel:mainfrom
DeJeune:fix/unexpected-reasoning-start-event
Jul 8, 2025
Merged

fix(ai): Unexpected reasoning-start event in extract reasoning middleware#7107
lgrammel merged 1 commit intovercel:mainfrom
DeJeune:fix/unexpected-reasoning-start-event

Conversation

@DeJeune
Copy link
Contributor

@DeJeune DeJeune commented Jul 7, 2025

Background

If the extract reasoning middleware is used when making a request but the model's response does not include <think></think> tags, the middleware will generate an unexpected reasoning-start event.

Summary

Ensure that the reasoning-start event is only emitted in real reasoning mode.

Tasks

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • Formatting issues have been fixed (run pnpm prettier-fix in the project root)

Comment on lines +700 to 704
"id": "1",
"providerMetadata": undefined,
"text": "</think>",
"type": "text",
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(wondering if there is another bug hidden here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this test case and fix, when startWithReasoning equals false, only one reasoning-start event should be sent. Theoretically, there shouldn't be any bug.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for checking!

@lgrammel lgrammel merged commit af1d5a5 into vercel:main Jul 8, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants