Don't show the first-run banner for runs an installed package starts
Why we make these changes
The first-run banner shows on the first uninstrumented run in a process, whoever starts it, so libraries and platforms built on Pydantic AI switch it off in production code for their own users: Airflow ("would land in the task log as ERROR lines"), Baserow, Code Puppy, Converge, Funes, and code-graph-rag, which filed it as a bug. Decided by @DouweM: stay quiet when a library runs agents, show for an application.
Design. When a run starts, the first frame outside Pydantic AI and the standard library decides it: if that frame is in site-packages or dist-packages, the run gets no banner and doesn't use up the once-per-process claim, so the user's own agent later in the same process still shows it. Where the starter can't be attributed, the banner shows as it does today: where the chain of coroutines ends (or at an anyio/trio task wrapper), the frames below belong to whatever drives the loop (uvicorn, ipykernel). run_stream_events() decides in the stack of whoever iterates it, because the run itself happens in a task of its own, and a run a UI adapter streams counts as the user's app. Rejected options: deciding at Agent(...) construction (it misattributes agents a library builds for the user, and the reverse), and deciding when the banner is displayed (the stack has crossed a task boundary by then).
For the maintainer: an app that hands agent.run to a framework which awaits it in the same coroutine chain, like Starlette's BackgroundTasks.add_task(agent.run, ...), is attributed to the framework and gets no banner. Telling that apart from a library awaiting its own run would need more than the stack.
New public surface
None.
User-visible behavior
| Run started by | Before | After |
|---|---|---|
An installed package (e.g. airflow.providers..., a uv tool CLI) | banner | none, claim kept |
| Your own script, notebook, app, thread, anyio task, or a UI adapter served by your app | banner | banner |
Verification
Tests in tests/test_display.py: sync run from an installed package, run() and run_stream_events() from one, a UI adapter behind an installed server, a server loop, an anyio task group and a thread. The wait_for case is a parametrization of the async test. I checked 13 scenarios with an inline script.
What changes for existing users
Libraries and platforms built on Pydantic AI no longer show their users our banner; application users see no change.
PR decisions
2026-10-29 · Decide library-vs-application by the run's call stack · iter -
- Decision: first frame outside pydantic_ai/pydantic_graph/stdlib at _prepare_run; site-packages or dist-packages means library; a starter past an event loop not driven by our sync methods keeps the banner
- Why: construction site misattributes library-built agents; display time crosses task boundaries; unknown falls back to today's behavior
- Source: https://github.com/pydantic/pydantic-ai/tree/banner-quiet-in-libraries
2026-10-29 · pre-push review 1 of 3 at aaa15dde6422718d7fe85eb06a77aa72f1cc6b56 · iter -
- Decision: remediated: event-loop boundary falls back to showing; walk gated on no instrumentation; private-helper test replaced by thread and server-loop tests; async test docstring. Not done: run_stream_events/UI-adapter runs a library starts still show the banner (question for Douwe)
- Why: reviewed tree 2a3f8288fca0e3ad6b45cca27254ef2b82cb72d8; scope d78880e6f6..aaa15dde64 full branch
- Source: https://github.com/pydantic/pydantic-ai/tree/banner-quiet-in-libraries
2026-10-29 · pre-push review 2 of 3 at c3c8cf111c603d8d49dccb8b95185ba66a346398 · iter -
- Decision: dispatched in the background; its report had not been delivered when review 3 ran, so review 3 covered its scope (changes since aaa15dde64)
- Why: reviewed tree c9482ddcbaf6baf2f6610cf23e853ecb14f4c2be
- Source: https://github.com/pydantic/pydantic-ai/tree/banner-quiet-in-libraries
2026-10-29 · Decide run_stream_events in the iterating caller's stack; UI adapter runs keep the banner · iter -
- Decision: verdict recorded on RunBinding in AgentRunEvents._ensure_started; a pydantic_ai.ui frame on the stack means the user's app
- Why: Douwe chose to fix this in the PR; the web framework pulling an adapter stream is installed but the app is the user's
- Source: https://github.com/pydantic/pydantic-ai/tree/banner-quiet-in-libraries
2026-10-29 · pre-push review 3 of 3 at ca4baee4cbd0911452241c7b4fd3c76702014d6f · iter -
- Decision: remediated: anyio and trio frames are loop boundaries too, with an anyio task-group test; cost notes corrected for run_stream_events. Budget exhausted; pushed after local checks
- Why: reviewed tree 02cbc9ac9c6a5d89b737c3b493afce54e168bcee; scope aaa15dde64..ca4baee4cb plus callers
- Source: https://github.com/pydantic/pydantic-ai/tree/banner-quiet-in-libraries
2026-10-29 · push after budget at d7d86f88a70359eaa6d6f94475c45529132fe7f9 · iter -
- Decision: applied douwebot's three optional wording suggestions without a fourth local review
- Why: comment/docstring rewording plus one docs/logfire.md sentence split; review budget exhausted at 3 of 3; fresh douwebot approval required on the new head
- Source: https://github.com/pydantic/pydantic-ai/pull/11893
2026-10-29 · push after budget at e8c1fb997d5f428e62bc40c59f4de8e7939b7077 · iter -
- Decision: applied douwebot's two optional refactor suggestions (named verdict, one _compiled_as test helper) without a fourth local review
- Why: behavior-preserving refactor; the 12-scenario inline check still passes; fresh douwebot approval required
- Source: https://github.com/pydantic/pydantic-ai/pull/11893
2026-10-29 · late report of pre-push review 2 of 3 (at c3c8cf111c), triaged at df7236ca136605f481448a3bb37a5dd7d7ea212b · iter -
- Decision: finding 1 (anyio/trio) already fixed by review 3; finding 2 fixed by marking the boundary where a coroutine chain ends instead of at any asyncio frame (covers wait_for and uvloop), with a wait_for test; finding 3 fixed by hedging the BANNER_ENABLED docstring. Not addressed: an app handing agent.run to a framework that awaits it in the same chain (Starlette BackgroundTasks) is attributed to the framework
- Why: budget exhausted; inline 13-scenario check passes; remediating a delivered finding needs no further dispatch
- Source: https://github.com/pydantic/pydantic-ai/pull/11893
2026-10-29 · CI repair at fe357b79974a839872e5f31d7784680c76f6590d · iter -
- Decision: skip the wait_for parametrization before 3.12
- Why: 3.11 asyncio.wait_for wraps the coroutine in a Task, so the starter is past a task boundary and keeps today's banner (safe direction); test-only delta
- Source: https://github.com/pydantic/pydantic-ai/pull/11893
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.