Repository navigation
Description
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:
- 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 asnot_plannedby a GitHub Actions bot rather than fixed. - The wrong system prompt.
session/system.ts:43picks the Claude prompt withmodel.api.id.includes("claude"). An ARN doesn't match, so the model getsdefault.txtinstead. The two differ in substance: only the Claude prompt has theTodoWriteplanning 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"
}opencode run --variant high "hi"against a real profile: Bedrock returns the 400 above.- Or set
options.endpointto a local HTTP server that logs request bodies: the body hasreasoningConfig, and thesystemtext 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
opencode-agent commentedon Oct 7, 2026
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
reasoningand writing the variants asadditionalModelRequestFields), this is unlikely to be fixed in v1.Active development happens in OpenCode v2 (
@opencode/cli, theopencode2command). 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.github-actions commentedon Oct 7, 2026
This issue might be a duplicate of existing issues. Please check:
reasoningConfig: Extra inputs are not permittederror.The system-prompt behavior described here may be an additional, distinct symptom.
gillespied commentedon Oct 7, 2026
Thanks. I read the v2 source (
v2branch, 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.opencode-agent commentedon Oct 7, 2026
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.