Skip to content

Commit 6ca60d9

Browse files
fix(opencode): update Cerebras SDK reasoning replay (anomalyco#34826)
Co-authored-by: Aiden Cline <[email protected]>
1 parent b393499 commit 6ca60d9

3 files changed

Lines changed: 86 additions & 2 deletions

File tree

‎bun.lock‎

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/opencode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@ai-sdk/amazon-bedrock": "4.0.112",
6060
"@ai-sdk/anthropic": "3.0.82",
6161
"@ai-sdk/azure": "3.0.49",
62-
"@ai-sdk/cerebras": "2.0.41",
62+
"@ai-sdk/cerebras": "2.0.60",
6363
"@ai-sdk/cohere": "3.0.27",
6464
"@ai-sdk/deepinfra": "2.0.41",
6565
"@ai-sdk/gateway": "3.0.104",

‎packages/opencode/test/session/llm.test.ts‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,80 @@ describe("session.llm.stream", () => {
832832
},
833833
)
834834

835+
const cerebrasFixture = { providerID: "cerebras", modelID: "gpt-oss-120b" }
836+
it.instance(
837+
"replays Cerebras assistant reasoning using the provider-supported field",
838+
() =>
839+
Effect.gen(function* () {
840+
const fixture = loadFixture(cerebrasFixture.providerID, cerebrasFixture.modelID)
841+
const request = waitRequest(
842+
"/chat/completions",
843+
new Response(createChatStream("Hello"), {
844+
status: 200,
845+
headers: { "Content-Type": "text/event-stream" },
846+
}),
847+
)
848+
849+
const resolved = yield* Provider.use.getModel(
850+
ProviderV2.ID.make(cerebrasFixture.providerID),
851+
ModelV2.ID.make(fixture.model.id),
852+
)
853+
const sessionID = SessionID.make("session-test-cerebras-reasoning")
854+
const agent = {
855+
name: "test",
856+
mode: "primary",
857+
options: {},
858+
permission: [{ permission: "*", pattern: "*", action: "allow" }],
859+
} satisfies Agent.Info
860+
861+
const user = {
862+
id: MessageID.make("msg_user-cerebras-reasoning"),
863+
sessionID,
864+
role: "user",
865+
time: { created: Date.now() },
866+
agent: agent.name,
867+
model: { providerID: ProviderV2.ID.make(cerebrasFixture.providerID), modelID: resolved.id },
868+
} satisfies SessionV1.User
869+
870+
yield* drain({
871+
user,
872+
sessionID,
873+
model: resolved,
874+
agent,
875+
system: ["You are a helpful assistant."],
876+
messages: [
877+
{ role: "user", content: "Hello" },
878+
{
879+
role: "assistant",
880+
content: [
881+
{ type: "reasoning", text: "thinking" },
882+
{ type: "text", text: "Previous answer" },
883+
],
884+
},
885+
{ role: "user", content: "Continue" },
886+
] satisfies ModelMessage[],
887+
tools: {},
888+
})
889+
890+
const capture = yield* Effect.promise(() => request)
891+
const messages = capture.body.messages as Array<Record<string, unknown>>
892+
const assistant = messages.find((msg) => msg.role === "assistant")
893+
894+
expect(assistant?.reasoning).toBe("thinking")
895+
expect(assistant && "reasoning_content" in assistant).toBe(false)
896+
}),
897+
{
898+
config: () => ({
899+
enabled_providers: [cerebrasFixture.providerID],
900+
provider: {
901+
[cerebrasFixture.providerID]: {
902+
options: { apiKey: "test-key", baseURL: `${state.server!.url.origin}/v1` },
903+
},
904+
},
905+
}),
906+
},
907+
)
908+
835909
const alibabaQwenFixture = { providerID: "alibaba", modelID: "qwen-plus" }
836910
it.instance(
837911
"service stream cancellation cancels provider response body promptly",

0 commit comments

Comments
 (0)