Pydantic AI: Concurrency-limited models can keep their slot when a streamed request ends early
pydantic-ai · pydantic-ai-slim
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| pydantic-ai PyPI |
|
|
| pydantic-ai-slim PyPI |
|
|
pydantic-ai · pydantic-ai-slim
| Product | Affected | Fixed in |
|---|---|---|
| pydantic-ai PyPI |
|
|
| pydantic-ai-slim PyPI |
|
|
Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 2.10.0 until 2.53.0, streamed requests made through ConcurrencyLimitedModel or limit_model_concurrency can retain shared concurrency slots because anyio.CapacityLimiter associates an acquired slot with the borrowing task while streaming cleanup can run in a different task. Early stream termination, cancellation, consumer exceptions, or complete stream_text() consumption with debounce_by=0.1 can therefore leave capacity occupied, eventually preventing later requests that share the long-lived limiter from proceeding and causing a denial of service. Agent-level max_concurrency and non-streaming model requests are not affected. This issue is fixed in version 2.53.0.
From the CVE record · GitHub_M
Streamed requests through ConcurrencyLimitedModel or limit_model_concurrency can leave shared concurrency slots occupied when streaming cleanup runs in a different task. Early termination, cancellation, consumer exceptions, or complete stream_text() consumption with debounce_by=0.1 can eventually block later requests sharing a long-lived limiter. Agent-level max_concurrency and non-streaming requests are not affected.
Check applications using PyPI pydantic-ai or pydantic-ai-slim versions 2.10.0 through versions before 2.53.0.