Repository navigation
fix: @kernel_function: do not mutate shared Annotated metadata dicts - #14479
Wu Shuwen (dajiaohuang) wants to merge 1 commit into
Conversation
_parse_parameter() called meta.pop('description') on the typing.Annotated
metadata dict, which mutates the caller's dict. When one shared metadata
dict is reused across multiple kernel functions, the description is lost
from all functions after the first decoration.
Replace pop with get() so the shared dict is never modified.
Fixes microsoft#14441.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Exclude description from bulk metadata updates to preserve existing description precedence.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes mutation of shared Annotated metadata dictionaries during kernel function decoration.
Changes:
- Replaces destructive metadata access with non-mutating lookup.
- Preserves caller-owned metadata for reuse.
| File | Description |
|---|---|
python/semantic_kernel/functions/kernel_function_decorator.py |
Updates metadata description handling; preserve existing description precedence during bulk updates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The shared-metadata mutation fix passes review, including repeated parsing and the existing method-function tests. The earlier bot precedence finding was not a regression; I checked the parent commit and closed that finding with the evidence. The remaining merge blocker is the expired failed gate/label/review workflows. Please update/rebase the branch so fresh required checks can run. |
|
Thanks for the fix. This bug is already fixed on main by #14496. I verified that the shared Annotated metadata no longer mutates when reused across decorated functions. Closing as superseded; no rebase or further changes are needed here. |

Description
_parse_parameter() called meta.pop("description") on the typing.Annotated metadata dict, which mutates the caller's dict. When one shared metadata dict is reused across multiple kernel functions, the description is lost from all functions after the first decoration.
Reproduction
Fix
Replace meta.pop("description") with meta.get("description") so the shared dict is never modified.
Fixes #14441.