You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Bug: KernelFunctionSelectionStrategy and KernelFunctionTerminationStrategy default result_parser raises TypeError #14589
KernelFunctionSelectionStrategy and KernelFunctionTerminationStrategy (python/semantic_kernel/agents/strategies) both declare a default for result_parser that cannot be called the way the strategy calls it. The default is a zero-argument lambda, but select_agent and should_agent_terminate call self.result_parser(result) with one argument. If you do not pass your own result_parser, the strategy always fails with a TypeError.
SEL TypeError KernelFunctionSelectionStrategy.<lambda>.<locals>.<lambda>() takes 0 positional arguments but 1 was given
TERM TypeError KernelFunctionTerminationStrategy.<lambda>.<locals>.<lambda>() takes 0 positional arguments but 1 was given
Expected behavior
Constructing either strategy without a result_parser should work, or the field should be required. Today the field looks optional but is not.
Proposed fix
I would keep the field optional and give it a default that takes the function result:
Selection: return str(result).strip(), so a function that returns an agent name selects that agent.
Termination: return str(result).strip().lower() == "true", so a function that returns true ends the chat.
I picked this over making result_parser a required field because it does not break any caller that passes its own parser, and the behavior is easy to predict. For termination I did not keep "always return True" as the default, because that would stop the chat after the first check regardless of the function output, which makes the kernel function pointless.
I have a fix with tests ready and can open a PR if this direction is acceptable.
Hi! I'd like to work on this if nobody is already on it.
I plan a small fix so the default result_parser accepts the function result (selection: str(result).strip(); termination: treat "true" as terminate), plus regression tests for the current TypeError. Happy to adjust if maintainers prefer a different default.
Please assign me (Li-john1021) if that sounds alright — and sorry if I stepped on anyone who was already preparing a PR.
Activity
Li-john1021 commentedon Oct 14, 2026
Hi! I'd like to work on this if nobody is already on it.
I plan a small fix so the default
result_parseraccepts the function result (selection:str(result).strip(); termination: treat"true"as terminate), plus regression tests for the current TypeError. Happy to adjust if maintainers prefer a different default.Please assign me (Li-john1021) if that sounds alright — and sorry if I stepped on anyone who was already preparing a PR.