ColtenOuO opened a new pull request, #70132:
URL: https://github.com/apache/airflow/pull/70132
## Summary
`AgentOperator`'s human-in-the-loop review path (`enable_hitl_review=True`)
loses the original output type for any `output_type` that is neither `str` nor
a Pydantic `BaseModel` (e.g. `list[str]`, `bool`, `dict`).
The output is round-tripped through a string while it's shown to a human
reviewer: `HITLReviewMixin._to_string` serializes it before review, and
`AgentOperator.execute()` deserializes it back into `output_type` after
approval. The serialization side used `str(output)`, which produces a Python
repr (e.g. `"['tag-a', 'tag-b']"`), not valid JSON.
The deserialization side then tried `json.loads()` on that repr, which
always raised, and silently fell back to returning the raw repr *string*
instead of the original list/bool/dict — a type change downstream tasks don't
expect.
`regenerate_with_feedback()` (used when a reviewer requests changes) had the
identical `str(output)` bug.
This is the same defect class already fixed for the `require_approval=True`
path in #70075, which switched to `TypeAdapter(...).dump_json(...)`. That fix
wasn't applied to the separate `enable_hitl_review=True` path, so it regressed
here.
## Changes
- `HITLReviewMixin._to_string` and `AgentOperator.regenerate_with_feedback`
now serialize non-str/non-`BaseModel` output with
`TypeAdapter(type(output)).dump_json(output)`, matching the pattern
already used by `LLMApprovalMixin.defer_for_approval`.
- `AgentOperator.execute()`'s HITL-review branch now reuses the existing
`rehydrate_pydantic_output` helper (already used by the approval path)
instead of a bespoke `json.loads`/`except` fallback, so both review paths
behave consistently.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Sonnet 5)
Generated-by: Claude Code (Sonnet 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]