Skip to content

@ai-sdk/amazon-bedrock: strict on tools rejected by Bedrock Messages API for Claude Opus 4.7/4.8 #16121

Description

@igalmazor

When using @ai-sdk/amazon-bedrock with Claude Opus 4.7 or 4.8 on Bedrock's Messages API (invoke-model), structured output via Output.object() / Output.array() fails with:

tools.0.custom.strict: Extra inputs are not permitted

Root Cause

The strict field was added to prepareTools in response to #12766. In bedrock-prepare-tools.ts line 143:

...(tool.strict != null ? { strict: tool.strict } : {}),

This passes strict: true into the tool spec. However, Bedrock's Messages API for Opus 4.7/4.8 does not accept this field and rejects the request with HTTP 400.

Note: The Converse API does support strict, but @ai-sdk/amazon-bedrock uses the Messages API.

AWS docs confirm: "Claude Opus 4.7 does not accept strict: true on tools[] and returns tools.0.custom.strict: Extra inputs are not permitted"source

Reproduction

  1. Use @ai-sdk/amazon-bedrock@4.0.112 (or any version with the @ai-sdk/amazon-bedrock: ignores strict:true on tools #12766 fix)
  2. Call generateText with Output.object({ schema }) targeting us.anthropic.claude-opus-4-8 or us.anthropic.claude-opus-4-7
  3. Request fails with HTTP 400:
{
  "message": "The model returned the following errors: tools.0.custom.strict: Extra inputs are not permitted"
}

Expected Behavior

The Bedrock provider should either:

  1. Strip strict from tool specs when using the Messages API (since it's not supported for these models)
  2. Only pass strict for models/API paths that accept it

Workaround

Patch bedrock-prepare-tools.ts to remove the strict passthrough line.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions