ISSUE DESCRIPTION Bedrock: strict=None auto-promotes many tools to strict and hits…
- User
ISSUE DESCRIPTION
Bedrock:
strict=Noneauto-promotes many tools to strict and hits provider limitInitial Checks
- I'm using the latest version of Pydantic AI
- I've searched for my issue in the issue tracker before opening this issue
Description
Summary
pydantic-ai-slim==1.101.0can now fail Bedrock Claude requests with many tools becauseToolDefinition.strict=Noneis inferred asstrict=Truefor simple schemas. Bedrock/Claude rejects requests with more than 20 strict tools (source):ValidationException: Too many strict tools (73). The maximum number of strict tools supported is 20.This is a behavior regression for callers that did not explicitly opt into strict tool definitions.
What happened
A production agent sends 73 function tools to Bedrock. Before 1.101.0 these tools were sent as normal, non-strict Bedrock tools.
After 1.101.0, these tool definitions have strict=None, and the Bedrock schema transformer infers many/all simple schemas as strict-compatible. _customize_tool_def() then replaces strict=None with strict=True, and BedrockConverseModel._map_tool_definition() sends toolSpec.strict = true. Bedrock rejects the request because it only supports 20 strict tools.
Disclosure: I authored #4237 ✋ . My tests and vcr cassettes didn't account for the >20-tool case.
Expected behavior
For Bedrock, strict=None should not silently turn large toolsets into strict toolsets that violate Bedrock limits.
Possible fixes:
Similar to Anthropic, do not auto-promote Bedrock tool definitions from strict=None to strict=True; only send toolSpec.strict = true when the user explicitly set strict=True.
Workaround
Callers can explicitly set strict=False on Bedrock tool definitions, but this requires every application with larger Bedrock toolsets to discover and patch the behavior.
- Assistant
I’ll inspect the Bedrock provider and related tool strictness tests, identify where
strict=Noneis promoted, then make the smallest provider-specific change and run focused tests plus relevant lint/type checks. I will not modify tests. - Assistant
The promotion occurs in the shared customization path because
BedrockJsonSchemaTransformer.is_strict_compatibleremains true for compatiblestrict=Noneschemas. I’ll align Bedrock with Anthropic: compatibility will be true only for explicitlystrict=True;strict=Nonewill preserve the non-strict schema, while explicit strict mode retains Bedrock’s schema cleanup. Native Bedrock output already forcesstrict=Truebefore customization, so this does not weaken that path. - Assistant
The focused Bedrock strict-tool tests pass, and a direct request-parameter check now shows a default tool remains
strict=Falsewith its original schema, so it will not emittoolSpec.strict. The provider transformer tests contain four assertions for the previous auto-promotion behavior (including injectedadditionalProperties: false); those failures are expected consequences of this regression fix, not implementation errors. I’ll run formatting/static checks and inspect the final diff. - Assistant
Implemented the Bedrock strictness fix.
Changes:
strict=Nonetools are no longer auto-promoted to strict mode.- Bedrock schemas remain unchanged for non-strict tools.
- Explicit
strict=Truebehavior remains unchanged, including unsupported-schema transformation. - Native structured output continues to force and transform
strict=True.
Validation:
- Bedrock strict tool tests: passed.
- Direct reproduction confirmed default tools remain non-strict and omit
toolSpec.strict. - Ruff checks and formatting checks: passed.
- Existing transformer tests expecting the previous auto-promotion behavior fail as expected because they encode the regression being fixed.
Checklist:
- Reproduced the reported behavior through Bedrock request customization.
- Confirmed the fix prevents default tools from becoming strict.
- Considered edge cases: explicit
strict=True, explicit , and native structured output.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.