You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2026/10/06 23:11:25 UTC

[PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

kaxil opened a new pull request, #74380:
URL: https://github.com/apache/airflow/pull/74380

   Stacked on #74379. Until that merges, this diff also shows its commit; the change here is the last commit.
   
   `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. That only happened for methods that also take `**kwargs`. For an ordinary method with named parameters, such as `S3Hook.read_key`, the toolset's argument 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 validator is now built from a copy of the schema that still accepts the pinned names as optional. A model that sends one reaches `execute_tool` and gets `bucket_name is fixed for this tool: call it again without it.`, whatever the method's signature. What the model is shown is unchanged, and the pinned value is still the one passed to the hook.
   
   The existing real-run test now covers both signatures, and the named-parameter case fails without the fix. The hook guide's pinned-argument paragraph and the captured refusal in its "Restricting the agent" section are updated to the new message, recaptured from the example Dag running through `AgentOperator`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on code in PR #74380:
URL: https://github.com/apache/airflow/pull/74380#discussion_r4203151982


##########
providers/common/ai/src/airflow/providers/common/ai/toolsets/hook.py:
##########
@@ -181,6 +181,12 @@ async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]:
                 if param_name in json_schema.get("properties", {}):
                     json_schema["properties"][param_name]["description"] = param_desc
             _drop_properties(json_schema, self._pinned)
+            # The validator accepts the pinned names, with any value, so a model that sends one
+            # anyway is told it is fixed rather than given a generic extra-input or type error.
+            args_schema = {
+                **json_schema,
+                "properties": {**json_schema["properties"], **dict.fromkeys(self._pinned, {})},

Review Comment:
   tiny nit: `dict.fromkeys(self._pinned, {})` points every pinned key at the same `{}` object. It's read-only here so it's harmless, but `{name: {} for name in self._pinned}` reads a bit clearer about the intent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #74380:
URL: https://github.com/apache/airflow/pull/74380


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #74380:
URL: https://github.com/apache/airflow/pull/74380#discussion_r4206779514


##########
providers/common/ai/src/airflow/providers/common/ai/toolsets/hook.py:
##########
@@ -181,6 +181,12 @@ async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]:
                 if param_name in json_schema.get("properties", {}):
                     json_schema["properties"][param_name]["description"] = param_desc
             _drop_properties(json_schema, self._pinned)
+            # The validator accepts the pinned names, with any value, so a model that sends one
+            # anyway is told it is fixed rather than given a generic extra-input or type error.
+            args_schema = {
+                **json_schema,
+                "properties": {**json_schema["properties"], **dict.fromkeys(self._pinned, {})},

Review Comment:
   Done, switched to `json_schema["properties"] | {name: {} for name in self._pinned}` so each pinned name gets its own fragment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on code in PR #74380:
URL: https://github.com/apache/airflow/pull/74380#discussion_r4203151982


##########
providers/common/ai/src/airflow/providers/common/ai/toolsets/hook.py:
##########
@@ -181,6 +181,12 @@ async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]:
                 if param_name in json_schema.get("properties", {}):
                     json_schema["properties"][param_name]["description"] = param_desc
             _drop_properties(json_schema, self._pinned)
+            # The validator accepts the pinned names, with any value, so a model that sends one
+            # anyway is told it is fixed rather than given a generic extra-input or type error.
+            args_schema = {
+                **json_schema,
+                "properties": {**json_schema["properties"], **dict.fromkeys(self._pinned, {})},

Review Comment:
   nit: `dict.fromkeys(self._pinned, {})` points every pinned key at the same `{}` object. It's read only here so it's harmless, but `{name: {} for name in self._pinned}` reads a bit clearer about the intent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Tell the model a pinned hook argument is fixed for every allowed method [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on PR #74380:
URL: https://github.com/apache/airflow/pull/74380#issuecomment-6034289464

   should be fine to merge it after resolving conflict


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org