Skip to content

Bedrock application inference profile ARNs: reasoning variants fail and the wrong system prompt is used #53751

Closed as not planned

Description

@gillespied

Description

An Amazon Bedrock application inference profile (used to track usage and cost per team) is configured by setting a model's id to the profile ARN. Basic use works, but because an ARN doesn't contain the model name, anything OpenCode and the AI SDK decide from the id goes wrong. Two effects, one cause:

  1. Every reasoning variant fails. The AI SDK decides whether a Bedrock model is Anthropic from the id, so for an ARN it sends the Amazon Nova format (reasoningConfig) instead of the Claude one (thinking + output_config). Bedrock rejects it:
    reasoningConfig: Extra inputs are not permitted (HTTP 400, isRetryable: false). Plain requests with no variant work fine. This is the same symptom as [BUG] Bedrock Claude application inference profile reasoning variants send invalid payload #31749, which was closed as not_planned by a GitHub Actions bot rather than fixed.
  2. The wrong system prompt. session/system.ts:43 picks the Claude prompt with model.api.id.includes("claude"). An ARN doesn't match, so the model gets default.txt instead. The two differ in substance: only the Claude prompt has the TodoWrite planning guidance and "Professional objectivity"; only the general one says "DO NOT ADD ANY COMMENTS unless asked" and to run lint/typecheck when finished.

The AI SDK already has a fix for the first one

@ai-sdk/amazon-bedrock has a per-model modelFamily: 'anthropic', documented as "Specify this when the model ID does not identify the underlying model, such as an application inference profile ARN." It first ships for chat models in 4.0.177; OpenCode pins 4.0.166 (with a patch that only adds reasoning-schema options, nothing to do with model detection). It is a per-model argument (bedrock(modelId, { modelFamily })), not a provider option, and OpenCode calls sdk.languageModel(model.api.id) with no settings (provider.ts:1938 on v1.18.35). Setting it on the provider does nothing.

I tested the SDK directly (4.0.191, a local server recording the request body, a made-up ARN) with reasoning effort high:

additionalModelRequestFields sent
eu.anthropic.claude-sonnet-5-5 {"thinking":{"type":"adaptive","display":"summarized"},"output_config":{"effort":"high"}}
ARN {"reasoningConfig":{"maxReasoningEffort":"high"}}
ARN, bedrock(arn, { modelFamily: 'anthropic' }) identical to the Claude model's, including additionalModelResponseFieldPaths

Suggested fix

Model config already has a family field (e.g. "family": "claude-sonnet"). Use it when the id doesn't say what the model is: pass { modelFamily: 'anthropic' } to the SDK for Bedrock models whose family is claude* (bumping the SDK to >= 4.0.177), and fall back to model.family in system.ts and the other api.id.includes("claude") checks. I haven't tried this inside OpenCode, only at the SDK level above.

Steps to reproduce

No AWS account needed to see the request, only to see Bedrock reject it. ~/.config/opencode/opencode.json:

{
  "enabled_providers": ["amazon-bedrock"],
  "provider": { "amazon-bedrock": {
    "options": { "region": "eu-west-2" },
    "models": { "claude-tracked": {
      "id": "arn:aws:bedrock:eu-west-2:123456789012:application-inference-profile/abcdefghijkl",
      "family": "claude-sonnet", "reasoning": true,
      "limit": { "context": 1000000, "output": 128000 } } } } },
  "model": "amazon-bedrock/claude-tracked"
}
  1. opencode run --variant high "hi" against a real profile: Bedrock returns the 400 above.
  2. Or set options.endpoint to a local HTTP server that logs request bodies: the body has reasoningConfig, and the system text begins "You are opencode, an interactive CLI tool…" rather than "You are OpenCode, the best coding agent on the planet."

OpenCode version

Reasoning failure confirmed with real Bedrock calls on 1.18.1. The wrong reasoning format was also recorded on 1.18.35 (latest). The wrong system prompt was recorded on 1.18.1; the code that picks it is identical on 1.18.35 and dev.

Operating System / Terminal

macOS (Apple Silicon), Terminal.

Why this matters

Application inference profiles are how you attribute Bedrock usage and cost to a team, so anyone doing that with OpenCode hits this. The only workaround I found is to switch off reasoning on the model and hand-write each variant as raw additionalModelRequestFields, which also loses the desktop app's reasoning indicator.

Activity

  1. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up and for testing the SDK directly. It makes the cause very clear.

    This report is about OpenCode v1 (1.18.x). v1 now only gets fixes for critical bugs, like data loss, security problems or breakage with no workaround. Since plain requests to the profile ARN work and you've found a workaround (turning off reasoning and writing the variants as additionalModelRequestFields), this is unlikely to be fixed in v1.

    Active development happens in OpenCode v2 (@opencode/cli, the opencode2 command). It's a separate implementation with its own provider and system prompt handling, so please give it a try with your application inference profile setup. If you think this is critical, or you see the same reasoning-variant or system-prompt problem with an ARN model id in v2, please reply here with the v2 version and what you saw, and we'll take another look.

  2. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor

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

    • #31749: Claude Bedrock application-inference-profile ARNs send an invalid reasoning payload for variants, producing the same reasoningConfig: Extra inputs are not permitted error.
    • #10611: Earlier report of Claude Bedrock inference-profile ARN detection causing reasoning configuration failures.

    The system-prompt behavior described here may be an additional, distinct symptom.

  3. gillespied commented on Oct 7, 2026

    @gillespied
    Author

    Thanks. I read the v2 source (v2 branch, 2.0.24). v2 no longer uses the AI SDK for Bedrock, so the SDK model-family bug is gone. A similar id check remains in v2's variant generation (packages/core/src/variant.ts, bedrockConverse), which still produces Nova-format effort variants for an ARN id. I filed it separately as #53756 with the exact lines and a suggested fix. I haven't run v2 against a real profile yet, and the new issue says so.

  4. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for checking the v2 source and filing #53756. That's the right place to track the v2 variant generation for ARN model ids. As you found, v2 doesn't use the AI SDK for Bedrock, so the model-family detection problem in this report doesn't apply there.

    The v1 bug isn't critical because there's a workaround, and v1 only gets critical fixes, so it won't be fixed and I'm closing this issue. Follow-up on v2 will happen in #53756.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions