Skip to content

Python: fix kernel_function decorator mutating shared Annotated metadata dicts - #14442

Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/kernel-function-metadata-mutation
Open

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/kernel-function-metadata-mutation

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Fixes #14441.

_parse_parameter() now reads the description with get() and copies only known keys into the parameter metadata instead of pop()-ing from the Annotated dict, so decoration never mutates caller-owned dicts and shared metadata keeps working across functions.

2 regression tests (shared-dict reuse keeps descriptions; source dict untouched) fail on main and pass here; tests/unit/functions green.

…ata dicts

_parse_parameter() called meta.pop("description") on dict metadata used
in typing.Annotated, mutating the user-provided dict. When the same
metadata dict is reused across multiple kernel functions (shared
parameter docs), every function after the first silently lost its
parameter description, and the dict itself was permanently modified.

Use meta.get() instead of meta.pop() and filter the description key out
when applying the remaining metadata keys, so semantics are unchanged
but the caller's dict is left untouched.

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.

This branch had an error being deployed

1 failed deployment
github-app-auth 851efcef Deployed Sep 13, 2026 by ManoharPaturi via review #510
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.

Python: @kernel_function mutates shared Annotated metadata dicts (description lost after first use)

2 participants