kaxil opened a new pull request, #67858:
URL: https://github.com/apache/airflow/pull/67858
Follow-up from #67644: `LLMFileAnalysisOperator` silently ignores
`serialize_output=True` and always returns a Pydantic instance instead of the
dict the user asked for.
## Root cause
`LLMOperator.execute` ends with:
```python
if self._serialize_model_output and isinstance(output, BaseModel):
output = output.model_dump()
return output
```
`LLMFileAnalysisOperator` overrides `execute()` (it needs to build the
file-analysis request before calling the agent) and returns `output` directly
without invoking `super().execute()` or replicating that branch. So the
`serialize_output=True` opt-in had no effect on this operator -- both
`serialize_output=False` and `serialize_output=True` returned the Pydantic
instance.
Caught by Codex review of the merged PR.
## Fix
Mirror the same `isinstance(output, BaseModel) -> model_dump()` block at the
end of `LLMFileAnalysisOperator.execute`. A short comment explains why the
duplication is necessary (override doesn't call `super`).
Adds a regression test that constructs the operator with
`serialize_output=True` and asserts the result is a `dict`, not a `Summary`.
Verified locally: 10 tests pass.
## Notes
- The `execute_complete` path on this operator was already correct (it uses
the helper from `output_type.rehydrate_pydantic_output`, which respects
`_serialize_model_output`). Only `execute` was missing the branch.
- Same shape as the other two operators: `LLMOperator` and `AgentOperator`
each handle the dump in their own `execute` because none of them share an
`execute` implementation by inheritance today. A future refactor could pull the
dump into a shared post-process step, but it's a one-line block per operator
for now.
--
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]