Skip to content

Commit f5a0a15

Browse files
cvanderschuereakenarsaritonyxwzDouweMethan01x
authored
Update to v0.7.2 (#9)
* Add `priority` `service_tier` to `OpenAIModelSettings` and respect it in `OpenAIResponsesModel` (pydantic#2368) * Add an example of using RunContext to pass data among tools (pydantic#2316) Co-authored-by: Douwe Maan <[email protected]> * Rename gemini-2.5-flash-lite-preview-06-17 to gemini-2.5-flash-lite as it's out of preview (pydantic#2387) * Fix toggleable toolset example so toolset state is not shared across agent runs (pydantic#2396) * Support custom thinking tags specified on the model profile (pydantic#2364) Co-authored-by: jescudero <[email protected]> Co-authored-by: Douwe Maan <[email protected]> * Add convenience functions to handle AG-UI requests with request-specific deps (pydantic#2397) * docs: add missing optional packages in `install.md` (pydantic#2412) * Include default values in tool arguments JSON schema (pydantic#2418) * Fix "test_download_item_no_content_type test fails on macOS" (pydantic#2404) * Allow string format, pattern and others in OpenAI strict JSON mode (pydantic#2420) * Let more `BaseModel`s use OpenAI strict JSON mode by defaulting to `additionalProperties=False` (pydantic#2419) * BREAKING CHANGE: Change type of 'source' field on EvaluationResult (pydantic#2388) Co-authored-by: Douwe Maan <[email protected]> * Fix ImageUrl, VideoUrl, AudioUrl and DocumentUrl not being serializable (pydantic#2422) * BREAKING CHANGE: Support printing reasons in the console output for pydantic-evals (pydantic#2163) * Document performance implications of async vs sync tools (pydantic#2298) Co-authored-by: Douwe Maan <[email protected]> * Mention that tools become toolset internally (pydantic#2395) Co-authored-by: Douwe Maan <[email protected]> * Fix tests for Logfire>=3.22.0 (pydantic#2346) * tests: speed up the test suite (pydantic#2414) * google: add more information about schema on union (pydantic#2426) * typo in output docs (pydantic#2427) * Deprecate `GeminiModel` in favor of `GoogleModel` (pydantic#2416) * Use `httpx` on `GoogleProvider` (pydantic#2438) * Remove older deprecated models and add new model of Anthropic (pydantic#2435) * Remove `next()` method from `Graph` (pydantic#2440) * BREAKING CHANGE: Remove `data` from `FinalResult` (pydantic#2443) * BREAKING CHANGE: Remove `get_data` and `validate_structured_result` from `StreamedRunResult` (pydantic#2445) * docs: add `griffe_warnings_deprecated` (pydantic#2444) * BREAKING CHANGE: Remove `format_as_xml` module (pydantic#2446) * BREAKING CHANGE: Remove `result_type` parameter and similar from `Agent` (pydantic#2441) * Deprecate `GoogleGLAProvider` and `GoogleVertexProvider` (pydantic#2450) * BREAKING CHANGE: drop 4 months old deprecation warnings (pydantic#2451) * Automatically use OpenAI strict mode for strict-compatible native output types (pydantic#2447) * Make `InlineDefsJsonSchemaTransformer` public (pydantic#2455) * Send `ThinkingPart`s back to Anthropic used through Bedrock (pydantic#2454) * Bump boto3 to support `AWS_BEARER_TOKEN_BEDROCK` API key env var (pydantic#2456) * Add new Heroku models (pydantic#2459) * Add `builtin_tools` to `Agent` (pydantic#2102) Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: Douwe Maan <[email protected]> * Bump mcp-run-python (pydantic#2470) * Remove fail_under from top-level coverage config so <100% html-coverage step doesn't end CI run (pydantic#2475) * Add AbstractAgent, WrapperAgent, Agent.event_stream_handler, Toolset.id, Agent.override(tools=...) in preparation for Temporal (pydantic#2458) * Let toolsets be built dynamically based on run context (pydantic#2366) Co-authored-by: Douwe Maan <[email protected]> * Add ToolsetFunc to API docs (fix CI) (pydantic#2486) * tests: change time of evals example (pydantic#2501) * ci: remove html and xml reports (pydantic#2491) * fix: Add gpt-5 models to reasoning model detection for temperature parameter handling (pydantic#2483) Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Douwe Maan <[email protected]> Co-authored-by: Marcelo Trylesinski <[email protected]> * History processor replaces message history (pydantic#2324) Co-authored-by: Marcelo Trylesinski <[email protected]> * ci: split test suite (pydantic#2436) Co-authored-by: Douwe Maan <[email protected]> * ci: use the right install command (pydantic#2506) * Update config.yaml (pydantic#2514) * Skip testing flaky evals example (pydantic#2518) * Fix error when parsing usage details for video without audio track in Google models (pydantic#2507) * Make OpenAIResponsesModelSettings.openai_builtin_tools work again (pydantic#2520) * Let Agent be run in a Temporal workflow by moving model requests, tool calls, and MCP to Temporal activities (pydantic#2225) * Install only dev in CI (pydantic#2523) * Improve CLAUDE.md (pydantic#2524) * Add best practices regarding to coverage to CLAUDE.md (pydantic#2527) * Add support for `"openai-responses"` model inference string (pydantic#2528) Co-authored-by: Claude <[email protected]> * docs: Confident AI (pydantic#2529) * chore: mention what to do with the documentation when deprecating a class (pydantic#2530) * chore: drop hyperlint (pydantic#2531) * ci: improve matrix readability (pydantic#2532) * Add pip to dev deps for PyCharm (pydantic#2533) Co-authored-by: Marcelo Trylesinski <[email protected]> * Add genai-prices to dev deps and a basic test (pydantic#2537) * Add `--durations=100` to all pytest calls in CI (pydantic#2534) * Cleanup snapshot in test_evaluate_async_logfire (pydantic#2538) * Make some minor tweaks to the temporal docs (pydantic#2522) Co-authored-by: Douwe Maan <[email protected]> * Add new OpenAI GPT-5 models (pydantic#2503) * Fix `FallbackModel` to respect each model's model settings (pydantic#2540) * Add support for OpenAI verbosity parameter in Responses API (pydantic#2493) Co-authored-by: Claude <[email protected]> Co-authored-by: Douwe Maan <[email protected]> * Add `UsageLimits.count_tokens_before_request` using Gemini `count_tokens` API (pydantic#2137) Co-authored-by: Douwe Maan <[email protected]> * chore: Fix uv.lock (pydantic#2546) * Stop calling MCP server `get_tools` ahead of `agent run` span (pydantic#2545) * Disable instrumentation by default in tests (pydantic#2535) Co-authored-by: Marcelo Trylesinski <[email protected]> * Only wrap necessary parts of type aliases in forward annotations (pydantic#2548) * Remove anthropic-beta default header set in `AnthropicModel` (pydantic#2544) Co-authored-by: Marcelo Trylesinski <[email protected]> * docs: Clarify why AG-UI example links are on localhost (pydantic#2549) * chore: Fix path to agent class in CLAUDE.md (pydantic#2550) * Ignore leading whitespace when streaming from Qwen or DeepSeek (pydantic#2554) * Ask model to try again if it produced a response without text or tool calls, only thinking (pydantic#2556) Co-authored-by: Douwe Maan <[email protected]> * chore: Improve Temporal test to check trace as tree instead of list (pydantic#2559) * Fix: Forward max_uses parameter to Anthropic WebSearchTool (pydantic#2561) * Let message history end on ModelResponse and execute pending tool calls (pydantic#2562) * Fix type issues * skip tests requiring API keys * add `google-genai` dependency * add other provider deps * add pragma: no cover for untested logic --------- Co-authored-by: akenar <[email protected]> Co-authored-by: Tony Woland <[email protected]> Co-authored-by: Douwe Maan <[email protected]> Co-authored-by: Yi-Chen Lin <[email protected]> Co-authored-by: José I. Escudero <[email protected]> Co-authored-by: jescudero <[email protected]> Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: William Easton <[email protected]> Co-authored-by: David Montague <[email protected]> Co-authored-by: Guillermo <[email protected]> Co-authored-by: Hamza Farhan <[email protected]> Co-authored-by: Mohamed Amine Zghal <[email protected]> Co-authored-by: Yinon Ehrlich <[email protected]> Co-authored-by: Matthew Brandman <[email protected]> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Douwe Maan <[email protected]> Co-authored-by: Alex Enrique <[email protected]> Co-authored-by: Jerry Yan <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Mayank <[email protected]> Co-authored-by: Alex Hall <[email protected]> Co-authored-by: Jerry Lin <[email protected]> Co-authored-by: Raymond Xu <[email protected]> Co-authored-by: kauabh <[email protected]> Co-authored-by: Victorien <[email protected]> Co-authored-by: Ethan Brooks <[email protected]> Co-authored-by: eballesteros <[email protected]>
1 parent 512ac55 commit f5a0a15

File tree

249 files changed

+23553
-5569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+23553
-5569
lines changed

.claude/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(rg:*)",
5+
"Bash(make:*)",
6+
"Bash(uv run pytest:*)",
7+
"Bash(uv run:*)",
8+
"Bash(git push:*)",
9+
"Bash(git checkout:*)",
10+
"Bash(gh pr create:*)",
11+
"Bash(gh pr view:*)",
12+
"Bash(git add:*)",
13+
"Bash(git commit:*)",
14+
"Bash(gh pr comment:*)",
15+
"Bash(gh pr checks:*)",
16+
"Bash(gh run view:*)",
17+
"Bash(gh pr list:*)",
18+
"Bash(gh api:*)",
19+
"Bash(pre-commit run:*)",
20+
"Bash(grep:*)",
21+
"Bash(find:*)",
22+
"Bash(coverage:*)"
23+
],
24+
"deny": []
25+
}
26+
}

.github/ISSUE_TEMPLATE/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
blank_issues_enabled: true
1+
blank_issues_enabled: false
22
contact_links:
33
- name: 💬 Join Slack
44
url: 'https://logfire.pydantic.dev/docs/help/#slack'

.github/workflows/ci.yml

Lines changed: 87 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ jobs:
7171
# always build docs to check it works without insiders packages
7272
- run: make docs
7373

74-
- run: make docs-insiders
75-
if: github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main'
74+
- name: Build docs with insiders packages
75+
run: make docs-insiders
76+
if: (github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main') && env.PPPR_TOKEN != ''
7677
env:
7778
PPPR_TOKEN: ${{ secrets.PPPR_TOKEN }}
7879

@@ -107,6 +108,7 @@ jobs:
107108
with:
108109
model: qwen2:0.5b
109110

111+
- run: uv sync --only-dev
110112
- run: >
111113
uv run
112114
--package pydantic-ai-slim
@@ -130,16 +132,24 @@ jobs:
130132
CO_API_KEY: ${{ secrets.COHERE_API_KEY }}
131133
132134
test:
133-
name: test on ${{ matrix.python-version }}
135+
name: test on ${{ matrix.python-version }} (${{ matrix.install.name }})
134136
runs-on: ubuntu-latest
135137
timeout-minutes: 10
136138
strategy:
137139
fail-fast: false
138140
matrix:
139141
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
142+
install:
143+
- name: pydantic-ai-slim
144+
command: "--package pydantic-ai-slim"
145+
- name: standard
146+
command: ""
147+
- name: all-extras
148+
command: "--all-extras"
140149
env:
141150
UV_PYTHON: ${{ matrix.python-version }}
142151
CI: true
152+
COVERAGE_PROCESS_START: ./pyproject.toml
143153
steps:
144154
- uses: actions/checkout@v4
145155

@@ -151,42 +161,88 @@ jobs:
151161
with:
152162
deno-version: v2.x
153163

154-
- run: mkdir coverage
164+
- run: mkdir .coverage
155165

156-
# run tests with just `pydantic-ai-slim` dependencies
157-
- run: uv run --package pydantic-ai-slim coverage run -m pytest
166+
- run: uv sync --only-dev
167+
- run: uv run ${{ matrix.install.command }} coverage run -m pytest --durations=100 -n auto --dist=loadgroup
158168
env:
159-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-slim
169+
COVERAGE_FILE: .coverage/.coverage.${{ matrix.python-version }}-${{ matrix.install.name }}
160170

161-
- run: uv run coverage run -m pytest
162-
env:
163-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-standard
171+
- name: store coverage files
172+
uses: actions/upload-artifact@v4
173+
if: matrix.python-version != '3.9'
174+
with:
175+
name: coverage-${{ matrix.python-version }}-${{ matrix.install.name }}
176+
path: .coverage
177+
include-hidden-files: true
164178

165-
- run: uv run --all-extras coverage run -m pytest
166-
env:
167-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-all-extras
179+
test-lowest-versions:
180+
name: test on ${{ matrix.python-version }} (lowest-versions)
181+
runs-on: ubuntu-latest
182+
timeout-minutes: 10
183+
strategy:
184+
fail-fast: false
185+
matrix:
186+
python-version: ["3.10", "3.11", "3.12", "3.13"]
187+
env:
188+
UV_PYTHON: ${{ matrix.python-version }}
189+
CI: true
190+
COVERAGE_PROCESS_START: ./pyproject.toml
191+
steps:
192+
- uses: actions/checkout@v4
168193

169-
- run: uv run --all-extras python tests/import_examples.py
194+
- uses: astral-sh/setup-uv@v5
195+
with:
196+
enable-cache: true
170197

171-
# this must run last as it modifies the environment!
172-
- name: test lowest versions
173-
if: matrix.python-version != '3.9'
174-
run: |
175-
unset UV_FROZEN
176-
uv run --all-extras --resolution lowest-direct coverage run -m pytest
198+
- uses: denoland/setup-deno@v2
199+
with:
200+
deno-version: v2.x
201+
202+
- run: mkdir .coverage
203+
204+
- run: uv sync --group dev
205+
206+
- run: unset UV_FROZEN
207+
208+
- run: uv run --all-extras --resolution lowest-direct coverage run -m pytest --durations=100 -n auto --dist=loadgroup
177209
env:
178-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-lowest-versions
210+
COVERAGE_FILE: .coverage/.coverage.${{matrix.python-version}}-lowest-versions
179211

180212
- name: store coverage files
181213
uses: actions/upload-artifact@v4
182214
with:
183-
name: coverage-${{ matrix.python-version }}
184-
path: coverage
215+
name: coverage-${{ matrix.python-version }}-lowest-versions
216+
path: .coverage
185217
include-hidden-files: true
186218

219+
test-examples:
220+
name: test examples on ${{ matrix.python-version }}
221+
runs-on: ubuntu-latest
222+
timeout-minutes: 10
223+
strategy:
224+
fail-fast: false
225+
matrix:
226+
python-version: ["3.11", "3.12", "3.13"]
227+
env:
228+
UV_PYTHON: ${{ matrix.python-version }}
229+
CI: true
230+
steps:
231+
- uses: actions/checkout@v4
232+
233+
- uses: astral-sh/setup-uv@v5
234+
with:
235+
enable-cache: true
236+
237+
- uses: denoland/setup-deno@v2
238+
with:
239+
deno-version: v2.x
240+
241+
- run: uv run --all-extras python tests/import_examples.py
242+
187243
coverage:
188244
runs-on: ubuntu-latest
189-
needs: [test]
245+
needs: [test, test-lowest-versions]
190246
steps:
191247
- uses: actions/checkout@v4
192248
with:
@@ -197,38 +253,19 @@ jobs:
197253
uses: actions/download-artifact@v4
198254
with:
199255
merge-multiple: true
200-
path: coverage
256+
path: .coverage
201257

202258
- uses: astral-sh/setup-uv@v5
203259
with:
204260
enable-cache: true
205261

206-
- run: uv sync --package pydantic-ai-slim --only-dev
207-
- run: rm coverage/.coverage.*-py3.9-* # Exclude 3.9 coverage as it gets the wrong line numbers, causing invalid failures.
208-
- run: uv run coverage combine coverage
262+
- run: uv sync --group dev
263+
- run: uv run coverage combine
264+
- run: uv run coverage report
209265

210-
- run: uv run coverage html --show-contexts --title "Pydantic AI coverage for ${{ github.sha }}"
211-
212-
- name: Store coverage html
213-
uses: actions/upload-artifact@v4
214-
with:
215-
name: coverage-html
216-
path: htmlcov
217-
include-hidden-files: true
218-
219-
- run: uv run coverage xml
220-
221-
- run: uv run diff-cover coverage.xml --html-report index.html
222-
223-
- name: Store diff coverage html
224-
uses: actions/upload-artifact@v4
225-
with:
226-
name: diff-coverage-html
227-
path: index.html
228-
229-
- run: uv run coverage report --fail-under 100
230-
- run: uv run diff-cover coverage.xml --fail-under 100
231266
- run: uv run strict-no-cover
267+
env:
268+
COVERAGE_FILE: .coverage/.coverage
232269

233270
test-mcp-run-python:
234271
runs-on: ubuntu-latest
@@ -256,7 +293,7 @@ jobs:
256293
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
257294
check:
258295
if: always()
259-
needs: [lint, mypy, docs, test-live, test, coverage, test-mcp-run-python]
296+
needs: [lint, mypy, docs, test-live, test, test-lowest-versions, test-examples, coverage, test-mcp-run-python]
260297
runs-on: ubuntu-latest
261298

262299
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ node_modules/
1919
**.idea/
2020
.coverage*
2121
/test_tmp/
22+
.mcp.json

.hyperlint/config.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

CLAUDE.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,23 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
55
## Development Commands
66

77
### Core Development Tasks
8+
89
- **Install dependencies**: `make install` (requires uv, pre-commit, and deno)
9-
- **Run all checks**: `make` (format, lint, typecheck, test with coverage)
10-
- **Format code**: `make format`
11-
- **Lint code**: `make lint`
12-
- **Type checking**: `make typecheck` (uses pyright) or `make typecheck-both` (pyright + mypy)
13-
- **Run tests**: `make test` (with coverage) or `make test-fast` (parallel, no coverage)
10+
- **Run all checks**: `pre-commit run --all-files`
11+
- **Run tests**: `make test`
1412
- **Build docs**: `make docs` or `make docs-serve` (local development)
1513

1614
### Single Test Commands
15+
1716
- **Run specific test**: `uv run pytest tests/test_agent.py::test_function_name -v`
1817
- **Run test file**: `uv run pytest tests/test_agent.py -v`
1918
- **Run with debug**: `uv run pytest tests/test_agent.py -v -s`
2019

21-
### Multi-Python Testing
22-
- **Install all Python versions**: `make install-all-python`
23-
- **Test all Python versions**: `make test-all-python`
24-
2520
## Project Architecture
2621

2722
### Core Components
2823

29-
**Agent System (`pydantic_ai_slim/pydantic_ai/agent.py`)**
24+
**Agent System (`pydantic_ai_slim/pydantic_ai/agent/`)**
3025
- `Agent[AgentDepsT, OutputDataT]`: Main orchestrator class with generic types for dependency injection and output validation
3126
- Entry points: `run()`, `run_sync()`, `run_stream()` methods
3227
- Handles tool management, system prompts, and model interaction
@@ -125,3 +120,43 @@ This is a uv workspace with multiple packages:
125120
- **Lock file**: `uv.lock` (commit this file)
126121
- **Sync command**: `make sync` to update dependencies
127122
- **Optional extras**: Define groups in `pyproject.toml` optional-dependencies
123+
124+
## Best Practices
125+
126+
This is the list of best practices for working with the codebase.
127+
128+
### Rename a class
129+
130+
When asked to rename a class, you need to rename the class in the code and add a deprecation warning to the old class.
131+
132+
```python
133+
from typing_extensions import deprecated
134+
135+
class NewClass: ... # This class was renamed from OldClass.
136+
137+
@deprecated("Use `NewClass` instead")
138+
class OldClass(NewClass): ...
139+
```
140+
141+
In the test suite, you MUST use the `NewClass` instead of the `OldClass`, and create a new test to verify the
142+
deprecation warning:
143+
144+
```python
145+
def test_old_class_is_deprecated():
146+
with pytest.warns(DeprecationWarning, match="Use `NewClass` instead"):
147+
OldClass()
148+
```
149+
150+
In the documentation, you should not have references to the old class, only the new class.
151+
152+
### Writing documentation
153+
154+
Always reference Python objects with the "`" (backticks) around them, and link to the API reference, for example:
155+
156+
```markdown
157+
The [`Agent`][pydantic_ai.agent.Agent] class is the main entry point for creating and running agents.
158+
```
159+
160+
### Coverage
161+
162+
Every pull request MUST have 100% coverage. You can check the coverage by running `make test`.

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,10 @@ typecheck-both: typecheck-pyright typecheck-mypy
6060

6161
.PHONY: test
6262
test: ## Run tests and collect coverage data
63-
uv run coverage run -m pytest
63+
uv run coverage run -m pytest -n auto --dist=loadgroup
64+
@uv run coverage combine
6465
@uv run coverage report
6566

66-
.PHONY: test-fast
67-
test-fast: ## Same as test except no coverage and 4x faster depending on hardware
68-
uv run pytest -n auto --dist=loadgroup
69-
7067
.PHONY: test-all-python
7168
test-all-python: ## Run tests on Python 3.9 to 3.13
7269
UV_PROJECT_ENVIRONMENT=.venv39 uv run --python 3.9 --all-extras --all-packages coverage run -p -m pytest

0 commit comments

Comments
 (0)