Repository navigation
Correct usage_limits=None docstring on AgentOperator and LLMOperator - #74307
Merged
Merged
Conversation
usage_limits=None does not disable limits: pydantic-ai substitutes UsageLimits() for None, so its default request_limit=50 still applies.
shahar1
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
usage_limitsdocstrings onAgentOperatorandLLMOperatorsayNone(the default) "means no enforcement". That is wrong: pydantic-ai replacesNonewithUsageLimits()(usage_limits = usage_limits or UsageLimits()inAgent.iter), so its defaultrequest_limit=50still applies and a long tool loop fails withUsageLimitExceededat 50 requests. That is the failure the run captured in #74297 hit withusage_limitsunset.The docstrings now say
Nonesets no token, cost, or tool-call limits but keeps the 50-request cap. TheLLMOperatordocstring also drops the sentence implying that moving fromNoneto acost_limit-only dict newly introduces the cap. Both already have it. TheLLM*operators that inheritusage_limitsfromLLMOperatorpick up the fix, and the how-to pages already describe the default correctly.Checked against
pydantic-ai-slim2.33.0 (the provider's floor) and 2.48.0: aFunctionModelthat always calls a tool raisesUsageLimitExceeded: The next request would exceed the request_limit of 50withusage_limits=None, andUsageLimits(request_limit=None)runs past 50 requests.{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.