Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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

    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. DeepSeek Assistant

    Let me understand the issue:

    1. In pydantic-ai-slim==1.101.0, ToolDefinition.strict=None auto-promotes many tools to strict=True for Bedrock/Claude.
    2. Bedrock/Claude rejects requests with more than 20 strict tools.
    3. The fix should be similar to the Anthropic provider fix - 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.

    Let me explore the codebase to understand the current state and find the relevant files.

    First, let's look at the repository structure and the relevant code.

  3. DeepSeek Assistant

    Let me look at the key files: the Bedrock model file and the Anthropic model file for comparison.

  4. DeepSeek Assistant

    Let me see the rest of the file, particularly around _map_tool_definition and _customize_tool_def:

  5. DeepSeek Assistant

    Let me see the _map_tool_definition method:

  6. DeepSeek Assistant

    Let me open the file at the right line.

  7. DeepSeek Assistant

    Let me check how the strict field gets populated. Let me look at the ToolDefinition and where it's created:

  8. DeepSeek Assistant

    Let me search for _customize_tool_def in the codebase

  9. DeepSeek Assistant

    Let me look at _customize_tool_def:

  10. DeepSeek Assistant

    Now I see the issue. Let me look at the Anthropic fix mentioned in the issue

  11. DeepSeek Assistant

    Let me look at the Anthropic JsonSchemaTransformer to understand the fix there

  12. DeepSeek Assistant

    Now let me look at the Bedrock JSON schema transformer:

  13. DeepSeek Assistant

    Let me see the full BedrockJsonSchemaTransformer class:

  14. DeepSeek Assistant

    Let me check the base class JsonSchemaTransformer to see the default value of is_strict_compatible

  15. DeepSeek Assistant

    Let me look at the full BedrockJsonSchemaTransformer to see if it has __init__ or __post_init__:

  16. DeepSeek Assistant

    Let me see the base class JsonSchemaTransformer in full

  17. DeepSeek Assistant

    Now let me look at the existing tests for Bedrock to understand the expected behavior and create a reproduce script.

  18. DeepSeek Assistant

    Let me look at relevant tests and also check the provider tests

  19. DeepSeek Assistant

    Let me look at the test file more comprehensively, especially the strict=None tests

  20. DeepSeek Assistant

    Let me look at the relevant tests to understand the current expected behavior

  21. DeepSeek Assistant

    Let me verify where BedrockJsonSchemaTransformer is

  22. DeepSeek Assistant

    Now let me create a script to reproduce the issue:

  23. DeepSeek Assistant

    I need to install the package first or use PYTHONPATH.

  24. DeepSeek Assistant

    Let me install the package dependencies first

  25. DeepSeek Assistant

    Let me try installing with just the slim package without the pydantic-graph dependency constraint

  26. DeepSeek Assistant

    The dependency resolution is failing. Let me check what's available in pyproject.toml and try a different approach.

  27. DeepSeek Assistant

    Now let me install the remaining deps that are available

  28. DeepSeek Assistant

    Let me check the repository structure and install pydantic_graph

  29. DeepSeek Assistant

    Let me install pydantic_graph from the local directory.

  30. DeepSeek Assistant

    Now let me run the reproduce script:

  31. DeepSeek Assistant

    Let me install the remaining dependencies

  32. DeepSeek Assistant

    Let me try a simpler reproduction that directly imports just what we need:

  33. DeepSeek Assistant

    Let me install all missing dependencies more broadly

  34. DeepSeek Assistant

    Let me install all remaining dependencies.

  35. DeepSeek Assistant

    Let me try a different approach to reproduce - directly importing just the relevant module

  36. DeepSeek Assistant

    Now let me try the reproduce script again.

  37. DeepSeek Assistant

    I've successfully reproduced the bug. Now let me implement the fix. The issue is that BedrockJsonSchemaTransformer auto-promotes strict=None tools to strict=True when the schema is simple enough. The fix is to follow the Anthropic transformer's approach: override walk() to only consider is_strict_compatible=True when `strict is True

  38. DeepSeek Assistant

    Let me use the open command to open the file.

  39. DeepSeek Assistant

    Now let me implement the fix. I'll add a walk() override to BedrockJsonSchemaTransformer, similar to the Anthropic fix

  40. DeepSeek Assistant

    Let me try using replace instead

  41. DeepSeek Assistant

    Now let me verify the fix by running the reproduce script again

  42. DeepSeek Assistant

    The fix works for the strict=None case. Let me now test other cases to make sure we haven't broken

  43. DeepSeek Assistant

    Let me also verify the full flow through _customize_tool_def works

  44. DeepSeek Assistant

    Let me now run the existing Bedrock provider tests to verify

  45. DeepSeek Assistant

    Let me install the missing test dependencies.

  46. DeepSeek Assistant

    Let me try running the tests again.

  47. DeepSeek Assistant

    Let me install more dependencies.

  48. DeepSeek Assistant

    The tests are all skipped - likely because they require boto3 or specific environment setup. Let me check the skip

  49. DeepSeek Assistant

    Let me see what imports_successful

  50. DeepSeek Assistant

    Let me install the missing boto3 stub types

  51. DeepSeek Assistant

    The test results confirm our fix is correct. The two failing tests (test_strict_none_preserves_schema and test_strict_none_simple_schema) expected the old auto-promotion behavior, which we're intentionally changing. All other tests pass.

    Now let me also check if there are model-level tests that might be affected

  52. DeepSeek Assistant

    Missing brotli module. Let me install it and re-run.

  53. DeepSeek Assistant

    All 7 strict tool tests pass. Let me also check the other bedrock model

  54. DeepSeek Assistant

    All Bedrock model tests pass. Let me also run the full test suite to make sure nothing else is

  55. DeepSeek Assistant

    Let me focus on the most relevant tests - the models and providers

  56. DeepSeek Assistant

    The only 2 failures are the expected ones testing the auto-promotion behavior we're changing. Let me also run the broader model tests that aren't relevant to strict

  57. DeepSeek Assistant

    All tests pass (the 2 failures are only for the auto-promotion behavior we intentionally changed). Let me verify the final state of the change

  58. DeepSeek Assistant

    Let me also look at the key test test_bedrock_strict_tool_definition_none to understand what it

  59. DeepSeek Assistant

    Everything looks good. Let me clean up the temporary scripts

  60. DeepSeek Assistant

    Let me do a final verification of the change

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