Repository navigation
Fail LLMOperator approval at parse time on Airflow cores older than 3.1 - #73261
Merged
Merged
Conversation
guan404ming
approved these changes
Sep 17, 2026
guan404ming
left a comment
Member
There was a problem hiding this comment.
LGTM. Small nit: the six-line comment above the guard restates the PR body, and the two ordering tests already pin the placement. I think "Checked before the combination rule so an old core reports the core version rather than a wrong knob." would be good.
Lee-W
reviewed
Sep 17, 2026
Human-in-the-loop review needs Airflow 3.1+, but require_approval=True had no version guard. On a 3.0.x core, which apache-airflow>=3.0.0 supports, the Dag imported fine and the task ran the model call before defer_for_approval failed on an import that cannot succeed there. Every retry paid for the call again. Reject the parameter in __init__ instead, matching how AgentOperator already gates enable_hitl_review.
kaxil
force-pushed
the
llm-require-approval-3-1-guard
branch
from
September 17, 2026 11:48
ba844f1 to
012e4f3
Compare
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.
Human-in-the-loop review needs Airflow 3.1+, but
require_approval=Truewas never gated on it. The provider floorsapache-airflow>=3.0.0, so a 3.0.x core is a supported install, and there the Dag imported cleanly and the failure landed mid-task.executecallsagent.run_sync()beforedefer_for_approval, anddefer_for_approvalimportsHITLTrigger, which raises on import below 3.1, andairflow.sdk.execution_time.hitl, which does not exist before 3.1. So the model call was paid for, the task then died on an import that could never have succeeded, and every retry paid for it again.__init__now rejects the parameter the wayAgentOperatoralready rejectsenable_hitl_review, so the Dag fails to import instead.Why
__init__rather thanexecute. Failing before the spend is the whole point, and a guard inexecutewould still sit downstream ofagent.run_sync(), reporting the problem after the cost it exists to avoid. Placement within__init__matters too: the check sits below theon_approval_timeoutliteral validation and above the combination rule, so a typo keeps its own precise message, while on an old core the core version is reported rather than a combination error that would send the user to drop an argument that was never the problem.Verified against a real Airflow 3.0.6 core with the provider installed from source:
AirflowOptionalProviderFeatureException: require_approval=True needs Airflow 3.1+.agent.run_sync()The four
@task.llm*decorator tests that build an operator withrequire_approval=Truenow carry a 3.1 skip, matching the existing gate on the equivalentAgentOperatortest. Without it they error on the 3.0.6 row of the providers-compatibility job rather than passing.One caveat, noted in
llm.rst: a dynamically mapped task (.expand()) is only constructed when it runs, so there the same error surfaces as a task failure rather than an import error, still before the model is called.Related to #72157, which adds this kind of guard for
approval_assigned_users. This covers the parent parameter that knob depends on.