Bedrock: strict=None auto-promotes many tools to strict and hits provider limit Initial…
- User
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.
Minimal, Reproducible Example
- Assistant
I’m using the
complete-partial-prskill because this regression spans provider semantics, schema transformation, and request-mapping tests. I’ll inspect the local implementation and history (offline, per the task constraints), then implement and verify the narrow Bedrock fix plus adjacent coverage. The expected behavior is sufficiently specific, so I’ll proceed without blocking on clarification. - Assistant
The skill’s scope check points to a provider-local compatibility decision: preserve explicit
strict=True/False, but stop Bedrock from converting the unspecified state into an opt-in feature. I’m now mapping where customization and serialization occur, and checking the commit history that introduced the inference so the regression test lands at the user-visible request boundary. - Assistant
History confirms the regression came from #4237’s Bedrock transformer explicitly marking compatible
strict=Noneschemas as strict. The direct mapper test forNonewas misleading because real requests first pass through generic customization. I’m tightening the transformer contract itself—matching Anthropic’s opt-in semantics—so both ordinary and large toolsets retain the unspecified/non-strict state, while native output and explicit strict tools still use Bedrock’s strict transformation. - Assistant
The implementation and regression coverage are in place. The key test builds the reported 73-tool request after full model customization and verifies that none of the serialized Bedrock
toolSpecs containsstrict; I’m running the provider transformer suite, focused Bedrock model tests, formatting/lint, and type checking now. - Assistant
All focused checks pass, including the complete Bedrock strict-tool feature file. A final review found one useful strengthening: the 73-tool regression now goes through
prepare_request()—the same preparation path used by real requests—before inspecting the wire-level tool configuration. Explicitstrict=True, native structured output, and unsupported-model behavior remain covered and unchanged.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.