Skip to content

Fix agent HITL review for list, marker and function output types - #74537

Merged
kaxil merged 1 commit into
apache:mainfrom
FrankYang0529:fix-common-ai-hitl-output-spec
Oct 12, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
FrankYang0529:fix-common-ai-hitl-output-spec

Conversation

@FrankYang0529

@FrankYang0529 FrankYang0529 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Why

  • Return an approved agent answer as output_type after human review #73904 (in apache-airflow-providers-common-ai 0.11.0rc1) made AgentOperator convert an answer approved in HITL review with a pydantic TypeAdapter built from output_type. The following cases work on 0.10.0 but break on 0.11.0rc1:
    • A list of output types, such as [Verdict, Other], raises PydanticSchemaGenerationError, and the task fails.
    • An output marker, such as ToolOutput(Verdict), raises AttributeError, and the task fails. NativeOutput, PromptedOutput and TextOutput fail the same way.
    • For an output function, TypeAdapter validates the approved text as the function's arguments and calls the function a second time.

How

  • An AgentOperator reviewer can approve, reject or ask for a new answer, but cannot edit the answer. So AgentOperator now keeps the output of the last run or regeneration and returns it when the reviewer approves, instead of converting the approved text. The operator no longer calls rehydrate_pydantic_output.
  • When the approved answer is a Pydantic model whose class the worker would not register for XCom deserialization, the operator returns the model as a dict.

Was generative AI tooling used to co-author this PR?
  • Yes - Claude Code

Comment thread providers/common/ai/src/airflow/providers/common/ai/utils/output_type.py Outdated
Comment thread providers/common/ai/src/airflow/providers/common/ai/utils/output_type.py Outdated
Comment thread providers/common/ai/tests/unit/common/ai/utils/test_output_type.py Outdated
Comment thread providers/common/ai/tests/unit/common/ai/operators/test_agent.py Outdated
Signed-off-by: PoAn Yang <payang@apache.org>
@FrankYang0529
FrankYang0529 force-pushed the fix-common-ai-hitl-output-spec branch from 803cbd3 to 6f5025a Compare October 12, 2026 03:03

@kaxil kaxil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the approved answer now comes back as the agent returned it, so [str, int] keeps "42" a string and the list, marker and function shapes no longer fail. LGTM.

One thing for a follow-up: the path without review (_complete_run, the if self._serialize_model_output and isinstance(output, BaseModel) branch) still dumps a model only when serialize_output is set. With output_type=[Summary, int] and review off, a 3.3+ worker pushes a Summary instance that the downstream pull rejects with the allow-list ImportError, while the review path now pushes a dict. That was already true before this PR. A small _to_xcom helper holding the condition you added here, called from both returns, would make the two paths agree.

Also minor: the tests that set run_hitl_review's return value to the agent's own output (test_execute_with_enable_hitl_review_delegates_to_run_hitl_review, test_execute_with_hitl_returns_string_unchanged, test_hitl_branch_success_also_deletes_the_budget_key) can no longer tell which value execute returns. One of them could return different text and assert the result is still the agent's, and test_execute_with_hitl_rehydrates_base_model still has the name and comment from the parse-back.

@kaxil
kaxil merged commit 1806c28 into apache:main Oct 12, 2026
85 checks passed
@kaxil

kaxil commented Oct 12, 2026

Copy link
Copy Markdown
Member

Merged but can you handle those minor comments in a follow-up PR @FrankYang0529

@FrankYang0529

Copy link
Copy Markdown
Member Author

@kaxil Thanks for the reivew. Create a follow-up PR #74729.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants