Skip to content

Problem with AWS Bedrock #24648

Closed
Closed

Description

@franjorub

Description

I have a configuration to use two different models from Bedrock, Opus for plan, Sonnet for build.

if I use the same model in both agents, its fine.

but if I use them separately, when I chat with one model, and continue the conversation in the other I get this error

undefined: The model returned the following errors: messages.1.content.0.thinking.signature: Field required

I have tested this methodology of different models with plan/build in other code assistants compatible with Bedrock and the problem doesn't happen

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 27, 2026
  2. github-actions commented on Apr 27, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is not fully covered by those, please add details (OpenCode version, OS, terminal) so it can be tracked separately.

  3. shakedlokits commented on Apr 28, 2026

    @shakedlokits

    I think it might be possible to resolve this with something like:

    
    export const plugin: Plugin = async () => {
      let isAnthropicBedrock = false;
    
      return {
        "chat.params": async (input, _output) => {
          isAnthropicBedrock =
            input.model.providerID === "amazon-bedrock" &&
            input.model.api.id.includes("anthropic");
        },
        "experimental.chat.messages.transform": async (_input, output) => {
          if (!isAnthropicBedrock) return;
          for (const msg of output.messages) {
            msg.parts = msg.parts.filter((part) => part.type !== "reasoning");
          }
        },
      };
    };
    
  4. rekram1-node commented on Apr 28, 2026

    @rekram1-node
    Collaborator

    ill try fixing this today

  5. Dulani commented on Apr 29, 2026

    @Dulani

    We hit the same messages.1.content.0.thinking.signature: Field required error when switching models mid-session (Azure OpenAI GPT-5.4 → AWS Bedrock Claude Opus) and after investigating we've identified the same root cause you're encountering with Plan(Opus) ↔ Build(Sonnet) on Bedrock.

    Root Cause

    packages/opencode/src/session/message-v2.ts in toModelMessages() replays assistant parts when building conversation history. For type: "reasoning" it currently does:

    assistantMessage.parts.push({
      type: "reasoning",
      text: part.text,
      ...(differentModel ? {} : { providerMetadata: part.metadata }),
    })

    When differentModel is true (either different provider or different model), it strips providerMetadata but keeps the reasoning part. The downstream Anthropic/Bedrock path then serializes that part as a Claude thinking block without a valid signature, and Bedrock rejects the request with exactly the error you're seeing.

    For your Plan(Opus) ↔ Build(Sonnet) case, differentModel is true (same provider, different model), so Claude's own signature gets stripped on replay — even though it would have been valid to pass through unchanged.

    Fix Applied

    We introduced differentProvider and split the behavior:

    • different provider → drop the reasoning part entirely (can't translate foreign reasoning into Anthropic thinking safely)
    • same provider, different model → preserve the reasoning part and its providerMetadata, so signatures from one Claude model can round-trip into the next
    const differentProvider = model.providerID !== msg.info.providerID
    // ...
    if (part.type === "reasoning") {
      if (differentProvider) continue
      assistantMessage.parts.push({
        type: "reasoning",
        text: part.text,
        providerMetadata: part.metadata,
      })
    }

    Verification

    • Two-turn repro (GPT-5.4 → Bedrock Opus) reproduced the failure deterministically before the fix, passes cleanly after
    • Switching a live session with existing Claude thinking blocks also works
    • Added focused tests for both cross-provider drop and same-provider preservation

    Related Issues

    This issue appears related in symptom to #22813 (which focuses on Anthropic thinking block signature validation) and #23926 (which identifies a different code path in transform.ts). All three converge on the same family of errors when mixing providers or models with extended thinking enabled.

    Ready to submit as a PR if helpful.

  6. rekram1-node commented on Apr 29, 2026

    @rekram1-node
    Collaborator

    @Dulani im going to fix it, this solution u propose "works" but it is poor. Also please dont paste giant AI messages

  7. Dulani commented on Apr 30, 2026

    @Dulani

    @rekram1-node - Apologies for the "giant AI message." I do most of my patching/PRs with LLMs and the larger messages are super helpful for giving the LLM the context it needs to do the job (I don't really have the Typescript expertise needed to write the code all on my own, but I still want to be helpful).

    I will keep them shorter in the future (wish I could attach more context instead). In any case, thanks for your GREAT work on this harness, it's been a pleasure to work in/with.

  8. xer0x commented on May 1, 2026

    @xer0x

    Thanks for working on this. As a Bedrock user it's been a frustrating surprise to get stuck on this. Running /compact on this history is my workaround at the moment.

  9. josechirivella commented on May 1, 2026

    @josechirivella

    I'm planning with Opus, and my executor is with Sonnet, but when I do the switching, that's when I get the error. My solution at the moment is to get the planning in Markdown and copy-paste to a new chat with Sonnet, but I've been getting mixed results.

  10. rekram1-node commented on May 1, 2026

    @rekram1-node
    Collaborator

    My open pr fixes this, will prolly release today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions