Skip to content

Commit b8406d0

Browse files
authored
Merge branch 'main' into main
2 parents 516e823 + e2ba27a commit b8406d0

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

.github/workflows/after-ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ jobs:
1616
steps:
1717
- uses: astral-sh/setup-uv@v5
1818
with:
19-
enable-cache: true
2019
python-version: "3.12"
20+
enable-cache: true
21+
cache-suffix: smokeshow
2122

2223
- uses: dawidd6/action-download-artifact@v6
2324
with:
@@ -54,8 +55,9 @@ jobs:
5455

5556
- uses: astral-sh/setup-uv@v5
5657
with:
57-
enable-cache: true
5858
python-version: "3.12"
59+
enable-cache: true
60+
cache-suffix: deploy-docs-preview
5961

6062
- uses: dawidd6/action-download-artifact@v6
6163
with:

.github/workflows/ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ jobs:
2626
# Typecheck both Python 3.10 and 3.13. We've had issues due to not checking against both.
2727
python-version: ["3.10", "3.13"]
2828
env:
29-
UV_PYTHON: ${{ matrix.python-version }}
3029
PYRIGHT_PYTHON: ${{ matrix.python-version }}
3130
steps:
3231
- uses: actions/checkout@v4
3332

3433
- uses: astral-sh/setup-uv@v5
3534
with:
35+
python-version: ${{ matrix.python-version }}
3636
enable-cache: true
37+
cache-suffix: lint
3738

3839
- name: Install dependencies
3940
run: uv sync --all-extras --all-packages --group lint
@@ -56,6 +57,7 @@ jobs:
5657
- uses: astral-sh/setup-uv@v5
5758
with:
5859
enable-cache: true
60+
cache-suffix: mypy
5961

6062
- name: Install dependencies
6163
run: uv sync --no-dev --group lint
@@ -70,6 +72,7 @@ jobs:
7072
- uses: astral-sh/setup-uv@v5
7173
with:
7274
enable-cache: true
75+
cache-suffix: docs
7376

7477
- run: uv sync --group docs
7578

@@ -107,6 +110,7 @@ jobs:
107110
- uses: astral-sh/setup-uv@v5
108111
with:
109112
enable-cache: true
113+
cache-suffix: live
110114

111115
- uses: pydantic/ollama-action@v3
112116
with:
@@ -151,16 +155,17 @@ jobs:
151155
- name: all-extras
152156
command: "--all-extras"
153157
env:
154-
UV_PYTHON: ${{ matrix.python-version }}
155158
CI: true
156159
COVERAGE_PROCESS_START: ./pyproject.toml
157160
steps:
158161
- uses: actions/checkout@v4
159162

160163
- uses: astral-sh/setup-uv@v5
161164
with:
165+
python-version: ${{ matrix.python-version }}
162166
enable-cache: true
163167
prune-cache: false
168+
cache-suffix: ${{ matrix.install.name }}
164169

165170
- uses: denoland/setup-deno@v2
166171
with:
@@ -199,16 +204,17 @@ jobs:
199204
matrix:
200205
python-version: ["3.10", "3.11", "3.12", "3.13"]
201206
env:
202-
UV_PYTHON: ${{ matrix.python-version }}
203207
CI: true
204208
COVERAGE_PROCESS_START: ./pyproject.toml
205209
steps:
206210
- uses: actions/checkout@v4
207211

208212
- uses: astral-sh/setup-uv@v5
209213
with:
214+
python-version: ${{ matrix.python-version }}
210215
enable-cache: true
211216
prune-cache: false
217+
cache-suffix: lowest-versions
212218

213219
- uses: denoland/setup-deno@v2
214220
with:
@@ -250,15 +256,16 @@ jobs:
250256
matrix:
251257
python-version: ["3.11", "3.12", "3.13"]
252258
env:
253-
UV_PYTHON: ${{ matrix.python-version }}
254259
CI: true
255260
steps:
256261
- uses: actions/checkout@v4
257262

258263
- uses: astral-sh/setup-uv@v5
259264
with:
265+
python-version: ${{ matrix.python-version }}
260266
enable-cache: true
261267
prune-cache: false
268+
cache-suffix: all-extras
262269

263270
- name: cache HuggingFace models
264271
uses: actions/cache@v4
@@ -288,6 +295,7 @@ jobs:
288295
- uses: astral-sh/setup-uv@v5
289296
with:
290297
enable-cache: true
298+
cache-suffix: dev
291299

292300
- run: uv sync --group dev
293301
- run: uv run coverage combine
@@ -343,6 +351,7 @@ jobs:
343351
- uses: astral-sh/setup-uv@v5
344352
with:
345353
enable-cache: true
354+
cache-suffix: docs-upload
346355

347356
- uses: actions/download-artifact@v4
348357
with:
@@ -384,6 +393,7 @@ jobs:
384393
- uses: astral-sh/setup-uv@v5
385394
with:
386395
enable-cache: true
396+
cache-suffix: deploy-docs-preview
387397

388398
- uses: actions/download-artifact@v4
389399
with:
@@ -431,6 +441,7 @@ jobs:
431441
- uses: astral-sh/setup-uv@v5
432442
with:
433443
enable-cache: true
444+
cache-suffix: release
434445

435446
- run: uv build --all-packages
436447

.github/workflows/claude.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
- uses: astral-sh/setup-uv@v5
3838
with:
3939
enable-cache: true
40+
cache-suffix: claude-code
4041

4142
- uses: denoland/setup-deno@v2
4243
with:

.github/workflows/manually-deploy-docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- uses: astral-sh/setup-uv@v5
1414
with:
1515
enable-cache: true
16+
cache-suffix: docs
1617

1718
- run: uv sync --group docs
1819

@@ -54,6 +55,7 @@ jobs:
5455
- uses: astral-sh/setup-uv@v5
5556
with:
5657
enable-cache: true
58+
cache-suffix: docs-upload
5759

5860
- uses: actions/download-artifact@v4
5961
with:

docs/retries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ client = create_network_resilient_client()
214214

215215
```python {title="custom_retry_logic.py"}
216216
import httpx
217-
from tenacity import stop_after_attempt, wait_exponential
217+
from tenacity import retry_if_exception, stop_after_attempt, wait_exponential
218218

219219
from pydantic_ai.retries import AsyncTenacityTransport, RetryConfig, wait_retry_after
220220

@@ -230,7 +230,7 @@ def create_custom_retry_client():
230230

231231
transport = AsyncTenacityTransport(
232232
config=RetryConfig(
233-
retry=custom_retry_condition,
233+
retry=retry_if_exception(custom_retry_condition),
234234
# Use wait_retry_after for smart waiting on rate limits,
235235
# with custom exponential backoff as fallback
236236
wait=wait_retry_after(

pydantic_ai_slim/pydantic_ai/agent/abstract.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@ async def main():
683683
An async iterable of stream events `AgentStreamEvent` and finally a `AgentRunResultEvent` with the final
684684
run result.
685685
"""
686+
if infer_name and self.name is None:
687+
self._infer_name(inspect.currentframe())
688+
686689
# unfortunately this hack of returning a generator rather than defining it right here is
687690
# required to allow overloads of this method to work in python's typing system, or at least with pyright
688691
# or at least I couldn't make it work without
@@ -696,7 +699,6 @@ async def main():
696699
model_settings=model_settings,
697700
usage_limits=usage_limits,
698701
usage=usage,
699-
infer_name=infer_name,
700702
toolsets=toolsets,
701703
builtin_tools=builtin_tools,
702704
)
@@ -713,7 +715,6 @@ async def _run_stream_events(
713715
model_settings: ModelSettings | None = None,
714716
usage_limits: _usage.UsageLimits | None = None,
715717
usage: _usage.RunUsage | None = None,
716-
infer_name: bool = True,
717718
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
718719
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
719720
) -> AsyncIterator[_messages.AgentStreamEvent | AgentRunResultEvent[Any]]:
@@ -739,7 +740,7 @@ async def run_agent() -> AgentRunResult[Any]:
739740
model_settings=model_settings,
740741
usage_limits=usage_limits,
741742
usage=usage,
742-
infer_name=infer_name,
743+
infer_name=False,
743744
toolsets=toolsets,
744745
builtin_tools=builtin_tools,
745746
event_stream_handler=event_stream_handler,

tests/test_streaming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ async def ret_a(x: str) -> str:
18171817
return f'{x}-apple'
18181818

18191819
events = [event async for event in test_agent.run_stream_events('Hello')]
1820+
assert test_agent.name == 'test_agent'
18201821

18211822
assert events == snapshot(
18221823
[

0 commit comments

Comments
 (0)