Python: @kernel_function mutates shared Annotated metadata dicts (description lost after first use)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start in semantic_kernel/functions/kernel_function_decorator.py at _parse_parameter(), then run the reproduction from the issue with two functions sharing Annotated metadata. Done means decoration leaves caller-owned metadata unchanged and both functions retain the description; add or update a regression test if the surrounding test structure identifies a suitable location.
Written by the indexing model from the issue text.
Description
Description
@kernel_function's _parse_parameter() calls meta.pop("description") on dict metadata inside typing.Annotated, mutating the caller's dict. Reusing one shared metadata dict across kernel functions silently strips the parameter description from every function after the first, and leaves the user's dict empty.
Reproduction
from typing import Annotated
from semantic_kernel.functions.kernel_function_decorator import kernel_function
from semantic_kernel.functions import KernelFunctionFromMethod
shared = {"description": "the answer count"}
@kernel_function
def a(x: Annotated[int, shared]) -> int: ...
@kernel_function
def b(y: Annotated[int, shared]) -> int: ...
KernelFunctionFromMethod(a, "a").metadata.parameters[0].description # 'the answer count'
KernelFunctionFromMethod(b, "b").metadata.parameters[0].description # None <-- lost
shared # {} <-- caller's dict mutated
Expected behavior
Decoration never mutates caller-owned metadata; both functions see the description.
Environment
semantic-kernel python main (ca40aa72), Python 3.12
- Dominant language
- C#
- Stars
- 28.6k
- Forks
- 4.8k
- Avg merge
- 14h 13m
- Merged PRs (30d)
- 18
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/semantic-kernel
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/semantic-kernel#14460 ·
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/semantic-kernel#14443 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/semantic-kernel#14359 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/semantic-kernel#14347 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/semantic-kernel#14311 · 2 comments ·
All issues in microsoft/semantic-kernel
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·