Skip to content

Python: Preserve already-typed native function arguments - #14643

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
original4422:fix/14642-preserve-typed-arguments
Oct 26, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
original4422:fix/14642-preserve-typed-arguments

Conversation

@original4422

Copy link
Copy Markdown
Contributor

Summary

Fixes #14642.

 native argument parsing
   revalidate Pydantic models
   recursively parse lists
+  preserve existing custom-class instances (including subclasses)
   construct other values

This avoids constructor errors for two-field dataclasses and silent nesting for one-field dataclasses. Built-in coercion, dictionary construction and Pydantic revalidation stay intact.

Evidence

  • Before: 8 new public Kernel.invoke regression cases fail on main, covering ordinary/dataclass instances, subclasses, repeated calls, mixed lists and function-to-function values.
    After: python -m pytest tests/unit/functions tests/unit/kernel — 306 passed, 0 skipped on macOS/Python 3.12.
  • Pydantic revalidate_instances="always", invalid-instance rejection and built-in integer coercion remain covered.
  • pre-commit run --config python/.pre-commit-config.yaml --all-files — all 13 hooks pass, including Ruff check/format. The repository-locked mypy 1.19.1 reports no issues in all 556 package source files.
  • Existing deprecation/OpenAI cleanup warnings remain in the unit run; no model or service integration tests were run.

Merge Danger

Door: two-way

Blast Radius: argument-parsing

Limited to preserving custom instances already accepted by their parameter type; no API signatures or generic/union handling change.

@original4422
Daniel Peng (original4422) requested a review from a team as a code owner October 23, 2026 00:46
Copilot AI balanced review requested due to automatic review settings October 23, 2026 00:46

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Oct 23, 2026
@original4422

Copy link
Copy Markdown
Contributor Author

Jose Alvarez (@jpalvarezl), when convenient, could you review this Python fix for already-typed native function arguments? It preserves custom instances and subclasses while retaining Pydantic revalidation and built-in coercion. The local functions/kernel tests (306) and all 13 pre-commit hooks pass. Thank you!

@original4422

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg), when you have a chance, could you review this Python fix for preserving already-typed custom instances passed through KernelArguments to native functions? It also covers subclasses, lists and function-to-function values while retaining Pydantic revalidation and built-in coercion. Thanks for taking a look!

Merged via the queue into microsoft:main with commit 5e6e461 Oct 26, 2026
37 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — f33a6edd Deployed Oct 23, 2026 by original4422 via team_check #660
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.

Python: native functions reconstruct already-typed dataclass arguments

3 participants