Move template-field validation out of AnthropicAgentSessionOperator _…#70432
Open
bramhanandlingala wants to merge 1 commit into
Open
Move template-field validation out of AnthropicAgentSessionOperator _…#70432bramhanandlingala wants to merge 1 commit into
bramhanandlingala wants to merge 1 commit into
Conversation
bramhanandlingala
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl,
kaxil and
potiuk
as code owners
July 25, 2026 11:29
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.
Summary
AnthropicAgentSessionOperator.__init__validatedmessageandoutcomebefore Jinja templating runs, even though both are
template_fields. Atemplated
outcome(e.g.outcome="{{ params.outcome }}") would crashat DAG-parse time with
AttributeError: 'str' object has no attribute 'keys', before rendering ever gets a chance to resolve it to a real dict.Fix
providers/anthropic/src/airflow/providers/anthropic/operators/agent.py:__init__now only does plain assignments.message/outcomemutual exclusivity, andoutcomerequiringdescription+rubric) moved to the top ofexecute(), after templating has run.Testing
providers/anthropic/tests/unit/anthropic/operators/test_agent.py:test_requires_exactly_one_of_message_or_outcomeandtest_outcome_requires_description_and_rubricto construct the operatorfirst, then assert the
ValueErroris raised on.execute()instead ofat construction.
test_init_does_not_validate_message_or_outcometo lock in that__init__accepts any combination without raising.Exemption list
Removed
AnthropicAgentSessionOperator's entry fromscripts/ci/prek/validate_operators_init_exemptions.txt, as required bythe burn-down rule.
Related to #70296