Better deps typing#2
Merged
samuelcolvin merged 4 commits intomainfrom Oct 12, 2024
Merged
Conversation
cjermain
pushed a commit
to cjermain/pydantic-ai
that referenced
this pull request
Nov 5, 2025
This commit fixes all critical and medium severity bugs identified in the prototype code review: CRITICAL BUG FIXES: 1. Multi-agent usage_history propagation (Bug pydantic#1) - Added usage_history parameter to run(), run_sync(), and iter() methods - Pass usage_history when creating GraphAgentState - Exposed usage_history in RunContext for tools to access - Now tools can pass ctx.usage_history to delegated agents 2. Thread safety for concurrent requests (Bug pydantic#3) - Added asyncio.Lock to UsageHistory class - Made check_per_minute_limits_before_request() async with locking - Made check_per_minute_limits_after_response() async with locking - Prevents race conditions where concurrent requests bypass limits 3. Streaming per-minute limit checks (Bug pydantic#2) - Updated _get_usage_checking_stream_response() to accept usage_history - Added per-minute limit checks during streaming - Pass usage_history from AgentStream to checking function - Now streaming responses properly enforce per-minute limits MEDIUM SEVERITY FIXES: 4. Memory leak prevention (Bug pydantic#4) - Always cleanup old entries, not just when limits are enabled - Prevents unbounded memory growth if limits are toggled 5. Input validation (Bug pydantic#8) - Added validation in UsageLimits.__init__() for negative values - Raises ValueError if any limit is negative TESTING: - All 25 usage limit tests pass - No regressions in existing tests - Ready for integration testing with multi-agent scenarios Changes: - pydantic_ai/usage.py: Thread safety, validation, async methods - pydantic_ai/_agent_graph.py: Async await, memory leak fix - pydantic_ai/_run_context.py: Added usage_history field - pydantic_ai/agent/abstract.py: Added usage_history parameter - pydantic_ai/agent/__init__.py: Pass usage_history to state - pydantic_ai/result.py: Streaming limit checks
thiagohora
pushed a commit
to thiagohora/pydantic-ai
that referenced
this pull request
Feb 10, 2026
5 tasks
1 task
3 tasks
3 tasks
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.
No description provided.