microsoft/semantic-kernel · error · ArgumentException
The streaming configuration must be null for non-streaming r
Error message
The streaming configuration must be null for non-streaming responses.
What it means
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.
Source
Thrown at dotnet/src/Agents/Bedrock/BedrockAgent.cs:434
}
#region internal methods
internal string CodeInterpreterActionGroupSignature { get => $"{this.GetDisplayName()}_CodeInterpreter"; }
internal string KernelFunctionActionGroupSignature { get => $"{this.GetDisplayName()}_KernelFunctions"; }
internal string UseInputActionGroupSignature { get => $"{this.GetDisplayName()}_UserInput"; }
#endregion
#region private methods
private IAsyncEnumerable<ChatMessageContent> InvokeInternalAsync(
InvokeAgentRequest invokeAgentRequest,
KernelArguments? arguments,
CancellationToken cancellationToken = default)
{
return invokeAgentRequest.StreamingConfigurations != null && (invokeAgentRequest.StreamingConfigurations.StreamFinalResponse ?? false)
? throw new ArgumentException("The streaming configuration must be null for non-streaming responses.")
: InvokeInternal();
// Collect all responses from the agent and return them as a single chat message content since this
// is a non-streaming API.
// The Bedrock Agent API streams beck different types of responses, i.e. text, files, metadata, etc.
// The Bedrock Agent API also won't stream back any content when it needs to call a function. It will
// only start streaming back content after the function has been called and the response is ready.
async IAsyncEnumerable<ChatMessageContent> InvokeInternal()
{
ChatMessageContentItemCollection items = [];
string content = "";
Dictionary<string, object?> metadata = [];
List<object?> innerContents = [];
await foreach (var message in this.InternalInvokeAsync(invokeAgentRequest, arguments, cancellationToken).ConfigureAwait(false))
{
items.AddRange(message.Items);
content += message.Content ?? "";View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
var request = new InvokeAgentRequest
{
StreamingConfigurations = new() { StreamFinalResponse = true },
};
await agent.InvokeInternalAsync(request, args); // non-streaming -> throws 175
// after
var request = new InvokeAgentRequest();
// StreamingConfigurations left null for non-streaming
await agent.InvokeInternalAsync(request, args); Defensive patterns
Strategy: validation
Validate before calling
if (request.StreamingConfigurations is not null && (request.StreamingConfigurations.StreamFinalResponse ?? false))
request.StreamingConfigurations = null; // clear for non-streaming path Type guard
static bool IsNonStreamingSafe(InvokeAgentRequest r) =>
r.StreamingConfigurations is null || !(r.StreamingConfigurations.StreamFinalResponse ?? false); Try / catch
try { await agent.InvokeInternalAsync(request, args, ct); }
catch (ArgumentException ex) when (ex.Message.Contains("null for non-streaming"))
{ /* clear StreamingConfigurations and retry */ } Prevention
- Do not set StreamingConfigurations on non-streaming requests.
- Build distinct request objects for streaming vs non-streaming paths.
When it happens
Trigger: 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.
Common situations: Request-builder helper that always sets StreamFinalResponse; copy-pasted request object from a streaming call into a non-streaming call.
Related errors
- The streaming configuration must have StreamFinalResponse se
- The Bedrock agent requires a message to be invoked.
- Bedrock agents must be invoked with a user message
- Invalid role: {authorRole}
- Message content cannot be null.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/a73bd5012df17401.
Report an issue: GitHub.