Skip to content

Python: Reject tool call arguments for parameters with include_in_function_choices=False - #14774

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:python-reject-hidden-parameter-tool-args
Nov 10, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:python-reject-hidden-parameter-tool-args

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation and Context

Parameters declared with {"include_in_function_choices": False} are left out of the tool schema that is sent to the model, and the docs describe them as values the host supplies through KernelArguments. Kernel.invoke_function_call still accepted those names in a model tool call, so a value from the model took precedence over the invocation-level value.

This change makes argument handling match the schema: a tool call can only set the parameters that were advertised to the model. It is the counterpart of #14625, which stopped advertising these parameters in the Anthropic, Bedrock, Google AI and Vertex AI tool formats. There is no related open issue.

Description

  • Kernel.invoke_function_call builds the set of accepted argument names from the parameters that have include_in_function_choices=True. A tool call that includes a hidden parameter gets the existing "Received unexpected argument(s)" result and the function is not invoked, so the model can retry without it.
  • Hidden parameters still get their value from the invocation-level KernelArguments or from their default. The required-parameter check is unchanged.
  • The kernel_function docstring now states that a tool call from the model cannot set such a parameter.
  • Tests in tests/unit/kernel/test_kernel.py cover a hidden name in dict and JSON-string arguments (the function must not run and the result must be the unexpected-argument message) and a host-supplied hidden value that still reaches the function. The two rejection tests fail without the change.

Compatibility: Bedrock agents create their function schema server-side when the action group is created, so action groups created before #14625 (released in python 1.46.0) still list hidden parameters. Calls from such agents that include a hidden name now get the unexpected-argument result until the action group is re-created.

Validation, run on Python 3.13 (macOS) in an environment built like the unit-test workflow (uv pip install --editable ".[<all extras>]" --group dev), from python/ unless noted:

  • uv run --no-sync python -u -X faulthandler -m pytest -p no:cacheprovider -n auto ./tests/unit --ignore=tests/unit/processes/dapr_runtime: 4983 passed, 1 skipped, 5 xfailed. The dapr suite was not run locally.
  • uv run --no-sync pytest -p no:cacheprovider tests/unit/kernel/test_kernel.py -k hidden_parameter: 3 passed.
  • uv run --no-sync pre-commit run --config python/.pre-commit-config.yaml --files <the three changed files> (from the repo root): all hooks passed or had no files to check.
  • uv run --no-sync mypy -p semantic_kernel --config-file mypy.ini: 42 errors in 7 files, none in the changed files. Unmodified main reports the same total (42 errors in 7 files) in this environment.

Contribution Checklist

…ction_choices=False

Kernel.invoke_function_call now accepts only the parameters that were advertised to the model. A tool call that names a parameter hidden with include_in_function_choices=False gets the existing unexpected-argument result and the function is not invoked. Hidden parameters keep getting their value from the invocation-level arguments or their default.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:01
@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Nov 10, 2026

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the change rejecting model-supplied arguments for hidden parameters.

No open issues 🎉

What changed in this PR

This PR aligns Python auto function calling with tool schemas by rejecting model-supplied arguments for parameters marked include_in_function_choices=False. It complements #14625, which excluded these parameters from additional providers’ tool schemas.

Changes:

  • Reject hidden parameter names through the existing unexpected-argument response.
  • Document that hidden values come from invocation-level arguments or parameter defaults.
  • Add tests for rejection of dict and JSON-string arguments and preservation of host-supplied values.
File Description
python/​tests/​unit/​kernel/​test_kernel.py Adds hidden-parameter rejection and host-value preservation tests.
python/​semantic_kernel/​kernel.py Restricts accepted model arguments to visible parameters.
python/​semantic_kernel/​functions/​kernel_function_decorator.py Documents hidden-parameter handling during auto function calling.

Review effort: Balanced

Merged via the queue into microsoft:main with commit 25bd1bb Nov 10, 2026
41 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the python-reject-hidden-parameter-tool-args branch November 10, 2026 16:48

This branch was successfully deployed

1 active deployment
github-app-auth — c66f3c99 Deployed Nov 10, 2026 by eavanvalkenburg via add_label #29655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants