Skip to content

Let LLMBatchOperator request_params be templated - #74751

Merged
henry3260 merged 1 commit into
apache:mainfrom
henry3260:template-llm-batch-request-params
Oct 15, 2026
Merged

henry3260 merged 1 commit into
apache:mainfrom
henry3260:template-llm-batch-request-params

Conversation

@henry3260

@henry3260 henry3260 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Why

LLMBatchOperator.request_params carries free-form provider body parameters
(temperature, top_k, seed, thinking, ...) merged into every request. It is the batch
counterpart of LLMOperator.agent_params / AgentOperator.agent_params, both of which are in
template_fields, so a Dag author who writes request_params={"temperature": "{{ params.temp }}"}
reasonably expects it to be rendered.

It was not in template_fields. The Jinja expression stayed a literal string and was sent to the
provider API as the parameter value, which fails at the provider with nothing pointing back at the
operator parameter as the cause.

max_tokens is deliberately left alone. Every scalar numeric parameter in this provider
(max_tokens, poll_interval, timeout, LLMFileAnalysisOperator.max_files) is untemplated;
only free-form dicts (agent_params, embedding_kwargs) and dicts with a known numeric schema
(usage_limits, which also coerces each rendered value) are templated. Templating a bare int
would hand the provider API the string Jinja produced.

What

  • providers/common/ai/src/airflow/providers/common/ai/operators/llm_batch.py — add
    request_params to template_fields, and document the templating in its :param: entry.
    No coercion is applied, matching agent_params: the keys are provider body parameters whose
    types the operator does not know.
  • providers/common/ai/docs/operators/llm_batch.rst — document that request_params is
    templated, that Jinja hands back a string (so a numeric value written as a template needs
    render_template_as_native_obj=True on the Dag), and that the rendered values feed the
    re-attach fingerprint — the same stability rule that already applies to result_path.
  • providers/common/ai/tests/unit/common/ai/operators/test_llm_batch.py — add
    TestTemplateFields: one test pinning the template_fields set, one rendering
    {"temperature": "{{ params.temp }}"} through render_template_fields. Both fail without the
    operator change.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

``request_params`` carries the same kind of free-form provider body
parameters as ``LLMOperator.agent_params``, which is templated, so a Dag
author who writes a Jinja expression there reasonably expects it to be
rendered. Because the field was missing from ``template_fields``, the
expression reached the provider API verbatim and the request failed there,
with nothing pointing back at the operator parameter as the cause.
@henry3260
henry3260 merged commit fa7c589 into apache:main Oct 15, 2026
164 checks passed
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