fix(opencode): update Cerebras SDK reasoning replay (#34826)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
b3934992d1
commit
6ca60d9204
3 changed files with 86 additions and 2 deletions
|
|
@ -59,7 +59,7 @@
|
|||
"@ai-sdk/amazon-bedrock": "4.0.112",
|
||||
"@ai-sdk/anthropic": "3.0.82",
|
||||
"@ai-sdk/azure": "3.0.49",
|
||||
"@ai-sdk/cerebras": "2.0.41",
|
||||
"@ai-sdk/cerebras": "2.0.60",
|
||||
"@ai-sdk/cohere": "3.0.27",
|
||||
"@ai-sdk/deepinfra": "2.0.41",
|
||||
"@ai-sdk/gateway": "3.0.104",
|
||||
|
|
|
|||
|
|
@ -832,6 +832,80 @@ describe("session.llm.stream", () => {
|
|||
},
|
||||
)
|
||||
|
||||
const cerebrasFixture = { providerID: "cerebras", modelID: "gpt-oss-120b" }
|
||||
it.instance(
|
||||
"replays Cerebras assistant reasoning using the provider-supported field",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const fixture = loadFixture(cerebrasFixture.providerID, cerebrasFixture.modelID)
|
||||
const request = waitRequest(
|
||||
"/chat/completions",
|
||||
new Response(createChatStream("Hello"), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "text/event-stream" },
|
||||
}),
|
||||
)
|
||||
|
||||
const resolved = yield* Provider.use.getModel(
|
||||
ProviderV2.ID.make(cerebrasFixture.providerID),
|
||||
ModelV2.ID.make(fixture.model.id),
|
||||
)
|
||||
const sessionID = SessionID.make("session-test-cerebras-reasoning")
|
||||
const agent = {
|
||||
name: "test",
|
||||
mode: "primary",
|
||||
options: {},
|
||||
permission: [{ permission: "*", pattern: "*", action: "allow" }],
|
||||
} satisfies Agent.Info
|
||||
|
||||
const user = {
|
||||
id: MessageID.make("msg_user-cerebras-reasoning"),
|
||||
sessionID,
|
||||
role: "user",
|
||||
time: { created: Date.now() },
|
||||
agent: agent.name,
|
||||
model: { providerID: ProviderV2.ID.make(cerebrasFixture.providerID), modelID: resolved.id },
|
||||
} satisfies SessionV1.User
|
||||
|
||||
yield* drain({
|
||||
user,
|
||||
sessionID,
|
||||
model: resolved,
|
||||
agent,
|
||||
system: ["You are a helpful assistant."],
|
||||
messages: [
|
||||
{ role: "user", content: "Hello" },
|
||||
{
|
||||
role: "assistant",
|
||||
content: [
|
||||
{ type: "reasoning", text: "thinking" },
|
||||
{ type: "text", text: "Previous answer" },
|
||||
],
|
||||
},
|
||||
{ role: "user", content: "Continue" },
|
||||
] satisfies ModelMessage[],
|
||||
tools: {},
|
||||
})
|
||||
|
||||
const capture = yield* Effect.promise(() => request)
|
||||
const messages = capture.body.messages as Array<Record<string, unknown>>
|
||||
const assistant = messages.find((msg) => msg.role === "assistant")
|
||||
|
||||
expect(assistant?.reasoning).toBe("thinking")
|
||||
expect(assistant && "reasoning_content" in assistant).toBe(false)
|
||||
}),
|
||||
{
|
||||
config: () => ({
|
||||
enabled_providers: [cerebrasFixture.providerID],
|
||||
provider: {
|
||||
[cerebrasFixture.providerID]: {
|
||||
options: { apiKey: "test-key", baseURL: `${state.server!.url.origin}/v1` },
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
const alibabaQwenFixture = { providerID: "alibaba", modelID: "qwen-plus" }
|
||||
it.instance(
|
||||
"service stream cancellation cancels provider response body promptly",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue