Repository navigation
Let Common AI toolsets use the agent's tool retry budget - #73957
Merged
Merged
Conversation
SQLToolset, HookToolset, DataFusionToolset and ObjectStorageToolset pinned max_retries=1 on every tool, overriding the agent's retries. An agent given retries=3 still ended its run on the second failed query in a row, so a model that needed a couple of attempts to get a column name right could not. Each toolset now takes max_retries, defaulting to the run's own tool retry budget, the way pydantic-ai's FunctionToolset does. Outside a pydantic-ai run (the LangChain, Strands and ADK bridges) there is no agent budget, so tools get pydantic-ai's default of one correction, and each bridged call now gets a context with its own retry count, so ctx.last_attempt means what it does inside a pydantic-ai run.
kaxil
force-pushed
the
toolset-retries
branch
from
September 30, 2026 15:08
3fe2f2a to
40dda9a
Compare
vatsrahul1001
approved these changes
Oct 1, 2026
pankajkoti
approved these changes
Oct 1, 2026
Lee-W
reviewed
Oct 1, 2026
Lee-W
approved these changes
Oct 1, 2026
Co-Authored-By: Claude <[email protected]>
kaxil
added a commit
to astronomer/airflow
that referenced
this pull request
Oct 14, 2026
The toolsets now take max_retries (apache#73957), so the guide no longer says they allow exactly one correction, and the retry budget docs list the Anthropic tool runner among the bridges that have no agent budget.
kaxil
added a commit
to astronomer/airflow
that referenced
this pull request
Oct 14, 2026
The toolsets now take max_retries (apache#73957), so the guide no longer says they allow exactly one correction, and the retry budget docs list the Anthropic tool runner among the bridges that have no agent budget. The frameworks page also names the Anthropic SDK among the frameworks a team can keep.
kaxil
added a commit
to astronomer/airflow
that referenced
this pull request
Oct 14, 2026
The toolsets now take max_retries (apache#73957), so the guide no longer says they allow exactly one correction, and the retry budget docs list the Anthropic tool runner among the bridges that have no agent budget. The frameworks page also names the Anthropic SDK among the frameworks a team can keep.
kaxil
added a commit
that referenced
this pull request
Oct 14, 2026
Agents written on the Anthropic SDK's client.beta.messages.tool_runner can now use common.ai's connection-backed toolsets (SQLToolset, HookToolset, ObjectStorageToolset, sandboxes) through AirflowTools and AsyncAirflowTools, with the same guarantees as the Strands and ADK adapters: masked results, correctable failures returned as is_error results within the retry limit, and any other failure failing the task before the next model request. run_coroutine_sync now copies the caller's context into its worker thread, and the anthropic extra's floor moves to 1.1.0, the first release whose tool runner only runs a turn's tool calls when the turn ends in tool_use. * Tighten the Anthropic tool runner guide * Narrow the message block type in the Anthropic adapter tests * Mention toolset max_retries in the Anthropic tool runner guide The toolsets now take max_retries (#73957), so the guide no longer says they allow exactly one correction, and the retry budget docs list the Anthropic tool runner among the bridges that have no agent budget. The frameworks page also names the Anthropic SDK among the frameworks a team can keep. * Fail the Anthropic tool runner adapter's run at max_iterations mid-task A runner that reaches max_iterations while the model is still calling tools ends on that tool_use turn, which holds no answer. tools.run now raises ToolRunnerMaxIterationsError instead of returning it, so the task fails rather than succeeding with an empty result.
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.
SQLToolset,HookToolset,DataFusionToolsetandObjectStorageToolsetpinnedmax_retries=1on every tool, which overrides the agent'sretries. An agent givenretries=3still ended its run on the second failed query in a row, so a model that needed two tries to get a column name right could not recover. The only workaround was to subclass the toolset and rewritemax_retriesinget_tools.Each toolset now takes
max_retries, defaulting toNone, which uses the run's own tool retry budget (ctx.max_retries, the agent'sretries). That is the order pydantic-ai's ownFunctionToolsetandMCPServeruse, so these toolsets now behave like pydantic-ai's. The fallback lives once onAirflowToolset.Agents that already set
retriesnow apply it to these toolsets. They used to allow exactly one correction whateverretriessaid.retries=0now fails the run on the first bad query, and a large integerretriesmeant for output validation also lets a failing database be queried that many times. A dict such asretries={"output": 3}raises only the output budget, andmax_retries=1on a toolset keeps the old behaviour. The new docs section spells this out.What the budget counts differs by toolset, and the docs now say so.
SQLToolsetandDataFusionToolsetturn every query error intoModelRetry.HookToolsetcounts invalid arguments and attempts to change a pinned argument; an exception from the hook fails the run straight away.ObjectStorageToolsetcounts invalid arguments only, since a failed read comes back asToolFailed, which pydantic-ai does not count.Outside a pydantic-ai agent (the LangChain, Strands and Google ADK bridges) there is no agent budget, so the bridge's placeholder
RunContextnow carries pydantic-ai's default of one correction. Each bridged call also gets its own copy with the tool's retry count, as pydantic-ai'sToolManagerdoes, soctx.last_attemptmeans the same through a bridge as inside a run. One side effect: a bareFunctionToolsetorMCPToolsetbridged without its ownmax_retriesnow gets one correction instead of none, matching a default pydantic-ai agent.SandboxToolsetstill pinsmax_retries=2. Moving it to the agent's budget would lower its default to one, so it is left for a follow-up.Run end to end on a local Airflow 3.4.0 with a real
SQLToolsetagainst SQLite. The model is a scripted pydantic-aiFunctionModelthat misspells a column twice before reading the error, since a real model will not make the same mistake on demand. Withagent_params={"retries": 3}, the first two queries fail withno such column: totl, the third usestotal, and the task succeeds:The same Dag with the default budget still fails on the second error, as before: