Open
Description
We should add a LanguageModelThinkingPart
to handle thinking tokens. This would stream out of LanguageModelChat, and then stream out of chat participants, show up in the chat response history, and the LanguageModelChat request. They could be displayed in the UI, so they get their own part, rather than building on LanguageModelExtraDataPart.
- Anthropic: in "extended thinking with tool use", thinking/redacted tokens are required to be captured and returned in the next request, along with a signature https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking#understanding-thinking-blocks. But otherwise, thinking tokens can be discarded. Thinking tokens can also be 'redacted'
- OpenAI: reasoning tokens are not returned
- DeepSeek/other models (?): reasoning tokens are streamed in a simple format, and do not need to be included in the next request
// Redacted thinking tokens in Anthropic could use LanguageModelExtraDataPart, since they won't be displayed.
// "thinking" or "reasoning"? Different models use one or the other.
export class LanguageModelThinkingPart {
thinking: string;
// for Anthropic, to track signature
metadata?: any;
constructor(thinking: string, metadata?: any);
}