gentwatch.

← This week all times UTC

AI 3 min read

pydantic‑ai v2.58.0 adds usage accounting rule and timeout controls

pydantic‑ai v2.58.0 released on Oct 17 2026 adds usage accounting for resumed responses and timeout controls, helping teams track costs and avoid hangs.

Abstract network illustration of a node looped back to itself and a broken link symbol amid glowing connections on a dark background.

In short. pydantic‑ai v2.58.0 arrived on Oct 17 2026 and changes usage accounting for resumed suspended responses while removing clai2 session grouping. It also adds timeout, deadline, and new ModelSettings fields for retries and request limits. Teams should review DBOS workflow compatibility before upgrading.

key facts · 7 checked

Version
v2.58.0[S1]
Release date
2026-10-17[S1]
Breaking change
Removed Group `clai2` sessions by project and worktree[S0]
Suspended response accounting
Count usage only in the originating run[S1]
Lines changed
+6379 / -1865[S0]
ModelSettings additions
`max_retries`, `request_timeout`[S1]
DBOS warning
Planning workflows may not recover after upgrade[S1]

our analysis · release diff

[S0]

built by gentwatch from primary data and our own coverage history

Repositorypydantic/pydantic-ai
Comparedv2.57.0 → v2.58.0
Commits119
Files changed300
Lines added / removed+6,379 / -1,865
Contributors6

Breaking-change markers

  • removed: Group `clai2` sessions by project and worktree, keeping removed worktrees under their repository (#10349)

Public API changes

  • modified: .github/scripts/pydantic_ai_gh_aw_shim/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/_cli/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/agent/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/models/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/native_tools/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/profiles/__init__.py
  • modified: pydantic_ai_slim/pydantic_ai/providers/__init__.py
  • modified: pyproject.toml
  • modified: src/pydantic_ai_harness/pydantic_ai_harness/skills/__init__.py
  • modified: src/pydantic_clai2/pydantic_clai2/builtin_plugins/web/__init__.py
  • added: src/pydantic_clai2/pydantic_clai2/builtin_plugins/workspaces/__init__.py

Most-changed files

FileChanges
pydantic_ai_slim/pydantic_ai/realtime/_session.py680
pydantic_ai_slim/pydantic_ai/realtime/_inferred_lifecycle.py667
pydantic_ai_slim/pydantic_ai/models/__init__.py450
pydantic_ai_slim/pydantic_ai/realtime/_core.py291
pydantic_ai_slim/pydantic_ai/models/anthropic.py262

Full comparison on GitHub

What happened

pydantic‑ai v2.58.0 was released on 2026‑10‑17 [S1]. The diff shows 119 commits, six contributors, and 300 files changed, with 6,379 lines added and 1,865 lines removed [S0]. A breaking‑change marker removes the Group clai2 sessions by project and worktree, keeping removed worktrees under their repository (#10349) [S0]. This means code that relied on automatic grouping will no longer find those sessions and must be updated [S0]. The compatibility notes say that a resumed suspended response is counted only in the run that produced it, affecting RunUsage, UsageLimits and SpendLimits [S1]. In practice, this prevents double‑counting of usage when a model pauses and later resumes [S1]. RealtimeConnection now yields lifecycle events through a public pydantic_ai.realtime.lifecycle module [S1]. Developers can now listen for start, stop and error events from a realtime session [S1]. A new DelegationTasks.steer method lets developers steer a running delegated task [S1]. This gives callers a way to change a task’s direction without restarting it [S1]. ModelSettings gains max_retries and request_timeout options [S1]. These settings let users limit how many times a provider call is retried and how long each attempt may take [S1]. Agents can be bounded with a timeout= argument or a RunContext.deadline value [S1]. This adds a hard stop for long‑running agent runs [S1]. DBOS workflows that use Planning may fail to recover after the upgrade; finish any active workflows before upgrading or roll out a new DBOS version [S1].

Why it matters

Removing automatic clai2 session grouping breaks code that relied on project‑level grouping, so developers must adjust session handling or adopt a different pattern [S0]. Teams that use clai2 should audit their session code and test new grouping logic before deployment [S0]. The new accounting rule prevents double‑counting of usage for resumed suspended responses, which can lower unexpected quota spikes and billing surprises [S1]. Operators should check their usage dashboards after the upgrade to confirm the new counts are correct [S1]. Timeout and deadline parameters give operators a way to stop runaway agent runs, protecting compute budgets and improving reliability in production [S1]. Before enabling these limits, verify the typical run duration so legitimate jobs are not cut off early [S1]. The added max_retries and request_timeout settings let teams tune provider interactions without writing custom wrappers, simplifying error handling for unstable endpoints [S1]. Users should test the retry count against their provider’s rate limits to avoid throttling [S1]. The DBOS warning signals that existing event‑stream handlers may lose ordering guarantees; teams using DBOS should plan a staged rollout to avoid state loss [S1]. A safe approach is to pause in‑flight Planning workflows, upgrade, then resume with the new DBOS version [S1]. Overall, the changes tighten resource accounting and give more control over long‑running agent processes.

Background

pydantic‑ai wraps large‑language‑model providers with typed classes, exposing agents, tools, and realtime connections as objects [S0][S1]. The library updates often to match provider API shifts and to add developer‑facing features. Historically, the clai2 component grouped sessions by the surrounding project and worktree, a convenience for monorepo setups. Suspended responses let a model pause execution and wait for external input before resuming; prior releases counted their usage across the whole session. The new rule now counts usage only in the run that produced the response, which changes how quotas are calculated [S1]. DBOS is used to replay events and recover agent state after crashes, relying on ordered Planning events. The release notes warn that DBOS workflows using the Planning status tool with an event_stream_handler might not resume after an upgrade, so finish any active workflows first to avoid losing state [S1].

Caveats and other views

The release notes do not provide a migration guide for the clai2 grouping removal, so developers will need to experiment with alternative session management. The usage rule for suspended responses only applies to new runs; historic usage data remains unchanged. The DBOS warning mentions only Planning workflows, so other DBOS event types may still work but should be tested.

What we don’t know yet

It is unknown whether the clai2 grouping will return in a later minor version. The impact on third‑party libraries that import clai2 internals has not been documented. No performance benchmarks are supplied for the new timeout and deadline features, so their overhead remains unclear.

Questions

4 answered

How does the new compatibility note affect usage accounting for suspended responses?

It changes accounting so that a resumed 'suspended' response is counted only in the run that produced it, affecting RunUsage, UsageLimits and SpendLimits [S1]. This prevents usage from being double‑counted across multiple runs [S1].

Which new ModelSettings options are added in v2.58.0?

ModelSettings now has a `max_retries` option that controls how many retry attempts the provider SDK makes. [S1] It also adds `request_timeout` that covers all attempts and stream consumption of a model request [S1].

What impact does the change have on DBOS workflows using Planning?

Existing DBOS workflows that use `Planning` with an `event_stream_handler` may not recover after upgrading to v2.58.0 [S1]. Users should finish any active workflows before upgrading or roll out a new DBOS version [S1].

How many commits and files changed in the release?

Q: How many commits and files changed in the release? A: The release diff shows 119 commits and 300 files changed, with a net addition of 6,379 lines and removal of 1,865 lines [S0]. Six contributors worked on the update [S0]. The version was released on 2026-10-17 [S1]. It also adds max_retries and request_timeout settings [S1].

Sources

1 cited · 1 primary
  1. S1
    pydantic/pydantic-ai v2.58.0 (2026-10-17)

    Pydantic github.com primary source

cite this story

Theo Varga. "pydantic‑ai v2.58.0 adds usage accounting rule and timeout controls." Gentwatch, October 17, 2026. https://gentwatch.news/pydantic-ai-v2-58-usage-timeout/

Spotted a mistake? Report an error · corrections policy

More from this week.