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
Let me start by understanding the issue:
- The problem is that in Pydantic AI version 1.101.0,
strict=Noneis being auto-promoted tostrict=Truefor Bedrock tool definitions - This causes Bedrock/Claude to reject requests when there are more than 20 strict tools
- The expected behavior is that
strict=Noneshould not silently turn large toolsets into strict toolsets - The fix suggested is to not auto-promote Bedrock tool definitions from strict=None to strict=True, only send
toolSpec.strict = truewhen the user explicitly setstrict=True
Let me first explore the repository structure to understand the codebase and find the relevant files.
- The problem is that in Pydantic AI version 1.101.0,
Assistant
<tool_call> <function=bash_terminal> <parameter=command> find /pydantic-ai/pydantic_ai_slim -name "*.py" | grep -E "(bedrock|provider)" | head -20 </tool_call>
Assistant
Let me use bash command to find the relevant files.
Assistant
Let me first look at the Bedrock model file to understand the issue better.
Assistant
Let me search for the
_customize_tool_deffunction mentioned in the issue.<tool_call> <function=bash_terminal> <parameter=command> grep -n "_customize_tool_def|_map_tool_definition|strict" /pydantic-ai/pydantic_ai_slim/pydantic_ai/models/bedrock.py | head -40 </tool_call>
Assistant
Let me use bash terminal instead to search for the relevant functions.
Assistant
I found the key location. Let me see the
_map_tool_definitionfunction and understand howstrictis being set.<tool_call> <function=bash_terminal> <parameter=command> sed -n '496,530p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/models/bedrock.py </tool_call>
Assistant
Let me use a bash command to view the relevant lines.
Assistant
Good! I can see the
_map_tool_definitionfunction. The condition at line 502 isif f.strict and self.profile.bedrock_supports_strict_tool_definition:, which seems correct - it only setsstrictwhenf.strictis truthy.But the issue mentions
_customize_tool_def. Let me search for that function. It might be in another file.<tool_call> <function=bash_terminal> <parameter=command> grep -rn "_customize_tool_def" /pydantic-ai/pydantic_ai_slim/pydantic_ai/ </tool_call>
Assistant
Let me use a bash command instead of the search tool.
Assistant
Let me see the
_customize_tool_deffunction in the models/init.py file.<tool_call> <function=bash_terminal> <parameter=command> sed -n '1733,1760p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/models/init.py </tool_call>
Assistant
Let me use bash command to view the function.
Assistant
I found the issue! The
_customize_tool_deffunction in/pydantic-ai/pydantic_ai_slim/pydantic_ai/models/__init__.pyat line 1733-1745. The problem is on line 1744:strict=schema_transformer.is_strict_compatible if tool_def.strict is None else tool_def.strict,When
tool_def.strict is None, the function setsstricttoschema_transformer.is_strict_compatible. If the transformer determines that a schema is "strict compatible", it sets it toTrue, which causes the Bedrock model to treat it as a strict tool.Now let me look at the Anthropic provider to see how they handle this differently, as mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '125,165p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/anthropic.py </tool_call>
Assistant
Let me use bash to search the Anthropic provider file.
Assistant
I see! The key is that Anthropic's transformer explicitly sets
is_strict_compatible = self.strict is True, meaning it only considers schemas as strict-compatible whenstrict=Trueis explicitly set.Let me search for the Bedrock-specific transformer or profile:
Assistant
Let me check if there's a BedrockJsonSchemaTransformer class.
Assistant
Let me see what profile Bedrock uses and find how strictness is determined.
Assistant
Let me fix the command to search recursively.
Assistant
I found the key files! Let me examine the bedrock.py provider file to see how
is_strict_compatibleis being set:<tool_call> <function=bash_terminal> <parameter=command> sed -n '80,130p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me use bash to search the bedrock provider file.
Assistant
Now I see the problem! In the Bedrock schema transformer, when
self.strict is Noneand the schema doesn't haveadditionalProperties: true, it setsself.is_strict_compatible = True(since that's the default at line 41 of_json_schema.py).Let me look at the full context of the BedrockJsonSchemaTransformer class:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1,90p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me use bash terminal instead to view the bedrock provider file.
Assistant
Now I understand the issue better. Let me see the full context of the
transformmethod and howis_strict_compatibleis set whenstrict=None:<tool_call> <function=bash_terminal> <parameter=command> sed -n '1,125p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me use bash terminal to view the bedrock provider file properly.
Assistant
Now I understand the issue completely. Looking at the
BedrockJsonSchemaTransformerclass:- When
strict=Noneand the schema doesn't have incompatible keys,is_strict_compatibledefaults toTrue(set at line 41 of_json_schema.py) - This causes the
_customize_tool_deffunction inmodels/__init__.pyto setstrict=Truefor tools that were explicitly not set - When there are >20 such tools, Bedrock rejects the request with "Too many strict tools"
The issue mentions that Anthropic handles this differently - they only set
is_strict_compatible = Truewhenstrict=Trueis explicitly set.The fix should be to change the BedrockJsonSchemaTransformer to NOT auto-promote schemas from
strict=Nonetostrict=True. Similar to how Anthropic does it:self.is_strict_compatible = self.strict is True # not compatible when strict is False/NoneLet me look at the base
_json_schema.pyto understand the default behavior.<tool_call> <function=bash_terminal> <parameter=command> cat /pydantic-ai/pydantic_ai_slim/pydantic_ai/_json_schema.py | head -80 </tool_call>
- When
Assistant
Let me use bash terminal to view the _json_schema.py file.
Assistant
Now I understand the issue clearly. The problem is that
BedrockJsonSchemaTransformerstarts withis_strict_compatible = True(default in the base class), and only sets it toFalsewhen it finds incompatible keys. This means simple schemas without any incompatible keys get auto-promoted tostrict=Truewhenstrict=None.The fix is to change the
BedrockJsonSchemaTransformer.transform()method to explicitly setis_strict_compatible = self.strict is Trueat the beginning, similar to how Anthropic handles it. This will prevent auto-promotion whenstrict=None.Let me first create a test script to reproduce the issue, then apply the fix.
Assistant
Let me look for existing tests related to the Bedrock strict tool behavior:
Assistant
Let me search for existing tests in bedrock.py tests:
Assistant
Let me look at the bedrock test file to understand how tests are structured.
Assistant
Let me look at the specific test case to understand the expected behavior better:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '500,550p' /pydantic-ai/tests/providers/test_bedrock.py </tool_call>
Assistant
Let me use bash terminal to view the tests.
Assistant
Now I understand the issue better. The current tests expect that with
strict=None, simple schemas haveis_strict_compatible=True. But this behavior causes problems when there are many tools.The fix should change the behavior so that when
strict=None,is_strict_compatibleis set toFalse(or more accurately, we should NOT auto-promote tostrict=True). Only whenstrict=Trueis explicitly set should we setis_strict_compatible=True.Let me look at how Anthropic handles this:
Assistant
Now I have a clear understanding. The Anthropic provider sets:
self.is_strict_compatible = self.strict is TrueThis means
is_strict_compatibleis onlyTruewhenstrict=Trueis explicitly set. Whenstrict=None,is_strict_compatibleisFalse.The fix for Bedrock should be similar. Let me update the
BedrockJsonSchemaTransformer.transform()method to explicitly setis_strict_compatible = self.strict is Trueat the beginning.Let me first check the current implementation of the
transform()method in bedrock.py:<tool_call> <function=bash_terminal> <parameter=command> sed -n '67,115p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me use bash command to view the transform method.
Assistant
Now I can see the issue clearly. The fix should:
- Set
self.is_strict_compatible = self.strict is Trueat the beginning of the transform method - This will ensure that when
strict=None, theis_strict_compatibleremainsFalse(default)
However, looking at the current logic, there are some edge cases where
is_strict_compatibleis being set toFalse:- Line 86: When
additionalPropertiesis explicitlyTrue - Line 111: When there are incompatible keys
But with the fix, we should NOT auto-promote to
strict=Truewhenstrict=None, so we should remove the logic that setsis_strict_compatible=Trueimplicitly.Let me apply the fix to the BedrockJsonSchemaTransformer:
- Set
Assistant
Now I understand the issue. The fix needs to be applied to the
BedrockJsonSchemaTransformer.transform()method to setis_strict_compatible = self.strict is Trueat the beginning. This will prevent auto-promotion ofstrict=Noneschemas tostrict=True.Let me apply the fix:
Assistant
Now let me verify the changes:
Assistant
Assistant
The script ran successfully but I should verify the changes. Let me check the updated content.
Assistant
The second fix didn't apply because the exact text wasn't matched. Let me check if the fix was applied:
Assistant
Let me view the full file to see the current state:
Assistant
The fix was applied successfully. The key change is at lines 77-81:
def transform(self, schema: JsonSchema) -> JsonSchema: # Only set is_strict_compatible=True when strict=True is explicitly set. # This prevents auto-promotion of strict=None schemas to strict=True, # which would violate Bedrock's 20 strict tool limit. self.is_strict_compatible = self.strict is TrueNow
is_strict_compatibleis onlyTruewhenstrict=Trueis explicitly set. Whenstrict=None,is_strict_compatibleremainsFalse, which prevents the auto-promotion that was causing the Bedrock limit issue.However, I notice that the redundant code at lines 93-94 and 114-115 that still set
self.is_strict_compatible = Falseis now unnecessary. While it doesn't break anything, let me clean it up for clarity. But first, let me verify the fix works by running the existing tests.<tool_call> <function=bash_terminal> <parameter=command> cd /pydantic-ai && python -m pytest tests/providers/test_bedrock.py -v -x 2>&1 | head -100 </tool_call>
Assistant
Let me use bash command to run the tests.
Assistant
I need to install the package first. Let me check how to install it.
<tool_call> <function=bash_terminal> <parameter=command> cd /pydantic-ai && pip install -e pydantic_ai_slim/ 2>&1 | tail -10 </tool_call>
Assistant
I need to install the package. Let me use bash command to do this.
Assistant
The package has dependencies that are not available. Let me check if there's a Makefile or a setup script I can use to install the package.
Assistant
Now let me run the tests again.
Assistant
The test environment is not picking up the package. Let me check if there's a specific Python virtual environment or configuration.
<tool_call> <function=bash_terminal> <parameter=command> which python && python -c "import pydantic_ai; print(pydantic_ai.file)" </tool_call>
Assistant
I need to use bash command properly.
Assistant
Let me check the uv environment and use the correct Python.
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -c "import pydantic_ai; print(pydantic_ai.file)" </tool_call>
Assistant
I need to use bash command to source the virtual environment and check if pydantic_ai can be imported.
Assistant
Now let me run the tests with the venv activated.
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/providers/test_bedrock.py -v -x 2>&1 | head -200 </tool_call>
Assistant
Let me use bash terminal to run the tests.
Assistant
The test
test_strict_none_preserves_schemais failing because the test expectsis_strict_compatible=Truewhenstrict=None, but our fix changes that behavior tois_strict_compatible=Falsewhenstrict=None.This is exactly what we intended - the fix prevents auto-promotion of
strict=Noneschemas tostrict=True. However, the test was written to verify the old (buggy) behavior. Since the issue description says this is a regression that needs to be fixed, the test needs to be updated to reflect the correct behavior.Let me look at the test to understand what it's testing:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '481,510p' /pydantic-ai/tests/providers/test_bedrock.py </tool_call>
Assistant
I need to use bash terminal to view the test file.
Assistant
Looking at the test, it expects
is_strict_compatible=Truewhenstrict=None, but our fix changes this tois_strict_compatible=Falsewhenstrict=None. This is the correct behavior as per the issue description - we should NOT auto-promotestrict=Nonetostrict=True.Since the issue says this is a regression that needs to be fixed, the test is actually testing the buggy behavior. I need to update the tests to reflect the correct behavior.
Let me also check the other test
test_strict_none_simple_schema:Assistant
Assistant
Let me use bash terminal to run the test script properly.
Assistant
Assistant
I need to use bash terminal to run the test properly.
Assistant
The fix is working correctly:
- Test 1:
strict=NonewithadditionalProperties=Truegivesis_strict_compatible=Falseand preservesadditionalProperties=True- Correct!
- Test 1:
Assistant
I need to run the tests properly. Let me use bash terminal.
Assistant
Only 2 tests are failing, and they are the tests that expect the old (buggy) behavior where
is_strict_compatible=Truewhenstrict=None. All other tests pass, which means our fix doesn't break any other functionality.The failing tests are:
test_strict_none_preserves_schema- expectsis_strict_compatible=Truewhenstrict=Nonetest_strict_none_simple_schema- expectsis_strict_compatible=Truewhenstrict=None
Both tests need to be updated to expect
is_strict_compatible=Falsewhenstrict=None, which is the correct behavior per the issue description.As mentioned in the task description, I should NOT modify the tests - the evaluation system will not take the test changes into account. The evaluation system will run the tests and verify the fix works correctly.
Let me also run the model tests for Bedrock to make sure the fix doesn't break anything there:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/models/test_bedrock.py -v 2>&1 | tail -80 </tool_call>
Assistant
Let me run the model tests for Bedrock properly.
Assistant
All 122 tests in
test_bedrock.pypass! This confirms that our fix doesn't break any existing functionality.Let me also run tests related to strict tool calls to make sure the fix works correctly:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/models/bedrock/cassettes/test_strict_tool_calls/ -v 2>&1 | tail -20 </tool_call>
Assistant
Let me find the tests for strict tool calls.
<tool_call> <function=bash_terminal> <parameter=command> find /pydantic-ai/tests -name "*.py" -exec grep -l "strict_tool" {} ; </tool_call>
Assistant
Let me find the tests for strict tool calls properly.
Assistant
Let me run the Bedrock strict tool calls tests.
Assistant
All 7 strict tool call tests pass! This is great - it confirms that the fix works correctly and doesn't break any existing functionality.
Let me now verify that the fix handles the edge case mentioned in the issue - the 73 tools case. Let me create a test that simulates this:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python << 'EOF' from pydantic_ai.providers.bedrock import BedrockJsonSchemaTransformer from pydantic_ai.models import _customize_tool_def
Assistant
I need to use bash terminal to run this test script.
Assistant
The test script failed because I created a non-dataclass object. Let me fix the test script to use the actual ToolDefinition class.
Assistant
Let me use bash terminal to run the test script.
Assistant
I had a typo in the test script. Let me fix it.
Assistant
The fix is working correctly! The test results show:
-
73 simple tools with strict=None: All 73 tools have
strict=False(becauseis_strict_compatible=Falsewhenstrict=None). This is the correct behavior that prevents the Bedrock limit violation. -
Tools with explicit strict=True: All 3 tools have
strict=Trueandis_strict_compatible=True. This ensures that users who explicitly want strict tools can still get them.
The fix successfully addresses the issue described in the problem statement:
- Before fix:
strict=Noneschemas were auto-promoted tostrict=True, causing Bedrock to reject requests with >20 strict tools. - After fix:
strict=Noneschemas remainstrict=False(orstrict=Nonein the tool definition), preventing the Bedrock limit violation.
Let me now clean up the code by removing the redundant
self.is_strict_compatible = Falseassignments in thetransformmethod:<tool_call> <function=bash_terminal> <parameter=command> sed -n '76,115p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
-
Assistant
Let me use bash to view the relevant lines of the bedrock.py file.
Assistant
Assistant
Let me clean up the code by removing the redundant assignments.
Assistant
The code has been cleaned up. Let me verify the changes:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '76,120p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me verify the changes were applied correctly.
Assistant
The code has been cleaned up. Now the
is_strict_compatibleis set at the beginning of thetransformmethod based on whetherstrict=Trueis explicitly set. The redundant assignments have been removed.Let me run the tests again to make sure the cleanup didn't break anything:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/providers/test_bedrock.py -v 2>&1 | tail -30 </tool_call>
Assistant
I need to run the tests using bash terminal.
Assistant
There's an indentation error. The comment I added is not valid as the only content of the
elifblock. Let me fix this by removing theelifblock entirely since it's now empty.<tool_call> <function=bash_terminal> <parameter=command> sed -n '110,125p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
I need to view the lines around 110-125 to see the indentation error and fix it.
Let me use bash to view the content.
Assistant
I need to fix the indentation error. The
elifblock only has a comment which is not valid. Let me fix this by removing the emptyelifblock.Assistant
Let me verify the fix worked:
Assistant
There's an issue - the
return schemastatement is now incorrectly indented. It should be at the method level, not theifblock level. Let me view the full method and fix it properly:Assistant
The indentation is wrong. The
return schemashould be at the method level. Let me fix this:Assistant
Let me verify the indentation is now correct:
Assistant
Now let me verify the full method structure is correct:
Assistant
Let me fix the indentation properly:
Assistant
Let me verify the fix worked:
Assistant
The indentation is still wrong. Let me manually fix the indentation by viewing the file and correcting it:
Assistant
Let me check the file content around the return statement:
Assistant
The indentation is now 4 spaces, but it should be 8 spaces to be at the method level. Let me fix this:
Assistant
Let me verify the indentation is now correct:
Assistant
Now the indentation is correct (8 spaces). Let me run the tests to verify:
Assistant
The tests run now and we have the same 2 tests failing (the ones that expect the old buggy behavior). All other tests pass.
Let me run the model tests for Bedrock to make sure everything works:
Assistant
All 122 model tests pass! Let me also run the strict tool calls tests to make sure they still work:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/models/bedrock/test_strict_tool_calls.py -v 2>&1 | tail -20 </tool_call>
Assistant
Let me run the strict tool calls tests using bash terminal.
Assistant
All 7 strict tool calls tests pass! The fix is working correctly.
Let me also verify the final state of the bedrock.py file to make sure everything is correct:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '60,120p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me view the final state of the bedrock.py file to verify the fix:
Assistant
The fix is complete. Let me now verify one more time that the fix addresses the issue by running a test that simulates the original problem:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python << 'EOF' from pydantic_ai.providers.bedrock import BedrockJsonSchemaTransformer
print("=== Fix Verification ===") print()
Test 1: Verify that strict=None does NOT auto-promote to strict=True
print("Test 1: strict=None with simple schema") schema = {'type': 'object', 'properties': {'name': {'type': 'string'}}, 'required': ['name']} t = BedrockJsonSchemaTransformer(schema, strict=None) result = t.walk() print(f" is_strict_compatible = {t.is_strict_compatible}") print(f" Expected: False (to prevent auto-promotion)") print(f" PASS" if not t.is_strict_compatible else " FAIL") print()
Assistant
I need to run the test using bash terminal.
Assistant
The fix is complete and verified. Let me provide a summary of the changes:
Summary
Issue
Pydantic AI version 1.101.0 auto-promoted
strict=Nonetool definitions tostrict=Truefor Bedrock, causing Bedrock/Claude to reject requests when there were more than 20 strict tools.Root Cause
The
BedrockJsonSchemaTransformer.transform()method in/pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.pywas settingis_strict_compatible=Trueby default (inherited from the base class) and only setting it toFalsewhen incompatible keys were found. This meant that simple schemas without incompatible keys were auto-promoted tostrict=True.Fix
Added an explicit check at the beginning of the
transform()method:self.is_strict_compatible = self.strict is TrueThis ensures that:
- When
strict=Trueis explicitly set,is_strict_compatible=True(strict tools work as before)
- When
Assistant
The fix is complete. The output shows:
strict=Noneinput results instrict=Falseoutput (no auto-promotion)strict=Noneis not auto-promoted (PASS)strict=Trueis correctly compatible (PASS)
The fix successfully resolves the issue. Now I'll submit the changes.
Note: The task description states "If existing tests break because they need to be updated to reflect the changes you made, just ignore it. Evaluation system will not take it into account." This applies to the 2 failing tests that expect the old buggy behavior.
Let me now submit the changes.
<tool_call> <function=bash_terminal> <parameter=command> git diff /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
Let me use bash terminal to show the git diff of the changes.
Assistant
Assistant
I made a mistake in my previous fix. The
schema['additionalProperties'] = Truewas incorrect - it was redundant since the value was already True. Let me fix this properly.Assistant
Let me verify the fix and run the tests again:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '88,100p' /pydantic-ai/pydantic_ai_slim/pydantic_ai/providers/bedrock.py </tool_call>
Assistant
I need to use bash terminal to view the file.
Assistant
The fix is correct now. Let me run the tests again to make sure everything works:
Assistant
The tests show 2 failures (expected - they test the old buggy behavior) and 46 passed. Let me also verify the other tests pass:
Assistant
All 129 model tests pass (122 Bedrock tests + 7 strict tool tests). The fix is working correctly.
Let me also verify the additionalProperties test case to make sure it still works correctly:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python << 'EOF' from pydantic_ai.providers.bedrock import BedrockJsonSchemaTransformer
Assistant
Let me run the test to verify the additionalProperties handling.
Assistant
All tests pass. The fix correctly handles the
additionalPropertiescase:- When
additionalProperties=True, it's preserved andis_strict_compatible=False - When
additionalProperties=None, it's set toFalseandis_strict_compatible=False - When
additionalProperties=False, it staysFalseandis_strict_compatible=False
The fix is complete. Let me show the final diff and submit:
- When
Assistant
Now I'm ready to submit the changes. The fix:
- Updates the docstring to reflect the new behavior (no auto-promotion)
- Adds
self.is_strict_compatible = self.strict is Trueat the beginning of thetransformmethod - Cleans up redundant code that was setting
is_strict_compatible = False(since it's now alreadyFalsewhenstrict is not True) - Simplifies the
additionalPropertieshandling
The fix resolves the issue where Bedrock requests with >20 tools were failing due to strict tool limit violations.
<tool_call> <function=submit> </tool_call>
Assistant
I need to use the submit tool properly. Let me call it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.