You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.Net: KernelFunctionSelectionStrategy.SelectAgentAsync and KernelFunctionTerminationStrategy.ShouldAgentTerminateAsync does not support streaming.
#11505
Open
0xLiao opened this issue
Apr 11, 2025
· 0 comments
{"error":{"code":"invalid_parameter_error","param":null,"message":"This model only support stream mode, please enable the stream parameter to access the model. ","type":"invalid_request_error"}
Microsoft.SemanticKernel.HttpOperationException: HTTP 400 (: 10137)
System.AggregateException: One or more errors occurred. (HTTP 400 (: 10137
)
After analyzing, I found that while the first request uses streaming mode, it switches to non-streaming when .SelectAgentAsync selects the next Agent:
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetChatMessageContentsAsync(String targetModel, ChatHistory chatHistory, PromptExecutionSettings executionSettings, Kernel kernel, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunctionFromPrompt.GetChatCompletionResultAsync(IChatCompletionService chatCompletion, Kernel kernel, PromptRenderingResult promptRenderingResult, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunctionFromPrompt.InvokeCoreAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunction.<>c__DisplayClass27_0.<<InvokeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.SemanticKernel.Kernel.InvokeFilterOrFunctionAsync(NonNullCollection`1 functionFilters, Func`2 functionCallback, FunctionInvocationContext context, Int32 index)
at Microsoft.SemanticKernel.Kernel.OnFunctionInvocationAsync(KernelFunction function, KernelArguments arguments, FunctionResult functionResult, Boolean isStreaming, Func`2 functionCallback, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunction.InvokeAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Agents.Chat.KernelFunctionSelectionStrategy.SelectAgentAsync(IReadOnlyList`1 agents, IReadOnlyList`1 history, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Agents.Chat.SelectionStrategy.NextAsync(IReadOnlyList`1 agents, IReadOnlyList`1 history, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Agents.AgentGroupChat.SelectAgentAsync(CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+MoveNext()
Although I explicitly used AgentGroupChat.InvokeStreamingAsync, the KernelFunctionSelectionStrategy.SelectAgentAsync method always calls KernelFunction.InvokeAsync internally. I found in the source code that it's hardcoded to use non-streaming invocation without any streaming support:
github-actionsbot
changed the title
.NET: KernelFunctionSelectionStrategy.SelectAgentAsync and KernelFunctionTerminationStrategy.ShouldAgentTerminateAsync does not support streaming.
.Net: KernelFunctionSelectionStrategy.SelectAgentAsync and KernelFunctionTerminationStrategy.ShouldAgentTerminateAsync does not support streaming.
Apr 11, 2025
While following the documentation to use the Agent Collaboration capability, since the model only supports streaming mode, I modified
await foreach (ChatMessageContent response in chat.InvokeAsync())
to
await foreach (StreamingChatMessageContent response in chat.InvokeStreamingAsync())
The first Agent sent the request with streaming enabled, send:
"model":"Qwen/QwQ-32B","stream":true,"stream_options":{"include_usage":true}"
but immediately threw an exception afterward.
After analyzing, I found that while the first request uses streaming mode, it switches to non-streaming when .SelectAgentAsync selects the next Agent:
Although I explicitly used
AgentGroupChat.InvokeStreamingAsync
, theKernelFunctionSelectionStrategy.SelectAgentAsync
method always callsKernelFunction.InvokeAsync
internally. I found in the source code that it's hardcoded to use non-streaming invocation without any streaming support:It appears there's no external configuration option to force streaming mode behavior in this case.
Platform
The text was updated successfully, but these errors were encountered: