Skip to content

docs(pydanticai): 10 source-verified class deep dives for v2.46.0 - #346

Merged
CodeHalwell merged 15 commits into
mainfrom
claude/trusting-goodall-a0f5kk
Sep 26, 2026
Merged

CodeHalwell merged 15 commits into
mainfrom
claude/trusting-goodall-a0f5kk

Conversation

@CodeHalwell

@CodeHalwell CodeHalwell commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds pydantic_ai_class_deep_dives_v2_46.md — 10 source-verified class deep dives verified against pydantic-ai 2.46.0 (installed from PyPI, sources read directly)
  • Updates index.mdx: version badge 2.43.0 → 2.46.0, new LinkCard in Reference grid, What's new table, revision history row
  • Updates pydantic_ai_comprehensive_guide.md: version marker 2.43.0 → 2.46.0

Classes documented (with 3–5 runnable code examples each)

# Class / Function Module Key additions
1 FallbackModel models.fallback fallback_on with exception types, async exception handlers, response handlers (ModelResponse-typed callables)
2 FunctionToolset toolsets.function Full constructor: instructions, defer_loading, sequential, requires_approval, id, metadata
3 Output quartet output TextOutput, ToolOutput, NativeOutput, PromptedOutput — comparison table and when-to-use guidance
4 Embedder + EmbeddingResult embeddings Batch embed, Cohere input_type routing, EmbeddingResult fields (embeddings, model_name, usage, cost()), instrument_all
5 MCPToolset v2.46.0 mcp FastMCP 4: URL/path/server/Client inputs, tool_error_behavior, prefer_tasks, cache_tools; allowlisting via FilteredToolset wrapper
6 load_mcp_toolsets mcp JSON mcpServers config, env var ${VAR:-default} expansion, prefix wrapping
7 CombinedToolset toolsets.combined Merging toolsets, name-collision handling, wrapping with FilteredToolset, for_run delegation
8 StructuredDict output Raw JSON schema as output type, $defs inlining, union with Pydantic models
9 ModelSettings lesser-known fields settings parallel_tool_calls, seed, stop_sequences, extra_headers, presence_penalty, logit_bias, extra_body
10 AdvisorTool native_tools Native Anthropic executor/advisor pattern, max_uses, max_tokens, caching, OpenRouter gateway

Sources read directly from installed package

  • pydantic_ai/models/fallback.py
  • pydantic_ai/toolsets/function.py
  • pydantic_ai/output.py
  • pydantic_ai/embeddings/base.py + __init__.py
  • pydantic_ai/mcp.py
  • pydantic_ai/toolsets/combined.py
  • pydantic_ai/settings.py
  • pydantic_ai/native_tools/__init__.py

🤖 Generated with Claude Code

https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J


Generated by Claude Code

Add pydantic_ai_class_deep_dives_v2_46.md covering 10 classes verified
against pydantic-ai 2.46.0 (installed from PyPI):

1. FallbackModel — fallback_on with exception types, async exception
   handlers, and new response handlers (ModelResponse-typed callables)
2. FunctionToolset — full constructor: instructions, defer_loading,
   sequential, requires_approval, id, metadata parameters
3. Output strategy quartet — TextOutput, ToolOutput, NativeOutput,
   PromptedOutput with comparison table and usage guidance
4. Embedder + EmbeddingResult — high-level embedding API, batch embed,
   normalised_embeddings, Cohere input_type routing, instrument_all
5. MCPToolset v2.46.0 (FastMCP 4) — URL/path/server/Client inputs,
   tool_error_behavior, prefer_tasks, cache_tools, allowed_tools
6. load_mcp_toolsets — JSON mcpServers config, env var expansion, prefix
   wrapping, combining with programmatic toolsets
7. CombinedToolset — merging toolsets, name-collision handling, wrapping
   with FilteredToolset, for_run lifecycle delegation
8. StructuredDict — raw JSON schema as output type, $defs inlining,
   union with Pydantic models, loading schema from file
9. ModelSettings lesser-known fields — parallel_tool_calls, seed,
   stop_sequences, extra_headers, presence/frequency_penalty,
   logit_bias, extra_body
10. AdvisorTool — native Anthropic executor/advisor pattern, max_uses,
    on_advisor_turn callback, OpenRouter gateway, comparison table

Sources read directly from installed package:
- pydantic_ai/models/fallback.py
- pydantic_ai/toolsets/function.py
- pydantic_ai/output.py
- pydantic_ai/embeddings/base.py + __init__.py
- pydantic_ai/mcp.py
- pydantic_ai/toolsets/combined.py
- pydantic_ai/settings.py
- pydantic_ai/native_tools/__init__.py

Also update index.mdx and comprehensive guide:
- Version badge 2.43.0 → 2.46.0
- New LinkCard for v2.46.0 deep dives in Reference grid
- What's new table: mark 2.46.0 as Current, add history row
- Revision history: add 2026-09-21 entry with modules consulted

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI lite review requested due to automatic review settings September 21, 2026 07:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T13:11:49.348066Z 739cb09 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14e51e7d7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
- sequential=True: was described as "model must call tools one at a time";
  correct semantics are execution serialization (barrier — no overlap
  within a step). Replace contrived pipeline example with shared-state
  counter that actually benefits from barrier semantics.

- defer_loading=True: was described as "lazy schema generation"; correct
  semantics are that tools are HIDDEN from the model until discovered via
  tool search, load_capability, or ToolReturn.tools. Rewrite example and
  explanation accordingly.

- AdvisorTool OpenRouter example: passed model= twice (positional string
  + keyword OpenRouterProvider()), causing TypeError. Fix by using
  openrouter:-prefixed model strings and dropping the redundant provider
  kwarg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 8 Medium severity

Open (8)
What changed in this PR

Adds a source-verified Pydantic AI v2.46.0 deep-dive page and updates guide versioning/navigation.

Changes:

  • Adds 10 grouped API deep dives with runnable examples.
  • Updates the index reference grid, changelog, and version badge.
  • Bumps comprehensive guide metadata to 2.46.0.
File Description
src/​content/​docs/​pydanticai-guide/​pydantic_ai_comprehensive_guide.md Updated as part of this pull request.
src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md Updated as part of this pull request.
src/​content/​docs/​pydanticai-guide/​index.mdx Updated as part of this pull request.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_comprehensive_guide.md Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 07:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bee400a84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
- defer_loading bullet: fix description to say "hide tools until
  discovered" not "defer schema loading until first use"
- NativeOutput union strict: change strict=True to strict=False;
  undiscriminated root union is rejected by OpenAI strict schemas
- Default output mode comment: drop "implicit ToolOutput" claim;
  agent selects mode from model profile
- StructuredDict signature: fix return annotation type[JsonSchemaValue]
  -> type[dict[str, Any]] (actual runtime type)
- AdvisorTool signature: remove non-existent system_prompt and
  on_advisor_turn fields; add caching field that actually exists
- All AdvisorTool examples: replace native_tools=[advisor] with
  capabilities=[advisor] (Agent has no native_tools= parameter)
- Example 2: replace on_advisor_turn callback example (param doesn't
  exist) with caching='5m' ephemeral context cache example
- OpenRouter example: drop unused OpenRouterProvider import; use
  bare OpenRouter catalog slug for advisor model
- comprehensive_guide.md stamp: clarify 2.46.0 classes are in the
  companion guide, not in this file's addendum

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
- EmbeddingResult.normalised_embeddings(): method does not exist;
  replace with manual normalisation from result.embeddings
- MCPToolset cache_tools default: was False in doc, actual default
  is True; update signature block, parameter table, and example
- MCPToolset allowed_tools: param does not exist; replace with
  FilteredToolset(raw, lambda tool: ...) pattern which is correct
- MCPToolset constructor note: add FilteredToolset to Example 4
  heading and clarify the allowlist belongs at the toolset layer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Several documented API examples and signatures are inaccurate or non-runnable.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (8)
Previously missed (4)

In code that hasn't changed since last review

Medium severity Root union schema is incompatible with strict structured output

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:445

strict=True with [Fruit, Vehicle] creates an undifferentiated root union, which strict structured-output providers reject when the schema contains a root anyOf/oneOf without a discriminator. As written, this advertised runnable example can fail before the model call; remove strict mode or add a discriminator.

Medium severity Remove unsupported AdvisorTool constructor fields

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1374

These fields do not match the current AdvisorTool constructor: the repository's API reference lists model, max_uses, max_tokens, and caching, but not system_prompt or on_advisor_turn. Keeping them here makes the following examples appear source-verified while failing at construction.

Medium severity Register native tools through capabilities

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1398

Native tool specs must be registered through capabilities=[NativeTool(...)]; Agent does not accept a native_tools keyword in this API. As written, this example raises TypeError before it can run, so wrap the advisor with NativeTool and pass it via capabilities.

This issue also appears in the following locations of the same file:

  • line 1429
  • line 1453
Low severity Describe ToolOutput as an explicit tool-based output option

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:390

output_type=SomeModel is not implicitly ToolOutput here: PydanticAI selects the output mode from the model profile, which may be native or prompted. Calling ToolOutput the default makes the selection behavior inaccurate; describe it as the explicit tool-based option instead.

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 08:04
…ing)

The defer_loading example did not show how hidden tools are discovered.
ToolSearch is auto-injected into every agent but passing it explicitly
clarifies the discovery mechanism and allows strategy configuration.
Add ToolSearch() to capabilities= and expand the prose to explain
auto-injection, provider-native search, and local fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43d056bd4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
- FilteredToolset predicate: lambda accepted one arg but signature is
  (RunContext, ToolDefinition); fix lambda to (lambda _ctx, tool: ...)
- logit_bias token_ids: was using cl100k_base hardcoded tokenizer which
  doesn't match gpt-5; use tiktoken.encoding_for_model(model) to derive
  IDs from the exact model's vocabulary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new deep-dive documentation contains unresolved correctness issues and incomplete runnable examples.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity MCPServerHTTP is not a valid legacy transport class

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:675

MCPServerHTTP is not the legacy class named elsewhere in this guide; the removed transport classes are MCPServer, MCPServerStdio, MCPServerSSE, and MCPServerStreamableHTTP. As written, this paragraph names a nonexistent API and omits the actual SSE/streamable-HTTP names.

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 08:18
AdvisorTool extends AbstractNativeTool, not AbstractCapability, so
capabilities=[advisor] does not register it correctly at runtime.
All three AdvisorTool examples now import NativeTool from
pydantic_ai.capabilities and pass NativeTool(advisor).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The deep-dive file contains unresolved moderate issues, including incorrect API guidance and non-runnable examples.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (3)
Previously missed (3)

In code that hasn't changed since last review

Medium severity Verify and document MCPToolset allowed_tools behavior

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:781

allowed_tools is advertised as a v2.46.0 MCPToolset addition in this PR, but this section explicitly says the parameter does not exist and directs users to a wrapper instead. Please verify the installed signature and document the actual allowlist behavior; as written, the page contradicts the API it claims to cover.

Low severity Clarify ToolOutput as an explicit tool-call strategy

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:396

Calling ToolOutput the default here conflicts with the later guidance in this page and with the documented Agent behavior: a bare Pydantic type selects tool/native/prompted mode from the model profile. Please describe ToolOutput as the explicit tool-call strategy so readers do not assume it is always the default.

Low severity Correct the legacy MCP class name

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:681

The legacy MCP class name here is incorrect: the repository's MCP reference names the removed classes as MCPServerStdio, MCPServerSSE, and MCPServerStreamableHTTP; MCPServerHTTP is not the old API name. Correcting this matters because readers may search for or migrate from a class that never existed.

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 08:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81af657565

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
…alls

- defer_loading example: remove claim that ToolSearch is auto-injected;
  describe it as a capability that must be added explicitly, since both
  Codex and Copilot flag the auto-injection claim as inaccurate for
  default agent configurations
- parallel_tool_calls: reframe description from 'ordering matters' to
  'limits fan-out' — the setting caps calls per response to one but
  does not control which tool the model invokes first; update step_b
  docstring to remove the misleading 'depends on A' ordering claim

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Several API, provider, signature, and behavior documentation inaccuracies remain unresolved.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (5)

In code that hasn't changed since last review

Medium severity Reconcile allowed_tools documentation with MCP API

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:781

The PR description lists allowed_tools as a 2.46.0 MCPToolset addition, but this page says the class has no such parameter. The comprehensive reference exposes allowed_tools on the separate MCP capability; reconcile the description and this section so readers know which API supports it.

Medium severity Reconcile on_advisor_turn documentation with source

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1387

The PR description advertises on_advisor_turn as a v2.46.0 AdvisorTool addition, but this source-verified signature and all examples omit it. Please reconcile that claim with the page/source so consumers know whether the callback exists and how to configure it.

Medium severity Add anthropic provider prefix to executor model

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1404

This executor model string lacks the anthropic: provider prefix. Agent model examples in this guide use provider-qualified IDs, so the bare Claude name can be inferred under the wrong provider instead of using Anthropic; prefix it before presenting this as runnable code.

This issue also appears on line 1438 of the same file.

Low severity Document ResponseRejected in handler failure summary

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:202

The failure summary omits response-handler rejection: when a handler rejects every response, the exception group contains ResponseRejected, so except* ModelAPIError alone will not catch that path. Please document that type alongside the exception-handler failures.

Low severity Avoid implying cross-turn tool ordering guarantee

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1218

parallel_tool_calls=False prevents multiple tool calls in one model response, but it does not make the model choose step_a before step_b across separate turns. The current wording and example imply an ordering guarantee that this setting does not provide; ordering needs an explicit application/tool-state constraint.

Copilot AI review requested due to automatic review settings September 21, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The deep-dive guide contains documentation inaccuracies and inconsistencies that should be corrected before approval.

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Add the anthropic provider prefix to the model string

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1404

This Agent model string omits the provider prefix. PydanticAI resolves provider-backed model strings in provider:model-name form, so the bare Claude ID will not select Anthropic as shown in the example. Use the anthropic:-prefixed form here.

This issue also appears on line 1438 of the same file.

Low severity Use the documented MCP server class names

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:682

MCPServerHTTP is not one of the legacy classes documented for this API; the removed classes are MCPServer, MCPServerStdio, MCPServerSSE, and MCPServerStreamableHTTP. Naming the nonexistent class makes it harder for readers to migrate from the actual API. Replace it with the real class names.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a057193a43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
… comment

- Rename response handler fn response_is_empty → response_too_short and
  update docstring; the predicate only catches very-short responses, not
  refusals like "I cannot help with that" (which are >10 chars and would
  not trigger fallback)
- Update section heading: "skip empty or refused answers" → "skip empty
  answers" to match what the code actually does
- Change Ollama PromptedOutput example comment from "# no JSON mode
  support" (wrong for self-hosted Ollama) to "# PromptedOutput works on
  any model, including self-hosted Ollama"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI review requested due to automatic review settings September 21, 2026 08:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate API inaccuracies and cross-document inconsistencies remain.

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Reconcile MCPToolset allowed_tools documentation

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:780

The PR description advertises allowed_tools as a v2.46.0 MCPToolset addition, while this page explicitly says MCPToolset has no such parameter and presents FilteredToolset instead. Reconcile the summary with the verified API (or document the actual allowed_tools surface) so the release notes do not promise a nonexistent constructor argument.

This issue also appears on line 1382 of the same file.

Low severity Replace nonexistent MCPServerHTTP type

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:682

MCPServerHTTP is not the legacy Pydantic AI type used for the HTTP transport; the documented names are MCPServerSSE and MCPServerStreamableHTTP (alongside MCPServerStdio). Using MCPServerHTTP here sends readers searching for a class that does not exist.

Replace nonexistent MCPServerHTTP with the real removed class names:
MCPServerSSE and MCPServerStreamableHTTP (alongside MCPServerStdio).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI review requested due to automatic review settings September 21, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Clarify sequential mode does not prevent cross-run races

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:299

sequential=True only prevents overlap among calls in the same model step; it is not a lock around the module-level counter_state across concurrent runs. Two simultaneous agent.run_sync/run calls can still race, so saying this prevents shared-state race conditions is too broad.

Low severity Fix misleading StructuredDict schema name output

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1106

StructuredDict cannot infer the Python variable name PersonDict; this call does not pass name, and the schema title is Person. The displayed <class 'PersonDict'> is therefore misleading. Pass an explicit name or update the output comment.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87a72a3510

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
- sequential=True: qualify race-condition claim as intra-step only;
  add note that concurrent agent.run() calls need an external lock
- StructuredDict Example 1: pass name='PersonDict' explicitly so the
  type(result.output) comment is accurate (without name=, title from
  schema is used, which would be 'Person' not 'PersonDict')
- AdvisorTool examples: add anthropic: prefix to Agent executor model
  strings ('anthropic:claude-haiku-4-5-20251001') — AdvisorTool.model
  correctly keeps bare Anthropic IDs per its docstring

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI review requested due to automatic review settings September 21, 2026 08:53
OpenAI's response-format JSON-schema name only allows letters, digits,
underscores, and hyphens — spaces cause the request to be rejected.
Change 'Fruit or vehicle' -> 'fruit_or_vehicle'; readable wording is
already in the description field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved documentation and API accuracy issues remain, including an unsafe allowlist example.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Previously missed (2)

In code that hasn't changed since last review

Low severity Document the correct empty-tuple tools default

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:220

The documented default does not match the 2.46.0 constructor: the current API reference shows tools=() (see pydantic_ai_comprehensive_guide.md:3709-3715). Since this is presented as the source signature, use the empty tuple rather than a mutable-list default so readers do not copy an API signature that is not actually present.

Low severity Clarify ToolOutput is an explicit tool-call option

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:396

ToolOutput is not the default for every Pydantic output: a bare output type is resolved from the model profile and may select native, tool, or prompted mode (as the later rule-of-thumb section explains). Reword this cell as the explicit tool-call option to avoid contradicting the page's actual default behavior.

Comment thread src/content/docs/pydanticai-guide/pydantic_ai_class_deep_dives_v2_46.md Outdated
…description

- FilteredToolset example: replace deny-by-prefix predicate with an
  explicit allowlist (TRUSTED_TOOLS set). The old 'not startswith'
  approach would silently expose any future tool whose name doesn't
  start with 'create', which is unsafe for untrusted-user scenarios.
- Output quartet table: reword ToolOutput row from 'Default for Pydantic
  models' to 'Explicit tool-call strategy' — a bare output_type selects
  mode from the model profile, so calling ToolOutput the default
  contradicted the page's own rule-of-thumb section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI review requested due to automatic review settings September 21, 2026 08:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate documentation inconsistencies and example corrections remain.

Review effort: Lite
Findings: None

Resolved since last review (1)

…orrections

- FallbackModel: pass handlers as lists/bare callables; a tuple is always
  parsed as exception types, so tuple-wrapped handlers raised TypeError or
  were silently ignored. Add a gotcha note.
- TextOutput(str.upper) fails at Agent construction; use a def function.
- StructuredDict output type prints <class 'dict'>, not PersonDict.
- ToolSearch is auto-injected; explicit use only configures it.
- CombinedToolset raises on any name clash; prefixing renames to avoid it.

Verified against pydantic-ai 2.46.0 with FunctionModel/TestModel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UbuuyLymfkxVYM5kGzDV53
Copilot AI review requested due to automatic review settings September 26, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Correct inaccurate provider and behavior descriptions, and complete the missing API documentation.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Qualify parallel_tool_calls provider support

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1231

This describes parallel_tool_calls=False as an unconditional runtime guarantee, but ModelSettings is cross-provider and unsupported keys are silently ignored; the comprehensive guide documents that contract at pydantic_ai_comprehensive_guide.md:2988. Qualify this behavior by saying it applies only to providers whose adapter supports the setting.

parallel_tool_calls=False is silently ignored by providers whose
adapter does not support the setting. Add a note so readers know
to verify their target provider before relying on the behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SETmwsc9jV6MkjZfXWQq9J
Copilot AI review requested due to automatic review settings September 26, 2026 13:17
@CodeHalwell
CodeHalwell merged commit a91a223 into main Sep 26, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Documentation inaccuracies and incomplete examples must be corrected before approval.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (3)

In code that hasn't changed since last review

Low severity Incorrect loader documented for deferred FunctionToolset tools

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:218

load_capability loads deferred capabilities, not deferred tools from a FunctionToolset. With defer_loading=True, this toolset's tools are discovered through the ToolSearch path; as written, this bullet sends readers to a loader that cannot load this toolset. Remove the load_capability reference or document a separate capability wrapper.

Low severity Clarify prefer_tasks has no effect with FastMCP 4 servers

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:714

For this FastMCP 4 integration, the prefer_tasks description is misleading: the 2.46.0 MCPToolset source says this preference is a FastMCP 3/SEP-1686 client-side behavior and has no effect for FastMCP 4 servers, which direct task creation themselves. Add that caveat so users do not rely on this flag for FastMCP 4 task routing.

Low severity Lifecycle delegation example uses non-dynamic child toolsets

src/​content/​docs/​pydanticai-guide/​pydantic_ai_class_deep_dives_v2_46.md:1052

This section claims to demonstrate for_run/for_run_step delegation, but both children are ordinary FunctionToolset instances and step_counter only reads ctx.run_step; no child overrides either lifecycle hook or refreshes its tools. As written, the example cannot demonstrate the behavior described. Use a genuinely dynamic child toolset or reframe this as a basic composition example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants