Skip to content

Add max_retries to AgentSkillsToolset - #74381

Merged
kaxil merged 2 commits into
apache:mainfrom
astronomer:skills-toolset-max-retries
Oct 7, 2026
Merged

kaxil merged 2 commits into
apache:mainfrom
astronomer:skills-toolset-max-retries

Conversation

@kaxil

@kaxil kaxil commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Stacked on #74379. Until that merges, this diff also shows its commit; the changes here are the last two commits.

pydantic-ai-skills gives its tools a budget of one correction, and that toolset-level value overrides the agent's retries. So a model that named two missing skill resources in a row failed the run with UnexpectedModelBehavior: Tool 'read_skill_resource' exceeded max retries count of 1, even with agent_params={"retries": {"tools": 3}}. AgentSkillsToolset had no way to change that.

AgentSkillsToolset now takes max_retries with the same meaning it has on the SQL, hook, DataFusion and object storage toolsets:

  • None, the default, uses the agent's tool retry budget.
  • An integer gives the skills tools a budget of their own.

It works by setting each tool's budget in AgentSkillsToolset.get_tools, resolved the same way as AirflowToolset._get_tool_max_retries. Nothing is forwarded into pydantic-ai-skills, so the fix does not depend on how that library handles the value. With the agent's default retries of one, nothing changes for existing Dags.

A real-run test covers three cases:

  • With the default budget, the second refused read still fails the run.
  • With the agent's retries raised to 3, the run finishes. This case fails without the change.
  • An explicit max_retries=2 wins over the agent's value.

The restricted Agent Skills example now sets max_retries=3. The guide and the retry-budget section of the toolsets index describe the parameter, with both outcomes re-captured from a real run.

kaxil added 2 commits October 7, 2026 12:52
pydantic-ai-skills gives its tools a budget of one correction, and the
toolset-level value takes precedence over the agent's retries, so a model
that named two missing skill resources in a row failed the run however the
agent was configured. AgentSkillsToolset now takes max_retries and passes it
through, the same parameter the other toolsets in this provider expose. It is
only forwarded when set, so the default budget is unchanged.
Every other toolset in this provider treats max_retries=None as the agent's
tool retry budget. AgentSkillsToolset now does too: it sets each tool's budget
in get_tools, resolved the same way as AirflowToolset._get_tool_max_retries,
instead of forwarding the value into pydantic-ai-skills, whose toolset fixes
its own budget at one correction. With the agent's default retries of one,
the default behaviour is unchanged.
@kaxil
kaxil force-pushed the skills-toolset-max-retries branch from 36be001 to 48d2e08 Compare October 7, 2026 11:55
@kaxil
kaxil merged commit ef495f3 into apache:main Oct 7, 2026
84 checks passed
@kaxil
kaxil deleted the skills-toolset-max-retries branch October 7, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants