dabla opened a new pull request, #74150: URL: https://github.com/apache/airflow/pull/74150
> [!IMPORTANT] > **Depends on #74147, which needs to be merged first.** That PR adds `get_async_extra_dejson()` to the common.compat provider, which this hook needs to read the connection's extra asynchronously on every supported Airflow version. Until it is merged this PR stays a draft and uses a local `_aextra_dejson()` fallback marked with a TODO. Once #74147 is merged, this branch is rebased, the fallback is replaced by `get_async_extra_dejson()`, and the common-compat requirement is bumped to the release that ships it. `PydanticAIHook.get_conn()` resolves its connection (and every fallback connection of a `fallback_conn_ids` chain) with `get_connection()` and reads `extra_dejson`, whose secret masking sends `MaskSecret` to the supervisor synchronously. Inside an async task with another async SDK call in flight (e.g. items running concurrently), both raise `DeadlockImminentError`, although the pydantic-ai agent the hook builds is itself async-native (`await agent.run(...)`). This adds an async path without duplicating the model resolution: - `aget_conn()` fetches the hook's connection and its fallback connections with `get_async_connection()` (extra from `Connection.aextra_dejson()`, #71890, Airflow 3.3.2+; on older versions the raw extra via `json.loads`, as in #72130, with a TODO to drop that fallback), seeds the hook's existing connection cache (`_seed_connection`, which now accepts the already-deserialized extra), keeps the fallback connections for `_resolve_fallback_models`, and then builds the model with the unchanged `get_conn()` -- fallback chains, model-id qualification and forwarding behave exactly as in the sync path. - `acreate_agent()` is the async counterpart of `create_agent()` (same overloads, `spec_file` included): it prefetches the connections the same way, then builds the agent. This is also the first building block for running `@task.agent` / `AgentOperator` natively async (`await agent.run(...)` instead of `run_sync`). Tests: new tests resolve a model, a fallback chain, the cache, `acreate_agent` and a `spec_file` agent while the sync `get_connection` and `extra_dejson` raise, and assert each connection is fetched once, asynchronously, and that `aextra_dejson()` is used when the connection has it. Existing tests pass unchanged. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Opus 5.5 Generated-by: Claude Opus 5.5 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
