kaxil opened a new pull request, #74900:
URL: https://github.com/apache/airflow/pull/74900

   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to