Lee-W commented on code in PR #74396:
URL: https://github.com/apache/airflow/pull/74396#discussion_r4241068505
##########
providers/common/ai/docs/operators/llm.rst:
##########
@@ -144,23 +144,25 @@ When the limit is hit pydantic-ai raises
``UsageLimitExceeded``, which
propagates to Airflow as a task failure, so Airflow's standard retry policy
applies on top.
-For the ``LLM*`` operator family, every limit here bounds a single agent
-*run*, not a task: each Airflow task retry re-renders ``usage_limits`` and
-starts a fresh count. A ``cost_limit`` of ``Decimal("0.50")`` caps one run,
-so it is not a bound on what the task spends in total.
-
-For ``AgentOperator`` on Airflow >= 3.3, it is the other way around: setting
-``usage_limits`` makes every limit bound the whole task instance -- the
-initial run, every retry, and every HITL regeneration all add to one running
-total, so a ``cost_limit`` of ``Decimal("0.50")`` bounds what the task spends
-across every attempt combined (best-effort, like the rest of ``cost_limit``
-above -- a SIGKILL loses the spend of the attempt it kills, and this is not
-a hard guarantee). See :ref:`howto/operator:agent` for how that budget is
-persisted and how to reset it, and for what a HITL regeneration shares. On
-Airflow < 3.3, and whenever ``usage_limits`` is ``None``, ``AgentOperator``
-behaves like the ``LLM*`` family: each attempt starts a fresh count. Within
-one attempt, its HITL regenerations share the initial run's count whenever
-``usage_limits`` is set, on every Airflow version.
+On Airflow >= 3.3, setting ``usage_limits`` makes every limit bound the whole
+task instance, for the ``LLM*`` family (``LLMOperator``, ``LLMBranchOperator``,
+``LLMSQLQueryOperator``, ``LLMSchemaCompareOperator``,
``LLMFileAnalysisOperator`` and
+the matching ``@task.*`` decorators) the same way it does for
``AgentOperator``:
+the initial run and every retry add to one running total, including the
implicit
+``request_limit=50``. A pause for approval, and a retry after a reviewer
rejects the
+output, share the same total. The total is cleared only once the task succeeds
-- a
+reviewer approval, or a ``LLMBranchOperator`` skip, counts as success -- and a
+cleared task instance starts a fresh one. A ``cost_limit`` of
``Decimal("0.50")``
Review Comment:
* `request_limit` and `input_tokens_limit` / `output_tokens_limit` bullets
now say the LLM* operators count across the whole task instance too on Airflow
>= 3.3 when `usage_limits` is set (`tool_calls_limit` stays AgentOperator-only)
* `llm.rst` now has the same note as `agent.rst` about clearing a running
task instance not bumping `max_tries`
##########
providers/common/ai/docs/changelog.rst:
##########
@@ -29,18 +29,21 @@ Changelog
......
.. note::
- On Airflow >= 3.3, ``AgentOperator``'s ``usage_limits`` counts usage across
every
- attempt of the task instance combined -- initial run, every retry, and every
HITL
- regeneration add to one running total (including the implicit
``request_limit=50``
- default), instead of each attempt starting fresh. Scale each limit by
``retries + 1``,
- or set ``usage_limits=None``, to keep the old per-attempt headroom. On every
Airflow
+ On Airflow >= 3.3, the ``usage_limits`` of ``AgentOperator`` and the
``LLM*`` operators
Review Comment:
Restored the 0.11.0 AgentOperator note and added a separate note for the
LLM* operators directly under the `Changelog` header.
--
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]