Skip to content

Warn that a durable agent retry replays toward the same usage limit - #73893

Closed
kaxil wants to merge 1 commit into
apache:mainfrom
astronomer:durable-no-progress
Closed

kaxil wants to merge 1 commit into
apache:mainfrom
astronomer:durable-no-progress

Conversation

@kaxil

@kaxil kaxil commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

With durable=True, a retry replays every cached model response and tool call, and replayed steps count toward usage_limits like live ones. A run that reached its limit therefore usually stops at the same step on every retry. Until now the task log only showed the same UsageLimitExceeded on each try, with nothing saying why the retries were not helping.

AgentOperator now logs a warning when a durable run reaches a usage limit. It includes the error, says a retry will likely stop at the same step if that is the task's own limit, and says that raising usage_limits is what lets the run go further. The durable execution guide says the same, including that an unset usage_limits still caps a run at pydantic-ai's default of 50 requests. Retry behaviour does not change.

Why not stop retrying instead. Failing the task once a retry reaches the limit purely from the cache looks like the obvious fix, but that only holds when everything in the run replays exactly. Several things run live on every attempt and can change the outcome: output functions and validators, tools asking for a retry, tool results the cache could not store, tools on routes the cache does not wrap, and agents run inside a tool, which can add their own usage or hit their own limits. Each of these can make an attempt look fully replayed and still leave a later attempt able to finish, so an operator-side fail-fast would sometimes drop a retry that would have succeeded. A redundant retry that only replays costs no model tokens, so the warning is the trade worth making.

Run end to end on a local Airflow 3.4.0 with a durable agent, usage_limits={"request_limit": 1} and retries=1. On try 1 the run makes its model call and tool call live, reaches the limit, and logs the warning:

Try 1: the run reaches its request limit and warns

On try 2 both steps replay from the cache (replayed 2 cached steps ... cached 0 new steps) and the run stops at the same limit, as the warning says:

Try 2: the retry replays both steps and stops at the same limit

@vatsrahul1001

Copy link
Copy Markdown
Contributor

Test failing needs to be looked at here

@vatsrahul1001

vatsrahul1001 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

3.0.6 is failing on the cap_structlog assertions that needs airflow._shared, which isn't there before 3.1. Only the log check breaks, the counting's fine. Maybe pull the log assertion into a separate AIRFLOW_V_3_1_PLUS test and keep the count check running on all versions?

With durable=True a retry replays every cached step, and replayed steps count
toward usage_limits like live ones, so a retry of a run that reached its limit
usually stops at the same step. The task log only showed the same
UsageLimitExceeded on every try, with nothing saying why the retries could not
help.

AgentOperator now logs a warning when a durable run reaches a usage limit,
saying the retry replays toward the same limit and that raising usage_limits is
what lets the run go further. Retry behaviour is unchanged, and the durable
execution docs say the same.
@kaxil
kaxil force-pushed the durable-no-progress branch from 065008e to b582ff3 Compare September 29, 2026 23:46
@kaxil

kaxil commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Closing: #73706 made the premise of this PR obsolete. Its ReplayUsageLedger stops replayed steps from counting toward usage_limits, so a durable retry no longer replays toward the limit it hit, and the cross-attempt budget covers what this warning was trying to explain. Rebasing would ship a warning that is no longer true.

@kaxil kaxil closed this Sep 30, 2026
@kaxil
kaxil deleted the durable-no-progress branch September 30, 2026 06:15
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.

3 participants