{"record":{"id":"a73bd5012df17401","repo":"microsoft/semantic-kernel","slug":"the-streaming-configuration-must-be-null-for-non-s","errorCode":null,"errorMessage":"The streaming configuration must be null for non-streaming responses.","messagePattern":"The streaming configuration must be null for non-streaming responses\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Agents/Bedrock/BedrockAgent.cs","lineNumber":434,"sourceCode":"    }\n\n    #region internal methods\n\n    internal string CodeInterpreterActionGroupSignature { get => $\"{this.GetDisplayName()}_CodeInterpreter\"; }\n    internal string KernelFunctionActionGroupSignature { get => $\"{this.GetDisplayName()}_KernelFunctions\"; }\n    internal string UseInputActionGroupSignature { get => $\"{this.GetDisplayName()}_UserInput\"; }\n\n    #endregion\n\n    #region private methods\n\n    private IAsyncEnumerable<ChatMessageContent> InvokeInternalAsync(\n        InvokeAgentRequest invokeAgentRequest,\n        KernelArguments? arguments,\n        CancellationToken cancellationToken = default)\n    {\n        return invokeAgentRequest.StreamingConfigurations != null && (invokeAgentRequest.StreamingConfigurations.StreamFinalResponse ?? false)\n            ? throw new ArgumentException(\"The streaming configuration must be null for non-streaming responses.\")\n            : InvokeInternal();\n\n        // Collect all responses from the agent and return them as a single chat message content since this\n        // is a non-streaming API.\n        // The Bedrock Agent API streams beck different types of responses, i.e. text, files, metadata, etc.\n        // The Bedrock Agent API also won't stream back any content when it needs to call a function. It will\n        // only start streaming back content after the function has been called and the response is ready.\n        async IAsyncEnumerable<ChatMessageContent> InvokeInternal()\n        {\n            ChatMessageContentItemCollection items = [];\n            string content = \"\";\n            Dictionary<string, object?> metadata = [];\n            List<object?> innerContents = [];\n\n            await foreach (var message in this.InternalInvokeAsync(invokeAgentRequest, arguments, cancellationToken).ConfigureAwait(false))\n            {\n                items.AddRange(message.Items);\n                content += message.Content ?? \"\";","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Agents/Bedrock/BedrockAgent.cs#L416-L452","documentation":"Thrown by the internal non-streaming InvokeInternalAsync on BedrockAgent when the request's StreamingConfigurations has StreamFinalResponse set true. Because this is the non-streaming code path, a streaming configuration is contradictory; the guard prevents misuse where a caller (or a shared request builder) accidentally enables streaming on a non-streaming call.","triggerScenarios":"Calling the non-streaming invoke path with an InvokeAgentRequest whose StreamingConfigurations.StreamFinalResponse is true. Often happens when the same request object is reused for both paths, or a wrapper sets streaming config unconditionally.","commonSituations":"Request-builder helper that always sets StreamFinalResponse; copy-pasted request object from a streaming call into a non-streaming call.","solutions":["Do not set StreamingConfigurations (or set it null) when invoking the non-streaming path.","If reusing a request builder, parameterize whether streaming is enabled and only set StreamingConfigurations on the streaming path."],"exampleFix":"// before\nvar request = new InvokeAgentRequest\n{\n    StreamingConfigurations = new() { StreamFinalResponse = true },\n};\nawait agent.InvokeInternalAsync(request, args); // non-streaming -> throws 175\n\n// after\nvar request = new InvokeAgentRequest();\n// StreamingConfigurations left null for non-streaming\nawait agent.InvokeInternalAsync(request, args);","handlingStrategy":"validation","validationCode":"if (request.StreamingConfigurations is not null && (request.StreamingConfigurations.StreamFinalResponse ?? false))\n    request.StreamingConfigurations = null; // clear for non-streaming path","typeGuard":"static bool IsNonStreamingSafe(InvokeAgentRequest r) =>\n    r.StreamingConfigurations is null || !(r.StreamingConfigurations.StreamFinalResponse ?? false);","tryCatchPattern":"try { await agent.InvokeInternalAsync(request, args, ct); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"null for non-streaming\"))\n{ /* clear StreamingConfigurations and retry */ }","preventionTips":["Do not set StreamingConfigurations on non-streaming requests.","Build distinct request objects for streaming vs non-streaming paths."],"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"}