Skip to content

Persist and surface Human-in-the-Loop (HITL) responses + write to task/audit logs #53683

Closed

Description

@cmarteepants

Description

Follow up to PR #53035 (initial HITL UI)

UI currently collects a user's response but does not persist it, surface it on reopen, or record it in logs. This limits audibility and user feedback.

Problem Statement

  • Approving users can't see what they (or someone else) selected after the fact
  • Airflow Admins and Users do not have no immutable record of who responded, when, and with which option
  • Debugging HITL-related failures is harder because the chosen value is absent from task logs

Proposal / Requirements

1. Persist response:

  • Store things like user_id, option_value, option_label and responded_at in the database when a HITL trigger is resolved
  • API: Extend API to return the saved payload

2. Surface response in UI payloads: Endpoints should include the stored response under a key like hitl_response

3. Log for audibility:

  • After successful save, write a structure line to task logs like [HITL] user=alice option="Approve" at 2025-07-23T14:02:11Z
  • Emit the same data to the Airflow audit log if enabled

4. UI fallback:

  • If hitl_response exists, display a read-only banner: Responded “Approve” by Alice at 14:02
  • Disable further edits unless the operator explicitly allows overrides.

Acceptance Criteria

  • Response data is persisted on backend and returned via API
  • Re-Opening the Action Required dialog shows the stored response
  • Task log contains the [HITL] entry with user, option, timestamp

Out of Scope

  • UI changes beyond showing stored value
  • Restrictions on who can edit an existing response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added this to the Airflow 3.1.0 milestone on Jul 23, 2025
  2. moved this from Backlog to Ready in AIP-90 - Human in the loopon Jul 28, 2025
  3. self-assigned this
    on Jul 28, 2025
  4. Lee-W commented on Jul 28, 2025

    @Lee-W
    Member

    Response data is persisted on backend and returned via API

    It's persisted now.

    response_at = Column(UtcDateTime, nullable=True)
    user_id = Column(String(128), nullable=True)
    chosen_options = Column(
    sqlalchemy_jsonfield.JSONField(json=json),
    nullable=True,
    default=None,
    )
    params_input = Column(sqlalchemy_jsonfield.JSONField(json=json), nullable=False, default={})

    Re-Opening the Action Required dialog shows the stored response

    This is fetchable through API but I'll take a look at the UI

    Task log contains the [HITL] entry with user, option, timestamp

    Log is not yet there. But I'll create a PR for it.

  5. moved this from Ready to In progress in AIP-90 - Human in the loopon Jul 28, 2025
  6. Lee-W commented on Jul 28, 2025

    @Lee-W
    Member

    Re-Opening the Action Required dialog shows the stored response

    I think we can add a follow-up PR after #53035 is merged. @guan404ming Please let me know if you would like to work on it 🙂

  7. guan404ming commented on Jul 28, 2025

    @guan404ming
    Member

    Re-Opening the Action Required dialog shows the stored response

    I've added the function in #53035. Please take another look, thanks! Feel free to let me know if anything needs to be adjusted.

  8. Lee-W commented on Jul 29, 2025

    @Lee-W
    Member

    log part created #53850

  9. moved this from In progress to In review in AIP-90 - Human in the loopon Jul 29, 2025
  10. Lee-W commented on Aug 1, 2025

    @Lee-W
    Member

    As discussed early this morning, I think we've addressed the issues. But please feel free to reopen it if you think there's still something missed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:APIAirflow's REST/HTTP APIarea:UIRelated to UI/UX. For Frontend Developers.area:loggingkind:featureFeature Requests

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions