microsoft/semantic-kernel · error · ArgumentException

The streaming configuration must have StreamFinalResponse…

Error message

The streaming configuration must have StreamFinalResponse set to true.

What it means

Thrown by the streaming InvokeInternalAsync when StreamingConfigurations is non-null but StreamFinalResponse is not true. The streaming path requires StreamFinalResponse == true to actually receive streamed tokens; the code auto-sets it when null, but rejects an explicit false as a likely caller mistake.

Solutions

  1. Set StreamingConfigurations.StreamFinalResponse = true, or
  2. Leave StreamingConfigurations null so the streaming path sets it for you.

Example fix

// before
request.StreamingConfigurations = new() { StreamFinalResponse = false };
await agent.InvokeStreamingInternalAsync(request, args); // throws 176

// after
request.StreamingConfigurations = new() { StreamFinalResponse = true };
Defensive patterns

Strategy: validation

Validate before calling

request.StreamingConfigurations ??= new() { StreamFinalResponse = true };
request.StreamingConfigurations.StreamFinalResponse = true; // ensure true for streaming

Type guard

static bool IsStreamingReady(InvokeAgentRequest r) =>
    r.StreamingConfigurations is null || (r.StreamingConfigurations.StreamFinalResponse ?? false);

Try / catch

try { await agent.InvokeStreamingInternalAsync(request, args, ct); }
catch (ArgumentException ex) when (ex.Message.Contains("StreamFinalResponse"))
{ /* set StreamFinalResponse = true or null out the config and retry */ }

Prevention

When it happens

Trigger: Calling the streaming invoke path with an InvokeAgentRequest where StreamingConfigurations is provided but StreamFinalResponse is set to false (or left null inside an existing config object that the else-if branch catches).

Common situations: Caller constructed a StreamingConfigurations object for other fields but forgot/declined StreamFinalResponse; reused a config object that disabled it.

Related errors


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

Appendix: source

Thrown at dotnet/src/Agents/Bedrock/BedrockAgent.cs:491

        }
    }

    private IAsyncEnumerable<StreamingChatMessageContent> InvokeStreamingInternalAsync(
        InvokeAgentRequest invokeAgentRequest,
        AgentThread thread,
        KernelArguments? arguments,
        CancellationToken cancellationToken = default)
    {
        if (invokeAgentRequest.StreamingConfigurations == null)
        {
            invokeAgentRequest.StreamingConfigurations = new()
            {
                StreamFinalResponse = true,
            };
        }
        else if (!(invokeAgentRequest.StreamingConfigurations.StreamFinalResponse ?? false))
        {
            throw new ArgumentException("The streaming configuration must have StreamFinalResponse set to true.");
        }

        return InvokeInternal();

        async IAsyncEnumerable<StreamingChatMessageContent> InvokeInternal()
        {
            var combinedResponseMessageBuilder = new StringBuilder();
            StreamingChatMessageContent? lastMessage = null;

            // The Bedrock agent service has the same API for both streaming and non-streaming responses.
            // We are invoking the same method as the non-streaming response with the streaming configuration set,
            // and converting the chat message content to streaming chat message content.
            await foreach (var chatMessageContent in this.InternalInvokeAsync(invokeAgentRequest, arguments, cancellationToken).ConfigureAwait(false))
            {
                lastMessage = new StreamingChatMessageContent(chatMessageContent.Role, chatMessageContent.Content)
                {
                    AuthorName = chatMessageContent.AuthorName,
                    ModelId = chatMessageContent.ModelId,

View on GitHub (pinned to c028a0c7dc)