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):textValidationException: 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’m treating the expected behavior as the decision: Bedrock should infer schema compatibility but only emit
strict: truewhen strictness was explicitly requested. I’ll use thecomplete-partial-prskill to check adjacent provider behavior, round-tripping, tests, and docs before implementing the focused fix. Since external access is disallowed, I’ll gather issue/PR context from the local history and repository. - Assistant
The skill’s delegation guidance applies here, so I’ve split off two read-only checks: one for adjacent Bedrock code paths and SDK request shapes, and one for the local history that introduced the regression. I’m keeping implementation and final verification on the main path.
- Assistant
The failure is confirmed in the full preparation path, not in
_map_tool_definition()itself: the shared schema customization resolves Bedrock’sstrict=NonetoTruebefore the mapper sees it. The conservative fix is provider-local—keep Bedrock’s schema normalization, but make inferred strictness false unless the caller explicitly chosestrict=True; native JSON output remains strict because Bedrock explicitly forces that mode before transformation. - Assistant
Local history confirms this is the right scope: PR #4237 added both the Bedrock promotion and a contradictory test claiming
strict=Nonewas omitted, but that test bypassed request customization. The shared inference must remain for OpenAI, while Anthropic already uses the same explicit-opt-in pattern now applied to Bedrock. The new regression test exercises 21 tools through the actual request path and inspects the outgoing Bedrock payload.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.