Back Home

代理框架/開發工具

Pydantic AI 2.41/2.42 Integrates Codex and Copilot, Tightens Validation of Deferred Tool Approval Data

Two consecutive releases add a direct image generation API and providers for ChatGPT/Codex subscription access and GitHub Copilot’s compatible endpoint. Version 2.42 also rejects malformed deferred tool approval results, so upgrading may cause agent workflows previously accepted under lenient validation to fail outright.

Software by Microsoft · Public domain · Image source
zh-Hant

Pydantic AI released versions 2.41.0 and 2.42.0 within roughly 24 hours. The focus is not another layer of chat abstractions, but bringing more model entry points and tool execution data under a unified, typed interface. The [2.41.0 release notes](https://github.com/pydantic/pydantic-ai/releases/tag/v2.41.0) introduce a standalone `ImageGenerator` API, allowing applications to invoke image generation without first creating a complete Agent loop. The release also adds the `openai-codex` provider, which connects to the service using ChatGPT/Codex subscription authentication. Meanwhile, the `fallback_model` option previously used by `ImageGeneration` and `XSearch` is being deprecated in favor of `fallback_subagent_model`, making it clearer that the fallback executor is not an ordinary model parameter but a subagent with its own execution path.

The following day, [2.42.0](https://github.com/pydantic/pydantic-ai/releases/tag/v2.42.0) added `GitHubCopilotProvider`, which connects to Copilot’s OpenAI-compatible API. For teams using multiple subscription-based model entry points, this can reduce the need for custom transport adapters. However, “OpenAI-compatible” still does not guarantee complete equivalence in tool calling, sampling parameters, error codes, or billing information. The release also fixes Bedrock Converse’s handling of sampling settings disabled by Anthropic, preserves Anthropic recovery information in normalized history, and directly expands JSON Schema `$ref` references that point to non-object types in code-mode function signatures, preventing some providers from rejecting tool schemas.

The change that most warrants upgrade testing concerns `DeferredToolResults.approvals`: version 2.42 rejects invalid approval values instead of allowing nonconforming data to continue into the agent recovery path. This helps prevent ambiguous semantics among human approvals, external work queues, and agent state, but it is also listed by the project as a compatibility consideration. Serialized data that relied on the previous lenient parsing may now produce errors during recovery. `ToolReturnContent` validation has also been changed to avoid making a Python call for every JSON node, reducing framework overhead, although the project has not published end-to-end agent throughput figures. PyPI shows that the [2.42.0 package](https://pypi.org/project/pydantic-ai/2.42.0/) was uploaded on September 9 through trusted publishing. Engineering teams should pay particular attention to regression-testing existing approval records, cross-provider tool schemas, cost tracking, and subscription credential lifecycles.

Sources

  1. Pydantic AI v2.41.0 release
  2. Pydantic AI v2.42.0 release
  3. pydantic-ai 2.42.0