better interleaved thinking support (#5298)

This commit is contained in:
Aiden Cline
2025-12-09 14:32:12 -08:00
committed by GitHub
parent 0aa3e6c270
commit df64612d54
12 changed files with 414 additions and 1219 deletions

View File

@@ -273,7 +273,23 @@ export namespace ProviderTransform {
return options
}
export function providerOptions(model: Provider.Model, options: { [x: string]: any }) {
export function providerOptions(model: Provider.Model, options: { [x: string]: any }, messages: ModelMessage[]) {
if (model.capabilities.interleaved && typeof model.capabilities.interleaved === "object") {
const cot = []
const assistantMessages = messages.filter((msg) => msg.role === "assistant")
for (const msg of assistantMessages) {
for (const part of msg.content) {
if (typeof part === "string") {
continue
}
if (part.type === "reasoning") {
cot.push(part)
}
}
}
options[model.capabilities.interleaved.field] = cot
}
switch (model.api.npm) {
case "@ai-sdk/openai":
case "@ai-sdk/azure":