Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Bedrock: strict=None auto-promotes many tools to strict and hits…

  1. User

    ISSUE DESCRIPTION

    Bedrock: strict=None auto-promotes many tools to strict and hits provider limit

    Initial Checks

    Description

    Summary

    pydantic-ai-slim==1.101.0 can now fail Bedrock Claude requests with many tools because ToolDefinition.strict=None is inferred as strict=True for 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

    Logfire Trace

    No response

    Python, Pydantic AI & LLM client version

    • Python: 3.14
    • Pydantic AI: 1.101.0

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /pydantic-ai, current file: none) bash-$

  2. MiniMax Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. MiniMax Assistant

    Let me look at the Anthropic provider to see how they handle the strict=None case:

  4. MiniMax Assistant

    Now let me look at the Bedrock model implementation:

  5. MiniMax Assistant

    Let me find _customize_tool_def:

  6. MiniMax Assistant

    Let me look at the JsonSchemaTransformer base class:

  7. MiniMax Assistant

    Let me look at the existing bedrock test file:

  8. MiniMax Assistant

    Let me look at the Anthropic test for the auto-enable behavior:

  9. MiniMax Assistant

    Let me look at all the test_strict_none_* tests:

  10. MiniMax Assistant

    Let me see the entire test file from the top:

  11. MiniMax Assistant

    Let me check git log to understand the history:

  12. MiniMax Assistant

    Now let me understand the broader picture. Let me look at the function in __init__.py:

  13. MiniMax Assistant

    Let me check the cassettes to see what the existing test recordings show:

  14. MiniMax Assistant

    Note the toolSpec in the cassette does NOT have strict: true because the test uses strict=False. Good.

    Now let me check the test_bedrock_mixed_strict_tool_run cassette:

  15. MiniMax Assistant

    Now let me check the conftest:

  16. MiniMax Assistant

    Now let me look at the existing inline_snapshot test for test_strict_none_simple_schema and check how snapshot is used:

  17. MiniMax Assistant

    Now I have a complete understanding. Let me create a reproduction script first:

  18. MiniMax Assistant

    Confirmed the bug. Now let me reproduce the full flow with the Agent:

  19. MiniMax Assistant

    Now I have confirmed the bug. Let me implement the fix following Anthropic's approach.

  20. MiniMax Assistant

    Now let me look at the current implementation more carefully:

  21. MiniMax Assistant

    Now let me implement the fix:

  22. MiniMax Assistant

    Now let me verify the patch:

  23. MiniMax Assistant

    Now let me verify the fix works:

  24. MiniMax Assistant

    Excellent! The fix works. Now let me run the existing tests:

  25. MiniMax Assistant

    Let me run all the strict-related tests:

  26. MiniMax Assistant

    The 4 tests that fail are all testing the buggy behavior we're fixing. Let me run the broader test suite to make sure nothing else is broken:

  27. MiniMax Assistant

    All other tests pass. Now let me also run the strict-related model tests:

  28. MiniMax Assistant

    All strict tool call tests pass. Now let me run the native output tests:

  29. MiniMax Assistant

    All native output tests pass. Now let me run all bedrock-related tests:

  30. MiniMax Assistant

    All 142 model tests pass. The 4 failing tests in tests/providers/test_bedrock.py are all testing the old (buggy) auto-promotion behavior. Let me verify those 4 failures are all related to the auto-promotion:

  31. MiniMax Assistant

    Let me now verify the fix handles all edge cases properly:

  32. MiniMax Assistant

    All edge cases pass. Let me also do a complete end-to-end test with the Agent:

  33. MiniMax Assistant

    Now let me also check the existing tests in tests/models/test_bedrock.py for any related tests:

  34. MiniMax Assistant

    Let me also check that the existing test_bedrock_native_output tests still work correctly:

  35. MiniMax Assistant

    OK the test description says "prepare_request() forces strict=True for native output". Let me check the cassette to verify:

  36. MiniMax Assistant

    Let me also verify the nested objects test:

  37. MiniMax Assistant

    Let me also run any other test that might involve strict mode:

  38. MiniMax Assistant

    All 249 bedrock-related model tests pass. Let me also run the broader test suite to make sure nothing else is broken:

  39. MiniMax Assistant

    The 4 failing tests are all testing the old buggy behavior. Let me also check that the issue is in tests/providers/test_bedrock.py and that I haven't introduced regressions elsewhere. Let me search for any tests that explicitly test for is_strict_compatible in the codebase:

  40. MiniMax Assistant

    Now let me also look at the transform method in Anthropic to compare with the Bedrock implementation:

  41. MiniMax Assistant

    Now let me also run the wider test suite to confirm nothing else is broken:

  42. MiniMax Assistant

    Let me also run the broader models test suite:

  43. MiniMax Assistant

    Let me check those non-bedrock failures:

  44. MiniMax Assistant

    Let me confirm these failures are unrelated to my fix:

  45. MiniMax Assistant

    The 2-3 pre-existing failures are unrelated to my fix. Let me make sure the fix is complete and look at the final state:

  46. MiniMax Assistant

    The diff is clean. Let me also run a broader range of tests to verify:

  47. MiniMax Assistant

    The 4 failing tests are exactly the ones testing the buggy auto-promote behavior. Let me see the inline-snapshot output to verify the test failures match my expected fix:

  48. MiniMax Assistant

    The 4 failing tests confirm that the fix correctly:

    1. Sets is_strict_compatible=False for strict=None (was True for simple schemas)
    2. Does not add additionalProperties=False to schemas when strict=None

    These tests are testing the OLD buggy behavior, and they need to be updated to reflect the new (correct) behavior. As per the instructions, I won't modify them.

    Let me also do a final sanity check by running the tests with my fix in place once more:

  49. MiniMax Assistant

    All sanity checks pass. Let me also clean up my repro scripts:

  50. MiniMax Assistant

    The fix is complete. Let me do a final check of the state of the code:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.