Skip to content

.Net AgentGroupChat got 'does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.1.name' when using ToolCallBehavior.AutoInvokeKernelFunctions #6717

@strikene

Description

@strikene

I'm trying to save/restore the Agent dialog to reuse.
I have saved ChatMessageContent.Content ,ChatMessageContent.AuthorName
When I reverted I used the following code
new ChatMessageContent(item.Role, item.Content) { AuthorName = item.AuthorName }

i got error
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Microsoft.SemanticKernel.HttpOperationException: '' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.1.name'
Status: 400 (model_error)

  Content:
  {

"error": {
"message": "'' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.1.name'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

  Headers:
  Access-Control-Allow-Origin: REDACTED
  apim-request-id: REDACTED
  x-ratelimit-remaining-requests: REDACTED
  Strict-Transport-Security: REDACTED
  x-ratelimit-remaining-tokens: REDACTED
  x-ms-rai-invoked: REDACTED
  X-Request-ID: REDACTED
  ms-azureml-model-error-reason: REDACTED
  ms-azureml-model-error-statuscode: REDACTED
  X-Content-Type-Options: REDACTED
  azureml-model-session: REDACTED
  x-ms-region: REDACTED
  Content-Length: 174
  Content-Type: application/json

   ---> Azure.RequestFailedException: '' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.1.name'
  Status: 400 (model_error)

  Content:
  {

"error": {
"message": "'' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.1.name'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

  Headers:
  Access-Control-Allow-Origin: REDACTED
  apim-request-id: REDACTED
  x-ratelimit-remaining-requests: REDACTED
  Strict-Transport-Security: REDACTED
  x-ratelimit-remaining-tokens: REDACTED
  x-ms-rai-invoked: REDACTED
  X-Request-ID: REDACTED
  ms-azureml-model-error-reason: REDACTED
  ms-azureml-model-error-statuscode: REDACTED
  X-Content-Type-Options: REDACTED
  azureml-model-session: REDACTED
  x-ms-region: REDACTED
  Content-Length: 174
  Content-Type: application/json

     at Azure.Core.HttpPipelineExtensions.ProcessMessageAsync(HttpPipeline pipeline, HttpMessage message, RequestContext requestContext, CancellationToken cancellationToken)
     at Azure.AI.OpenAI.OpenAIClient.GetChatCompletionsAsync(ChatCompletionsOptions chatCompletionsOptions, CancellationToken cancellationToken)
     at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
     --- End of inner exception stack trace ---
     at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
     at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetChatMessageContentsAsync(ChatHistory chat, PromptExecutionSettings executionSettings, Kernel kernel, CancellationToken cancellationToken)
     at Microsoft.SemanticKernel.Agents.ChatCompletionAgent.InvokeAsync(IReadOnlyList`1 history, ILogger logger, CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.ChatCompletionAgent.InvokeAsync(IReadOnlyList`1 history, ILogger logger, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
     at Microsoft.SemanticKernel.Agents.ChatHistoryChannel.InvokeAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.ChatHistoryChannel.InvokeAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.ChatHistoryChannel.InvokeAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
     at Microsoft.SemanticKernel.Agents.AgentChat.InvokeAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.AgentChat.InvokeAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.AgentChat.InvokeAgentAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
     at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeAsync(CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeAsync(CancellationToken cancellationToken)+MoveNext()
     at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()

new ChatCompletionAgent()
{
ExecutionSettings = new OpenAIPromptExecutionSettings
{
ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions ,
Temperature = 0.75
},
Instructions = Instructions,
Name = AgentName,
Kernel = k,
}
);

I have enabled several plugins in the kernel , and once ToolCallBehavior=null, there will be no problem
Does that mean I'm saving/restoring the conversation with something missing?

Platform

  • OS: win11
  • IDE: Visual Studio
  • Language: C#
  • Source: Microsoft.SemanticKernel Version="1.13.0

Metadata

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't workingkernelIssues or pull requests impacting the core kernel

Type

No type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions