Skip to content

Keep the pydantic-ai first-run banner out of Common AI task logs - #74900

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:pydantic-ai-banner-off
Oct 17, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
astronomer:pydantic-ai-banner-off

Conversation

@kaxil

@kaxil kaxil commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

pydantic-ai 2.43 and later print an ASCII-art banner to stderr on the first agent run in a process. pydantic-ai shows it when stderr is a terminal, or when an environment variable says a coding agent is running the process (CLAUDECODE, CODEX_*, CURSOR_AGENT, AI_AGENT and others). Task processes inherit the environment of whatever started Airflow. So anyone who runs airflow standalone, airflow dags test or breeze from Claude Code, Cursor or Codex gets the banner in every AgentOperator / LLMOperator task log. The supervisor logs task stderr at ERROR, so a run that succeeded shows about ten ERROR lines, and they come back after each deferral resume because each resume is a new process. This was seen while testing 1.0.0rc1 (#74741).

This sets pydantic_ai.BANNER_ENABLED = False when hooks/pydantic_ai.py is imported. Every agent the provider runs is built through PydanticAIHook.create_agent, so the operators, @task.agent / @task.llm and the model-backed retry policies all import it before an agent runs. BANNER_ENABLED is pydantic-ai's own switch for programs that want to own their output, and pydantic-ai reads it at display time. On pydantic-ai older than 2.43 the assignment adds an unused attribute, so the 2.36 floor is unaffected.

Why not set PYDANTIC_AI_NO_BANNER from the provider? It does the same thing, but writing to os.environ would leak into user code and every subprocess a task starts. Filtering one library's stderr in core would be the wrong layer.

A task that builds its own Agent(...) and never imports the hook isn't covered. The "run your own agent" guide now tells those users to set PYDANTIC_AI_NO_BANNER=1 in the worker environment.

The test sets CLAUDECODE=1, clears PYTEST_VERSION and CI (pydantic-ai suppresses the banner under both on its own), and resets pydantic-ai's once-per-process claim. Without the hook change it fails with the banner text on stderr.

Before:

image

pydantic-ai 2.43 and later print an ASCII-art banner to stderr on the first
agent run in a process when stderr is a terminal or a coding agent is
detected from the environment. Task stderr is logged at ERROR, so every
agent task started from Claude Code, Cursor or Codex got about ten ERROR
lines, again after each deferral resume. Turn the banner off where the
hook module is imported, and document PYDANTIC_AI_NO_BANNER for agents
run without the hook.
@kaxil
kaxil merged commit 1f4fe79 into apache:main Oct 17, 2026
86 checks passed
@kaxil
kaxil deleted the pydantic-ai-banner-off branch October 17, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants