{"record":{"id":"a08c7de4bfe220f2","repo":"microsoft/semantic-kernel","slug":"the-streaming-configuration-must-have-streamfinalr","errorCode":null,"errorMessage":"The streaming configuration must have StreamFinalResponse set to true.","messagePattern":"The streaming configuration must have StreamFinalResponse set to true\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Agents/Bedrock/BedrockAgent.cs","lineNumber":491,"sourceCode":"        }\n    }\n\n    private IAsyncEnumerable<StreamingChatMessageContent> InvokeStreamingInternalAsync(\n        InvokeAgentRequest invokeAgentRequest,\n        AgentThread thread,\n        KernelArguments? arguments,\n        CancellationToken cancellationToken = default)\n    {\n        if (invokeAgentRequest.StreamingConfigurations == null)\n        {\n            invokeAgentRequest.StreamingConfigurations = new()\n            {\n                StreamFinalResponse = true,\n            };\n        }\n        else if (!(invokeAgentRequest.StreamingConfigurations.StreamFinalResponse ?? false))\n        {\n            throw new ArgumentException(\"The streaming configuration must have StreamFinalResponse set to true.\");\n        }\n\n        return InvokeInternal();\n\n        async IAsyncEnumerable<StreamingChatMessageContent> InvokeInternal()\n        {\n            var combinedResponseMessageBuilder = new StringBuilder();\n            StreamingChatMessageContent? lastMessage = null;\n\n            // The Bedrock agent service has the same API for both streaming and non-streaming responses.\n            // We are invoking the same method as the non-streaming response with the streaming configuration set,\n            // and converting the chat message content to streaming chat message content.\n            await foreach (var chatMessageContent in this.InternalInvokeAsync(invokeAgentRequest, arguments, cancellationToken).ConfigureAwait(false))\n            {\n                lastMessage = new StreamingChatMessageContent(chatMessageContent.Role, chatMessageContent.Content)\n                {\n                    AuthorName = chatMessageContent.AuthorName,\n                    ModelId = chatMessageContent.ModelId,","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Agents/Bedrock/BedrockAgent.cs#L473-L509","documentation":"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.","triggerScenarios":"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).","commonSituations":"Caller constructed a StreamingConfigurations object for other fields but forgot/declined StreamFinalResponse; reused a config object that disabled it.","solutions":["Set StreamingConfigurations.StreamFinalResponse = true, or","Leave StreamingConfigurations null so the streaming path sets it for you."],"exampleFix":"// before\nrequest.StreamingConfigurations = new() { StreamFinalResponse = false };\nawait agent.InvokeStreamingInternalAsync(request, args); // throws 176\n\n// after\nrequest.StreamingConfigurations = new() { StreamFinalResponse = true };","handlingStrategy":"validation","validationCode":"request.StreamingConfigurations ??= new() { StreamFinalResponse = true };\nrequest.StreamingConfigurations.StreamFinalResponse = true; // ensure true for streaming","typeGuard":"static bool IsStreamingReady(InvokeAgentRequest r) =>\n    r.StreamingConfigurations is null || (r.StreamingConfigurations.StreamFinalResponse ?? false);","tryCatchPattern":"try { await agent.InvokeStreamingInternalAsync(request, args, ct); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"StreamFinalResponse\"))\n{ /* set StreamFinalResponse = true or null out the config and retry */ }","preventionTips":["For streaming, either set StreamFinalResponse = true or leave StreamingConfigurations null.","Never set StreamFinalResponse = false on the streaming path."],"tags":["validation","bedrock","agent","streaming","misuse"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}