Skip to content

Comments

feat: add reasoning_details support#12916

Open
Astricaelus wants to merge 3 commits intoCherryHQ:mainfrom
Astricaelus:feat/or-reasoning_details
Open

feat: add reasoning_details support#12916
Astricaelus wants to merge 3 commits intoCherryHQ:mainfrom
Astricaelus:feat/or-reasoning_details

Conversation

@Astricaelus
Copy link
Contributor

What this PR does

Before this PR: reasoning_details field is not used for OpenRouter Provider, and interleaved thinking is actually not enabled for most of the models

After this PR: Use reasoning_details to pass the reasoning content back to API.

Fixes #

Why we need it and why it was done in this way

Better support for interleaved thinking, thus better prompt caching.

Breaking changes

Special notes for your reviewer

Some of the datastructures are changed.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

NONE

@Astricaelus Astricaelus marked this pull request as ready for review February 13, 2026 13:49
@Astricaelus Astricaelus changed the title feat: add reasoning_deatiles support feat: add reasoning_details support Feb 13, 2026
webSearchResults: [],
reasoningId: ''
reasoningId: '',
reasoningDetails: [] as any[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

reasoningdetails有类型我没记错的话

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reasoningdetails有类型我没记错的话

确实是有的(https://openrouter.ai/docs/guides/best-practices/reasoning-tokens#reasoning_details-array-structure),不过在通用字段外,3种子类型有各自特殊字段,未来其他模型供应商也可能会带来新的类型。我觉得如果不会对客户端造成什么安全性风险,用Any或许没什么问题?因为使用reasoning_details时,我们已经相信OpenRouter会对数据的合法性、格式对接负责了。

Comment on lines +208 to +215
/**
* Raw reasoning details from OpenRouter.
* When present, this should be saved and sent back in subsequent requests
* to allow models like Claude/Gemini to correctly resume encrypted reasoning.
* Has higher priority than other reasoning fields.
*/
reasoning_details?: any[]

Copy link
Collaborator

Choose a reason for hiding this comment

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

provider specific的数据不应该额外添加字段,应该放到providerMetadata字段中

Comment on lines +237 to +243
/**
* Raw reasoning details from OpenRouter.
* When present, this should be saved and sent back in subsequent requests
* to allow models like Claude/Gemini to correctly resume encrypted reasoning.
* Has higher priority than other reasoning fields.
*/
reasoning_details?: any[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里同样,不要额外添加字段。我们目前所有provider specific的数据都依赖上游providerMetadata处理,你可以看看openrouter aisdk provider的类型定义是否已更新

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.

3 participants