microsoft/semantic-kernel · error · AgentExecutionException

Agent Failure - Strategy unable to determine next agent.

Error message

Agent Failure - Strategy unable to determine next agent.

What it means

After the selection function succeeds, result_parser(result) must yield an agent name string. If it returns None (after awaiting if it is a coroutine), the strategy cannot proceed and raises AgentExecutionException. Note the default parser returns '' (empty string), which does NOT trigger this branch, so this requires a custom parser that returns None.

Source

Thrown at python/semantic_kernel/agents/strategies/selection/kernel_function_selection_strategy.py:110

        )

        try:
            result = await self.function.invoke(kernel=self.kernel, arguments=arguments)
        except Exception as ex:
            logger.error("Kernel Function Selection Strategy next method failed", exc_info=ex)
            raise AgentExecutionException("Agent Failure - Strategy failed to execute function.") from ex

        logger.info(
            f"Kernel Function Selection Strategy next method completed: "
            f"{self.function.plugin_name}, {self.function.name}, result: {result.value if result else None}",
        )

        agent_name = self.result_parser(result)
        if isawaitable(agent_name):
            agent_name = await agent_name

        if agent_name is None:
            raise AgentExecutionException("Agent Failure - Strategy unable to determine next agent.")

        agent_turn = next((agent for agent in agents if agent.name == agent_name), None)
        if agent_turn is None:
            raise AgentExecutionException(f"Agent Failure - Strategy unable to select next agent: {agent_name}")

        return agent_turn

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Make result_parser always return a valid agent name string, with an explicit fallback rather than None.
  2. Improve the selection prompt/function so it consistently returns a parseable name.
  3. Return the first agent's name or a known-safe default when parsing fails.

Example fix

// before
def parse(result):
    name = extract(result.value)
    return name  # returns None when extraction fails

// after
def parse(result):
    name = extract(result.value)
    return name or agents[0].name  # always a concrete name
Defensive patterns

Strategy: validation

Validate before calling

name = strategy.result_parser(result)
if isawaitable(name):
    name = await name
assert name is not None, 'result_parser returned None; provide a fallback name'

Type guard

def safe_parser(result, fallback: str) -> str:
    value = parse(result)
    return value if value is not None else fallback

Prevention

When it happens

Trigger: A custom result_parser returns None for the given result, e.g. because it could not extract a name from the function output, or a code path returns None instead of a default.

Common situations: Parser logic that returns None on unexpected/empty LLM output; a parser that maps only known names and returns None for anything else; the function returned an empty or malformed result that the parser cannot handle.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/ae7aa4c4286dfada. Report an issue: GitHub.