The GitHub Actions job "Tests (AMD)" on 
airflow.git/anthropic-session-budget-reached has failed.
Run started by GitHub user kaxil (triggered by kaxil).

Head commit for run:
f3cf8c405e72e41ea5030db10154a9e775015de5 / Kaxil Naik <[email protected]>
Fix misleading error when an Anthropic agent session stops on its budget

Anthropic SDK 0.121.0 adds Managed Agents session budgets: a spend ceiling
passed to ``sessions.create``, after which the session stops issuing new
model requests and goes idle with a new ``budget_reached`` stop reason.

The provider treated every non-``end_turn`` idle reason the same way, so
a budget stop surfaced as "configure an autonomous agent or use an
outcome run" -- advice that has nothing to do with what happened. It also
raised the generic ``AnthropicAgentSessionError``, giving Dag authors no
way to tell a spend decision apart from a fault.

``budget_reached`` now gets its own branch and a new
``AnthropicSessionBudgetExceeded`` (a subclass of the existing session
error, so current handlers keep working). The message names both causes,
because a session also stops this way when its usage includes a model
with no list price that a budget cannot measure -- and raising the
ceiling does not unblock that case. It also says the operator archives
the session on this path, so the ceiling has to be raised for the next
run rather than on a session that no longer exists.

``poll_session_completion`` returns the SDK's ``stop_reason`` alongside
the message, and the trigger carries it in its error event, so the
deferrable path raises the same class as the synchronous one without
matching on message text. A trigger serialized before this field existed
omits it and falls back to the generic error.

Verified against the live API, not only against mocks: ``sessions.create``
accepts the documented budget payload, the server really emits
``budget_reached``, and the hook classifies a genuinely budget-stopped
session and raises ``AnthropicSessionBudgetExceeded``.

That testing also showed a budget is a stop trigger, not a spend cap. The
ceiling is checked between model requests, so an in-flight request runs
to completion: a $0.01 ceiling admitted between $0.32 and $0.61 of usage
across four runs. The docs now say so, since "hard spend ceiling" invites
the wrong expectation.

The ``anthropic`` floor moves to 0.121.0, the first release whose
``sessions.create`` accepts ``budget`` -- which is how the guide tells
users to set a ceiling. Reading a ``budget_reached`` stop reason happens
to work further back, because older clients mis-build the discriminated
union into the wrong variant class while preserving ``.type``, but only
with response validation left non-strict, so it is not something to
depend on.

Report URL: https://github.com/apache/airflow/actions/runs/31539088900

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to