- 
                Notifications
    You must be signed in to change notification settings 
- Fork 633
Closed
Description
If you create an Agent with tools, and the Agent Name contains a blank space, and you invoke the streaming method, it fails with the error below.
If you don't pass tools, it works fine, even if the agent name contains a blank space.
If your AgentName does not contain a blank space, it works fine.
When not using streaming, all works fine.
So, with this code, it fails:
AIAgent agent = new AzureOpenAIClient(
    new Uri(endpoint),
    new AzureCliCredential())
     .GetChatClient(deploymentName)
     .CreateAIAgent(
        instructions: "You are a helpful assistant",
        name: "My Agent",
        tools: [AIFunctionFactory.Create(GetWeather)]);but this code works:
AIAgent agent = new AzureOpenAIClient(
    new Uri(endpoint),
    new AzureCliCredential())
     .GetChatClient(deploymentName)
     .CreateAIAgent(
        instructions: "You are a helpful assistant",
        name: "MyAgent",
        tools: [AIFunctionFactory.Create(GetWeather)]);Unhandled exception. System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: invalid_value)
Parameter: messages[2].name
Invalid 'messages[2].name': string does not match pattern. Expected a string that matches the pattern '^[^\s<|\\/>]+$'.
   at Azure.AI.OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
   at Azure.AI.OpenAI.Chat.AzureChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
   at OpenAI.Chat.ChatClient.<>c__DisplayClass17_0.<<CompleteChatStreamingAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at OpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+MoveNext()
   at OpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
Guess for some reason, when using streaming, the returned response is unexpected when combining tools and agent name contains a blank space (and maybe some other special char)
Happy to help if you want me to test something.
Thanks!