EVEMISSTechnology

Repository guide · source walkthrough · v6

pydantic / pydantic-ai · Source walkthrough

This walkthrough provides a guided reading order through the codebase using static analyzer lessons and call-degree selections across analyzed revision 5b73d7c0da119f12c65b015b15eba3e4d128fca9.

Original repository
pydantic/pydantic-ai
License
MIT · open-source license
Analyzed revision · last verified
5b73d7c0da119f12c65b015b15eba3e4d128fca9 ·

Newer revision observed; the code this guide cites is unchanged. The default branch moved to f06bba53794d, checked 2026-10-03. A revision diff of 39 changed files found no change in the code regions this guide cites. The guide still describes revision 5b73d7c0da11; repository-wide counts (files, calls and so on) refer to that revision.

pydantic/pydantic-ai: Source Walkthrough

Terms used on this page
Entrypoint record
A file the analyzer marks as a place where execution can start. When it carries a __main__ guard excerpt, the file contains an if __name__ == "__main__": block and the excerpt shows what that block calls; without an excerpt, the file was flagged by its name only.
Bounded static execution path
A call chain reconstructed from the source code without running it, stopped after a fixed number of steps. It shows how far the code can be followed on paper, not what happens at run time.
Unresolved boundary
Where a static path stops because the next call goes into an external library or cannot be resolved without running the code. It marks the edge of this analysis, not a defect in the repository.
Static relations
Calls and imports found in the source. "External or unresolved" relations point outside the analyzed files.
Module role
The analyzer's label for a file, inferred from how many calls go in and out (for example core, entry/orchestration, leaf). It describes a position in the call graph, not the authors' design.
Test-like files
Files whose names or locations look like tests. This analysis counts them; it does not run them.
Observed · inferred · author-claimed · unresolved
How each statement is supported: read directly from the analyzed files; derived by the analyzer from them; stated by the repository's authors (metadata, README); or not established by this analysis.
Verified
Two uses on these pages. In an analyzer record ("verified provenance", "a verified entrypoint") it means the record was read directly from the analyzed files, which these guides call observed; for an entrypoint, the __main__ guard text is present. Since the analyzer fix of 2026-10-04, a file that only has an entrypoint-like name such as cli.py or main.py is recorded as inferred; guides analyzed before that still call such a file verified, and it is still only a guess about how the file is used. It does not mean the code was run or tested. "Last verified" is the date the guide last passed the lab's checks against the analysis record of the stated revision; it is not a review of the repository itself.

How to Use This Walkthrough

This walkthrough provides a sequenced reading order through specific files and line addressable blocks in analyzed revision 5b73d7c0da119f12c65b015b15eba3e4d128fca9. Each block is a line-bounded code unit extracted by the static analyzer, and block summaries represent the analyzer's static inferences rather than runtime behaviors.

Stop 1: Orientation

Start with repository landmark modules and file-level containers identified by the analyzer orientation lesson:

  • .claude/skills/testing-skill/parse_cassette.py:1-104: module .claude/skills/testing-skill/parse_cassette.py, file-level container for analyzed code.
  • .github/scripts/agent_provider_health.py:1-1048: module .github/scripts/agent_provider_health.py, file-level container for analyzed code.
  • .github/scripts/agent_spend_report.py:1-589: module .github/scripts/agent_spend_report.py, file-level container for analyzed code.
  • .github/scripts/agentic_workflow_guard.py:1-1240: module .github/scripts/agentic_workflow_guard.py, file-level container for analyzed code.
  • .github/scripts/check_api_compatibility.py:1-156: module .github/scripts/check_api_compatibility.py, file-level container for analyzed code.
  • .github/scripts/ci_duration.py:1-911: module .github/scripts/ci_duration.py, file-level container for analyzed code.

Stop 2: Execution Story

The analyzer reconstructs static execution paths originating at verified entrypoints, including five listed bounded execution path records terminating at unresolved boundaries:

  • .claude/skills/testing-skill/parse_cassette.py:103-104: main_guard __main__, direct-execution guard that gates code when executed directly.
  • .claude/skills/testing-skill/parse_cassette.py:89-100: function main, encapsulates an operation connecting to 8 downstream call or import relations.

Stop 3: Core Code

Six of the analyzer's core-code lesson's eight blocks lie in library code. Note that the library reading set is the AI Frontier lab's selection from static call degree rather than an analyzer lesson.

Module pydantic_ai_slim/pydantic_ai/messages.py is inferred as a service/core candidate with 403 incoming calls and 70 outgoing calls:

  • pydantic_ai_slim/pydantic_ai/messages.py:1429-1701: class BaseToolReturnPart, groups related behavior under one class boundary.
  • pydantic_ai_slim/pydantic_ai/messages.py:4948-5170: class CustomEvent, groups related behavior under one class boundary.

Module pydantic_ai_slim/pydantic_ai/exceptions.py is inferred as a leaf/data-boundary candidate with 421 incoming calls and 0 outgoing calls:

  • pydantic_ai_slim/pydantic_ai/exceptions.py:270-449: class RunCancelled, groups related behavior under one class boundary.
  • pydantic_ai_slim/pydantic_ai/exceptions.py:528-612: class ModelHTTPError, groups related behavior under one class boundary.

Module pydantic_ai_slim/pydantic_ai/_utils.py is inferred as a service/core candidate with 253 incoming calls and 6 outgoing calls:

  • pydantic_ai_slim/pydantic_ai/_utils.py:623-725: class PeekableAsyncStream, groups related behavior under one class boundary.
  • pydantic_ai_slim/pydantic_ai/_utils.py:458-550: function group_by_temporal, encapsulates an operation connecting to 3 downstream relations.

Module pydantic_ai_slim/pydantic_ai/agent/__init__.py is inferred as a service/core candidate with 4 incoming calls and 203 outgoing calls:

  • pydantic_ai_slim/pydantic_ai/agent/__init__.py:476-4290: class Agent, groups related behavior under one class boundary.
  • pydantic_ai_slim/pydantic_ai/agent/__init__.py:1462-2055: function Agent._prepare_run, encapsulates an operation connecting to 108 downstream relations.

Stop 4: Where Changes Ripple

Prioritize these change-guide blocks where the static graph exhibits stronger coupling across library and test code:

  • pydantic_ai_slim/pydantic_ai/exceptions.py:231-239: class UserError, groups related behavior under one class boundary.
  • tests/harness/playwright/test_playwright.py:297-515: class _FakePage (test code), groups related behavior under one class boundary.
  • tests/clai2/menu_script.py:29-30: function pick, encapsulates an operation connecting to 3 downstream relations.
  • tests/clai2/menu_script.py:30-30: straight_line pick, sequential statements inside pick.
  • pydantic_ai_slim/pydantic_ai/models/anthropic.py:2117-2715: function AnthropicModel._map_message, encapsulates an operation connecting to 200 downstream relations.
  • tests/harness/compaction/test_compaction.py:166-167: function _user (test code), encapsulates an operation connecting to 2 downstream relations.

What This Walkthrough Cannot Show

This walkthrough relies strictly on static analysis and cannot resolve dynamic dispatch, reflection, dynamic imports, runtime dependency injection, or framework runtime wiring. In addition, 5 oversized test files exceeded 400 kB and were skipped, relation extraction reached the repository cap of 150000 edges, and 125702 relations remain unresolved external boundaries.

What this analysis could not establish

The writing model's own notes on the analysis record. Identifiers such as lim_3, exec_* or claim_… name records of that analysis; the claims table cites the same records.

  • Five test files exceeding 400 kB were inventoried but skipped during AST parsing.
  • The 150000 relation cap was reached, truncating relation extraction for files analyzed after tests/harness/subagents/test_subagents_disk.py.
Claims and evidence — 32 claims, 32 supported by an independent verifier

Every substantive statement above is a claim bound to grounding IDs of the analyzed revision. Global grounding IDs are namespaced by the analysis run.

Claim Epistemic status Verifier Grounding (global IDs)
c1 The walkthrough covers analyzed revision 5b73d7c0da119f12c65b015b15eba3e4d128fca9. inferred supported analysis_169ebfd40f3abfe7:summary_repository
c2 Line ranges correspond to the analyzer's 94867 line-addressable semantic code blocks. inferred supported analysis_169ebfd40f3abfe7:summary_repository
c3 Block summaries and roles represent static analyzer inferences rather than observed runtime behavior. observed supported analysis_169ebfd40f3abfe7:lim_1
c4 Block block_610b8db2be294c covers lines 1-104 of .claude/skills/testing-skill/parse_cassette.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_610b8db2be294c
c5 Block block_7fb67b5bef103c covers lines 1-1048 of .github/scripts/agent_provider_health.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_7fb67b5bef103c
c6 Block block_d176819f2dcdb4 covers lines 1-589 of .github/scripts/agent_spend_report.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_d176819f2dcdb4
c7 Block block_1e926443ad37a3 covers lines 1-1240 of .github/scripts/agentic_workflow_guard.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_1e926443ad37a3
c8 Block block_c74336943c2c8e covers lines 1-156 of .github/scripts/check_api_compatibility.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_c74336943c2c8e
c9 Block block_74c6b70110ea3b covers lines 1-911 of .github/scripts/ci_duration.py as a module container. inferred supported analysis_169ebfd40f3abfe7:block_74c6b70110ea3b
c10 Five listed bounded execution path records trace from entrypoint .claude/skills/testing-skill/parse_cassette.py:__main__ to external unresolved boundaries. inferred supported analysis_169ebfd40f3abfe7:exec_bb0400b95179, analysis_169ebfd40f3abfe7:exec_9bbb24a4ce38, analysis_169ebfd40f3abfe7:exec_1fdb044ec706, analysis_169ebfd40f3abfe7:exec_06af0227393f, analysis_169ebfd40f3abfe7:exec_5f90db10d033
c11 Entrypoint py_entry_e9ef1059e87f defines a main guard in .claude/skills/testing-skill/parse_cassette.py. observed supported analysis_169ebfd40f3abfe7:py_entry_e9ef1059e87f
c12 Block block_dbf176e51e7398 is the direct-execution main guard spanning lines 103-104 of .claude/skills/testing-skill/parse_cassette.py. inferred supported analysis_169ebfd40f3abfe7:block_dbf176e51e7398
c13 Block block_e0cc5f8a441d6d represents function main on lines 89-100 of .claude/skills/testing-skill/parse_cassette.py. inferred supported analysis_169ebfd40f3abfe7:block_e0cc5f8a441d6d
c14 Six of the core-code lesson's eight blocks lie in library code. inferred supported analysis_169ebfd40f3abfe7:block_a646901394c042, analysis_169ebfd40f3abfe7:block_0c64b717dd30d9, analysis_169ebfd40f3abfe7:block_974a4f1c9da5df, analysis_169ebfd40f3abfe7:block_857c57a8d67cfe, analysis_169ebfd40f3abfe7:block_489173a9f29c14, analysis_169ebfd40f3abfe7:block_625f29f7c7e2cb
c15 The library reading set is selected by the AI Frontier lab from static call degree rather than being an analyzer lesson. inferred supported analysis_169ebfd40f3abfe7:role_190, analysis_169ebfd40f3abfe7:role_172, analysis_169ebfd40f3abfe7:role_91, analysis_169ebfd40f3abfe7:role_94
c16 Module pydantic_ai_slim/pydantic_ai/messages.py is a service/core candidate with 403 incoming and 70 outgoing calls. inferred supported analysis_169ebfd40f3abfe7:role_190
c17 Blocks block_1154cc5cbeabde and block_589c1ab79c748b represent classes BaseToolReturnPart and CustomEvent in pydantic_ai_slim/pydantic_ai/messages.py. inferred supported analysis_169ebfd40f3abfe7:block_1154cc5cbeabde, analysis_169ebfd40f3abfe7:block_589c1ab79c748b
c18 Module pydantic_ai_slim/pydantic_ai/exceptions.py is a leaf/data-boundary candidate with 421 incoming calls and 0 outgoing calls. inferred supported analysis_169ebfd40f3abfe7:role_172
c19 Blocks block_1590c3e07b9d9e and block_705b9caa94c646 represent classes RunCancelled and ModelHTTPError in pydantic_ai_slim/pydantic_ai/exceptions.py. inferred supported analysis_169ebfd40f3abfe7:block_1590c3e07b9d9e, analysis_169ebfd40f3abfe7:block_705b9caa94c646
c20 Module pydantic_ai_slim/pydantic_ai/_utils.py is a service/core candidate with 253 incoming and 6 outgoing calls. inferred supported analysis_169ebfd40f3abfe7:role_91
c21 Blocks block_3892d4364fa080 and block_ae21e27248c017 cover PeekableAsyncStream and group_by_temporal in pydantic_ai_slim/pydantic_ai/_utils.py. inferred supported analysis_169ebfd40f3abfe7:block_3892d4364fa080, analysis_169ebfd40f3abfe7:block_ae21e27248c017
c22 Module pydantic_ai_slim/pydantic_ai/agent/__init__.py is a service/core candidate containing class Agent and function Agent._prepare_run. inferred supported analysis_169ebfd40f3abfe7:role_94, analysis_169ebfd40f3abfe7:block_ec4e9a13cda3b4, analysis_169ebfd40f3abfe7:block_89e742c520d890
c23 Block block_a646901394c042 groups class UserError on lines 231-239 of pydantic_ai_slim/pydantic_ai/exceptions.py. inferred supported analysis_169ebfd40f3abfe7:block_a646901394c042
c24 Block block_ef1005fa0b0eba groups class _FakePage on lines 297-515 of tests/harness/playwright/test_playwright.py. inferred supported analysis_169ebfd40f3abfe7:block_ef1005fa0b0eba
c25 Block block_e625d8fcfd5c8a represents function pick on lines 29-30 of tests/clai2/menu_script.py. inferred supported analysis_169ebfd40f3abfe7:block_e625d8fcfd5c8a
c26 Block block_90f0e9db21fcb7 performs sequential statements on line 30 of tests/clai2/menu_script.py. inferred supported analysis_169ebfd40f3abfe7:block_90f0e9db21fcb7
c27 Block block_0c64b717dd30d9 represents function AnthropicModel._map_message on lines 2117-2715 of pydantic_ai_slim/pydantic_ai/models/anthropic.py. inferred supported analysis_169ebfd40f3abfe7:block_0c64b717dd30d9
c28 Block block_aa108ba947dfe2 represents function _user on lines 166-167 of tests/harness/compaction/test_compaction.py. inferred supported analysis_169ebfd40f3abfe7:block_aa108ba947dfe2
c29 Static analysis does not resolve dynamic imports, reflection, runtime dependency injection, or framework wiring. observed supported analysis_169ebfd40f3abfe7:lim_1
c30 Install and run step inferences are partial and unverified by this analysis. observed supported analysis_169ebfd40f3abfe7:lim_2
c31 Five files over 400 kB were inventoried but not parsed due to analysis bounds. observed supported analysis_169ebfd40f3abfe7:lim_6
c32 Static relation extraction reached the 150000 repository relation limit, and 125702 relations are unresolved or external. observed supported analysis_169ebfd40f3abfe7:lim_6

Sources, rights and disclosure · attribution-license-templates/v0.1

Rights notice. Original repository hosted on GitHub. Repository source code, documentation, names, media, and related project materials remain subject to the rights of their respective authors, contributors, and other rights holders and to applicable repository license terms.

Platform notice. GitHub is the source hosting platform for the linked repository. GitHub and related marks are trademarks of GitHub, Inc. EVEMISS Technology is not affiliated with or endorsed by GitHub unless explicitly stated otherwise.

How this page is produced. This page was produced using revision-aware repository analysis and AI-assisted editorial tooling. Technical claims are tied to the analyzed repository revision and may be revalidated when the source repository changes.

AI-assisted analysis. Reviewed by EVEMISS Technology through human–AI collaborative review. · Report a rights concern · Back to the overview