Skip to content

Tell the model a pinned hook argument is fixed for every allowed method - #74380

Merged
kaxil merged 3 commits into
apache:mainfrom
astronomer:hook-pinned-argument-message
Oct 7, 2026
Merged

kaxil merged 3 commits into
apache:mainfrom
astronomer:hook-pinned-argument-message

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.

HookToolset(pinned_arguments=...) leaves a pinned argument out of the schema the model sees, and refuses it if the model sends it anyway. The refusal is meant to tell the model the argument is fixed, but that only happened for methods that also take **kwargs. For an ordinary method with named parameters, such as S3Hook.read_key, the validator was built from the trimmed schema, so it rejected the pinned name first. The model got a generic pydantic error instead:

[{'type': 'extra_forbidden', 'loc': ('bucket_name',), 'msg': 'Extra inputs are not permitted', 'input': 'acme-payroll'}]

The refusal also ran late, in execute_tool. A toolset wrapped in .approval_required() therefore asked a person to approve the call with bucket_name='acme-payroll' in it, and only refused it after approval.

Now the validator's schema adds the pinned names back as untyped optional properties, and the refusal runs as the tool's args_validator_func, during validation. Whatever the method's signature or the value's type, the model gets bucket_name is fixed for this tool: call it again without it., and an approval gate never sees the call. execute_tool keeps the same check for the framework bridges (LangChain, Strands, ADK), which validate arguments without args_validator_func. args_validator_func is present at the provider's pydantic-ai-slim floor, 2.33.0.

What the model is shown is unchanged, and the pinned value is still the one passed to the hook.

There are two regression tests, and each fails without the change:

  • The existing real-run test now covers both signatures. The named-parameter case is the one that used to fail.
  • A new test wraps the toolset in .approval_required() and checks that the approval request contains only the corrected call.

The hook guide's pinned-argument paragraph and the captured refusal are updated. The capture was re-run with the example Dag going through AgentOperator.

@vatsrahul1001 vatsrahul1001 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Static checks failure not related to this PR. I have a fix for it #74390

@Lee-W

Lee-W commented Oct 7, 2026

Copy link
Copy Markdown
Member

should be fine to merge it after resolving conflict

kaxil added 3 commits October 7, 2026 12:52
When the model supplied a pinned argument to a HookToolset method with
named parameters, such as S3Hook.read_key, argument validation rejected it
first with a generic "Extra inputs are not permitted" error, and the
toolset's own "is fixed for this tool" message only ever reached methods
that also take **kwargs. The toolset now validates against a schema that
still accepts the pinned names, so every refusal tells the model the
argument is fixed. The model is still shown the schema without them.
The refusal ran in execute_tool, after an approval gate had already asked a
person to approve the call with the pinned argument in it. It now runs as the
tool's args_validator_func, so the call is refused before any gate or the hook
sees it; execute_tool keeps the check for the framework bridges, which validate
arguments without that hook. The validator schema now adds the pinned names
back as untyped optional properties instead of re-deriving the required list,
so a pinned argument sent with the wrong type is also told it is fixed.
@kaxil
kaxil force-pushed the hook-pinned-argument-message branch from 09db935 to eaa6639 Compare October 7, 2026 11:55
@kaxil
kaxil merged commit 4ef67b4 into apache:main Oct 7, 2026
84 of 85 checks passed
@kaxil
kaxil deleted the hook-pinned-argument-message branch October 7, 2026 13:17
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