microsoft/semantic-kernel · error · KernelException

No function results were returned.

Error message

No function results were returned.

What it means

Thrown when building the session state to return function results to the Bedrock agent, but the list of FunctionResultContent is empty. This guard prevents sending an empty ReturnControlInvocationResults payload, which Bedrock would reject. The check fires before constructing the SessionState.

Source

Thrown at dotnet/src/Agents/Bedrock/Extensions/BedrockAgentInvokeExtensions.cs:203

    }

    private static async Task<List<FunctionResultContent>> InvokeFunctionCallsAsync(
        BedrockAgent agent,
        List<FunctionCallContent> functionCallContents,
        CancellationToken cancellationToken)
    {
        var functionResults = await Task.WhenAll(functionCallContents.Select(async functionCallContent =>
        {
            return await functionCallContent.InvokeAsync(agent.Kernel, cancellationToken).ConfigureAwait(false);
        })).ConfigureAwait(false);

        return [.. functionResults];
    }

    private static SessionState CreateSessionStateWithFunctionResults(List<FunctionResultContent> functionResults, BedrockAgent agent)
    {
        return functionResults.Count == 0
            ? throw new KernelException("No function results were returned.")
            : new()
            {
                InvocationId = functionResults[0].CallId,
                ReturnControlInvocationResults = [.. functionResults.Select(functionResult =>
                    {
                        return new InvocationResultMember()
                        {
                            FunctionResult = new Amazon.BedrockAgentRuntime.Model.FunctionResult
                            {
                                ActionGroup = agent.KernelFunctionActionGroupSignature,
                                Function = functionResult.FunctionName,
                                ResponseBody = new Dictionary<string, ContentBody>
                                {
                                    { "TEXT", new ContentBody() { Body = GetFunctionResultAsString(functionResult.Result) } }
                                }
                            }
                        };
                    }

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure every kernel function invoked by the Bedrock agent returns a non-null, serializable result (return a meaningful string or object, not null).
  2. Verify the function-calling pipeline is not dropping results via a filter or error handler.
  3. Inspect the functionCallContents being processed to confirm the functions were actually invoked.
  4. If a function legitimately has no result, return a placeholder string (e.g., "ok" or "{}") rather than null.

Example fix

// before
[KernelFunction]
public string DoWork() { return null; /* causes empty results */ }

// after
[KernelFunction]
public string DoWork() { /* do work */ return "completed"; }
Defensive patterns

Strategy: validation

Validate before calling

// Ensure kernel functions return non-null results before wiring them to the Bedrock agent
foreach (var fn in kernel.Plugins.GetFunctionsMetadata())
{
    // document/statically check that the method returns a non-null serializable value
}

Try / catch

try { await foreach (var r in agent.InvokeAsync(request, thread, cancellationToken)) { ... } }
catch (KernelException ex) when (ex.Message.Contains("No function results were returned"))
{
    logger.LogError("A function returned no result. Ensure all plugin functions return non-null values.");
    throw;
}

Prevention

When it happens

Trigger: During the Bedrock agent's function-calling loop, the agent requested function calls (ReturnControl), but all invoked functions returned null or produced no FunctionResultContent entries. This can happen if InvokeAsync on the kernel function returned null and the processing logic dropped it, or if the function-calling configuration filtered out all results.

Common situations: A plugin method returns null where a FunctionResultContent was expected; a function threw and the error was swallowed; misconfigured function invocation filter that skips result capture; the function returned a value that failed serialization upstream.

Related errors


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