From 998ffb5f6cf4bf3c60569a709d1e534ddceb0383 Mon Sep 17 00:00:00 2001 From: Scott Fradkin Date: Mon, 20 Apr 2026 12:32:26 -0500 Subject: [PATCH 1/2] fix(bedrock): add inference profile prefixes and fix reasoning for additional models - Add palmyra and pixtral to US cross-region inference profile prefix list - Strip reasoning content from message history for non-reasoning models - Exclude palmyra from reasoning variant generation to prevent unsupported params --- packages/opencode/src/provider/provider.ts | 2 ++ packages/opencode/src/provider/transform.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 9ec5dfc6b50b..7226b28988c7 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -356,6 +356,8 @@ export namespace Provider { "nova-2", "claude", "deepseek", + "palmyra", + "pixtral", ].some((m) => modelID.includes(m)) const isGovCloud = region.startsWith("us-gov") if (modelRequiresPrefix && !isGovCloud) { diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index bab056dae784..45fba4439c05 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -51,6 +51,15 @@ export namespace ProviderTransform { model: Provider.Model, options: Record, ): ModelMessage[] { + // Strip reasoning parts from assistant messages for models that don't support reasoning + if (!model.capabilities.reasoning) { + msgs = msgs.map((msg) => { + if (msg.role !== "assistant" || !Array.isArray(msg.content)) return msg + const filtered = msg.content.filter((part) => (part as any).type !== "reasoning") + return { ...msg, content: filtered } + }) + } + // Anthropic rejects messages with empty content - filter out empty string messages // and remove empty text/reasoning parts from array content if (model.api.npm === "@ai-sdk/anthropic" || model.api.npm === "@ai-sdk/amazon-bedrock") { @@ -381,7 +390,8 @@ export namespace ProviderTransform { id.includes("kimi") || id.includes("k2p5") || id.includes("qwen") || - id.includes("big-pickle") + id.includes("big-pickle") || + id.includes("palmyra") ) return {} From a128f557871ffe1c4f0b6d651995effea2a2edcb Mon Sep 17 00:00:00 2001 From: Scott Fradkin Date: Mon, 20 Apr 2026 13:04:44 -0500 Subject: [PATCH 2/2] docs: update LOCAL_AWS_SETUP.md with corrected model config keys and new notes --- LOCAL_AWS_SETUP.md | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/LOCAL_AWS_SETUP.md b/LOCAL_AWS_SETUP.md index 65b6226c36ef..d6442b13d5f4 100644 --- a/LOCAL_AWS_SETUP.md +++ b/LOCAL_AWS_SETUP.md @@ -69,44 +69,38 @@ Create `~/.config/opencode/opencode.json`: "region": "" }, "models": { - "writer.palmyra-x4": { - "id": "us.writer.palmyra-x4-v1:0", + "writer.palmyra-x4-v1:0": { "name": "Writer Palmyra X4", "tool_call": false, "limit": { "context": 128000, "output": 8192 } }, - "writer.palmyra-x5": { - "id": "us.writer.palmyra-x5-v1:0", + "writer.palmyra-x5-v1:0": { "name": "Writer Palmyra X5", "tool_call": false, "limit": { "context": 1000000, "output": 8192 } }, - "deepseek.r1": { - "id": "us.deepseek.r1-v1:0", - "name": "DeepSeek R1", + "deepseek.r1-v1:0": { + "name": "DeepSeek R1 (A)", "tool_call": false, + "reasoning": false, "limit": { "context": 64000, "output": 32768 } }, - "mistral.pixtral-large-2502": { - "id": "us.mistral.pixtral-large-2502-v1:0", + "mistral.pixtral-large-2502-v1:0": { "name": "Mistral Pixtral Large", "tool_call": false, "limit": { "context": 128000, "output": 8192 } }, - "meta.llama4-maverick-17b-instruct": { - "id": "us.meta.llama4-maverick-17b-instruct-v1:0", + "meta.llama4-maverick-17b-instruct-v1:0": { "name": "Meta Llama 4 Maverick 17B", "tool_call": false, "limit": { "context": 1000000, "output": 8192 } }, - "meta.llama4-scout-17b-instruct": { - "id": "us.meta.llama4-scout-17b-instruct-v1:0", + "meta.llama4-scout-17b-instruct-v1:0": { "name": "Meta Llama 4 Scout 17B", "tool_call": false, "limit": { "context": 10000000, "output": 8192 } }, - "amazon.nova-2-lite": { - "id": "us.amazon.nova-2-lite-v1:0", + "amazon.nova-2-lite-v1:0": { "name": "Amazon Nova 2 Lite", "limit": { "context": 300000, "output": 5120 } } @@ -116,11 +110,11 @@ Create `~/.config/opencode/opencode.json`: } ``` -> **Note on `tool_call: false`:** Models marked with `tool_call: false` do not support -> tool use in streaming mode on Bedrock. This config prevents opencode from sending -> tool definitions to those models. The `flex` branch includes a fix that makes -> `tool_call: false` actually respected at runtime — see the tracking PR -> [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) for details. +> **Notes on model config keys:** Config keys must match the snapshot model ID exactly (e.g. `writer.palmyra-x5-v1:0`) — the `us.` cross-region inference profile prefix is added automatically at runtime for supported models and regions. The `id` field is only needed if you want the key to differ from the API model ID. +> +> **`tool_call: false`:** Models marked with `tool_call: false` do not support tool use in streaming mode on Bedrock. This prevents opencode from sending tool definitions to those models. +> +> **`reasoning: false`:** Models marked with `reasoning: false` will have reasoning content stripped from message history before being sent to the model. Required for models like DeepSeek R1 on Bedrock that generate reasoning output but reject it as input in subsequent turns. ### 3. Shell alias @@ -173,6 +167,9 @@ See [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) for the ful | Hide skill prompt text from chat UI | `packages/opencode/src/session/prompt.ts` | Marks skill template as `synthetic` so the full prompt is sent to the model but hidden from the user | | Respect `tool_call: false` at runtime | `packages/opencode/src/session/llm.ts` | Gates tool resolution behind `capabilities.toolcall` — fixes failures on Bedrock models that don't support streaming + tool use | | Re-sign macOS binaries after build | `packages/opencode/script/build.ts` | Strips Bun's embedded signature and applies a fresh ad-hoc one — fixes SIGKILL (exit 137) on Darwin 25+ where Bun's signature format is rejected | +| Add inference profile prefixes for palmyra and pixtral | `packages/opencode/src/provider/provider.ts` | Adds `us.` cross-region inference profile prefix for Writer Palmyra and Mistral Pixtral models in US regions | +| Strip reasoning from history for non-reasoning models | `packages/opencode/src/provider/transform.ts` | Removes reasoning content parts from assistant message history before sending to models with `reasoning: false` — fixes Bedrock rejections when switching from a reasoning model | +| Exclude palmyra from reasoning variant generation | `packages/opencode/src/provider/transform.ts` | Prevents unsupported `reasoningConfig` parameters from being sent to Writer Palmyra models | | Local build & AWS Bedrock setup docs | `LOCAL_AWS_SETUP.md` | This file | Full details and upstream tracking: [flexion/opencode#2](https://github.com/flexion/opencode/pull/2)