Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,12 +1097,16 @@ export function options(input: {
result["toolStreaming"] = false
}

// openai and providers using openai package should set store to false by default.
// OpenAI-family Responses clients default to stateless mode (store: false).
// For @ai-sdk/xai, store:false also causes the SDK to inject
// include: ["reasoning.encrypted_content"] so follow-up turns can receive
// encrypted reasoning for rehydration.
Comment thread
rekram1-node marked this conversation as resolved.
Outdated
if (
input.model.providerID === "openai" ||
input.model.api.npm === "@ai-sdk/openai" ||
input.model.api.npm === "@ai-sdk/github-copilot" ||
input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle"
input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle" ||
input.model.api.npm === "@ai-sdk/xai"
) {
result["store"] = false
}
Expand Down Expand Up @@ -1257,7 +1261,8 @@ export function smallOptions(model: Provider.Model) {
if (
model.providerID === "openai" ||
model.api.npm === "@ai-sdk/openai" ||
model.api.npm === "@ai-sdk/github-copilot"
model.api.npm === "@ai-sdk/github-copilot" ||
model.api.npm === "@ai-sdk/xai"
) {
const base = { store: false }
return mergeDeep(base, small)
Expand Down
37 changes: 37 additions & 0 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,43 @@ describe("ProviderTransform.options - setCacheKey", () => {
expect(result.store).toBe(false)
})

test("should set store=false for xAI provider by default", () => {
const xaiModel = {
...mockModel,
providerID: "xai",
api: {
id: "grok-4",
url: "https://api.x.ai",
npm: "@ai-sdk/xai",
},
}
const result = ProviderTransform.options({
model: xaiModel,
sessionID,
providerOptions: {},
})
expect(result.store).toBe(false)
expect(result.promptCacheKey).toBe(sessionID)
})

test("should set store=false for xAI SDK regardless of provider ID", () => {
const xaiModel = {
...mockModel,
providerID: "custom-xai",
api: {
id: "grok-4",
url: "https://api.x.ai",
npm: "@ai-sdk/xai",
},
}
const result = ProviderTransform.options({
model: xaiModel,
sessionID,
providerOptions: {},
})
expect(result.store).toBe(false)
})

test("should set store=false for azure provider by default", () => {
const azureModel = {
...mockModel,
Expand Down
Loading