Repository navigation
Allow loop gates to add human-readable decisions - #74806
Merged
Merged
Conversation
ashb
force-pushed
the
task-loops-decision-reason
branch
from
October 15, 2026 16:21
9085e7f to
318af82
Compare
Contributor
|
UX makes sense to me. We may surface this in more places later. Let'e see |
bbovenzi
reviewed
Oct 15, 2026
ashb
marked this pull request as ready for review
October 15, 2026 17:41
ashb
requested review from
XD-DENG,
amoghrajesh,
bugraoz93,
choo121600,
ephraimbuddy,
guan404ming,
henry3260,
jason810496,
pierrejeambrun,
rawwar,
ryanahamilton,
shubhamraj-git and
vatsrahul1001
as code owners
October 15, 2026 17:41
As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does.
A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels.
A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full.
ashb
force-pushed
the
task-loops-decision-reason
branch
from
October 15, 2026 20:02
eef3f94 to
5f3379b
Compare
kaxil
reviewed
Oct 16, 2026
kaxil
approved these changes
Oct 16, 2026
Contributor
Backport failed to create: v3-4-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 4c4bab0 v3-4-testThis should apply the commit to the v3-4-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
ashb
added a commit
that referenced
this pull request
Oct 17, 2026
As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does. * Show loop decision reasons in the UI A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels. A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full. (cherry picked from commit 4c4bab0)
ashb
added a commit
that referenced
this pull request
Oct 18, 2026
…#74932) As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does. * Show loop decision reasons in the UI A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels. A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full. (cherry picked from commit 4c4bab0)
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
…#74932) As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does. * Show loop decision reasons in the UI A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels. A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full. (cherry picked from commit 4c4bab0)
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.
As it landed on main, a loop's gate only recorded a go/no-go decision for
the next iteration, meaning the UI could show that a loop stopped after N
iterations, but a user would have to go to the logs to find out why,
exactly, the loop ended when it did.
This adds a
LoopDecisionobject that lets anuntilcallable includehuman-readable text to show alongside its decision.
As well as introducing this new type, it also changes how the decision
makes it to the server. Prior to this change, the decision was shipped to
the API server via a specially named XCom value, in a normal SetXCom
request, which was then read when the gate's TISuccessState request
arrived. That "worked", but was inherently fragile: a separate write
with its own locking, validation and cleanup on every non-success path.
The decision now travels on the gate's terminal state update. The server
acts on it in the transaction that marks the gate finished, so the
stop/continue signal never needs storing. A gate that fails because until
stayed false at max_iterations sends its reason with the failure, which is
when an explanation helps most.
Only the reason is persisted, as an XCom on the gate's attempt that the
server writes in that same transaction. Keying it to the attempt means
each try keeps its own reason, and a cleared or retried gate starts with
none, so no clear path has to remember to delete a stale one. Task state
was considered instead, but it is keyed by the iteration rather than the
attempt, so a reason outlived the clears and tries it described, and
clear_on_success and retention could remove it. The server writes the
XCom directly to the metadata DB (not to a configured backend, so the UI
can always show it), and the reserved
_airflow_loop_prefix stops usersand tasks forging it. The XCom list endpoint leaves those keys out when
asked, which the UI does.
Some (cropped) screenshots of how this currently shows it.
Long decision handling:
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.