Repository navigation
Keep the pydantic-ai first-run banner out of Common AI task logs - #74900
Merged
Merged
Conversation
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.
shahar1
approved these changes
Oct 17, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_AGENTand others). Task processes inherit the environment of whatever started Airflow. So anyone who runsairflow standalone,airflow dags testor breeze from Claude Code, Cursor or Codex gets the banner in everyAgentOperator/LLMOperatortask log. The supervisor logs task stderr atERROR, so a run that succeeded shows about tenERRORlines, 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 = Falsewhenhooks/pydantic_ai.pyis imported. Every agent the provider runs is built throughPydanticAIHook.create_agent, so the operators,@task.agent/@task.llmand the model-backed retry policies all import it before an agent runs.BANNER_ENABLEDis 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_BANNERfrom the provider? It does the same thing, but writing toos.environwould 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 setPYDANTIC_AI_NO_BANNER=1in the worker environment.The test sets
CLAUDECODE=1, clearsPYTEST_VERSIONandCI(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: