Skip to content

Bug: Step04_AgentOrchestration: ChatMessageContent error deserializing Intent #11147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Xavina opened this issue Mar 24, 2025 · 0 comments · Fixed by #11455
Closed

Bug: Step04_AgentOrchestration: ChatMessageContent error deserializing Intent #11147

Xavina opened this issue Mar 24, 2025 · 0 comments · Fixed by #11455
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code samples

Comments

@Xavina
Copy link

Xavina commented Mar 24, 2025

Describe the bug
When running the test Step04_AgentOrchestration, this is shown but tests passes:

Step04.Step04_AgentOrchestration.DelegatedGroupChatAsync

  Source: Step04_AgentOrchestration.cs line 33
  Duration: 1,4 sec

 Standard Output: 
   USER: Hi
   [00:00] USER: Hi
   [00:00] ASSISTANT - Manager: Hello! How can I assist you today?
   [00:01] ERROR: The type initializer for 'Step04.Steps.ManagerAgentStep' threw an exception. [KernelProcessError]
      at Step04.Steps.ManagerAgentStep.IsRequestingUserInputAsync(Kernel kernel, ChatHistory history, ILogger logger) in ..\Microsoft\semantic-kernel\dotnet\samples\GettingStartedWithProcesses\Step04\Steps\ManagerAgentStep.cs:line 107
      at Step04.Steps.ManagerAgentStep.InvokeAgentAsync(KernelProcessStepContext context, Kernel kernel, String userInput, ILogger logger) in ..\Microsoft\semantic-kernel\dotnet\samples\GettingStartedWithProcesses\Step04\Steps\ManagerAgentStep.cs:line 55
      at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c.<<GetReturnValueMarshalerDelegate>b__25_1>d.MoveNext() in ..\Microsoft\semantic-kernel\dotnet\src\SemanticKernel.Core\Functions\KernelFunctionFromMethod.cs:line 852
   --- End of stack trace from previous location ---
      at Microsoft.SemanticKernel.KernelFunction.<>c__DisplayClass27_0.<<InvokeAsync>b__0>d.MoveNext() in ..\Microsoft\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\Functions\KernelFunction.cs:line 247
   --- End of stack trace from previous location ---
      at Microsoft.SemanticKernel.Kernel.InvokeFilterOrFunctionAsync(NonNullCollection`1 functionFilters, Func`2 functionCallback, FunctionInvocationContext context, Int32 index) in ..\Microsoft\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\Kernel.cs:line 344
      at Microsoft.SemanticKernel.Kernel.OnFunctionInvocationAsync(KernelFunction function, KernelArguments arguments, FunctionResult functionResult, Boolean isStreaming, Func`2 functionCallback, CancellationToken cancellationToken) in ..\Microsoft\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\Kernel.cs:line 319
      at Microsoft.SemanticKernel.KernelFunction.InvokeAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken) in ..\Microsoft\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\Functions\KernelFunction.cs:line 244
      at Microsoft.SemanticKernel.LocalStep.HandleMessageAsync(ProcessMessage message) in ..\Microsoft\semantic-kernel\dotnet\src\Experimental\Process.LocalRuntime\LocalStep.cs:line 213
   --------------------------------------------------------------------------------
   [00:01] USER: Hi
   [00:01] ASSISTANT - Manager: Hello! How can I assist you today?


To Reproduce
Steps to reproduce the behavior:

  1. Configure secrets with gpt-4o-mini
  2. Run the test
  3. See error

Expected behavior
A conversation between a Manager and a User takes place. The final sentences looks like:

    [00:34] USER: That's all, thank you
    [00:34] ASSISTANT - Manager: You're welcome! If you need anything else in the future, just let me know. Have a great day!

Screenshots

Platform

Additional context
Managed to fix the issue, but need you to double check.

The root problem is at: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithProcesses/Step04/Steps/ManagerAgentStep.cs line 107. It is trying to retrieve the 'ResponseFormat' for IntentResult from:

private static readonly ChatResponseFormat s_intentResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
        jsonSchemaFormatName: "intent_result",
        jsonSchema: BinaryData.FromString(JsonSchemaGenerator.FromType<IntentResult>()),
        jsonSchemaIsStrict: true);

Looks like it is not working just return the type of IntentResult:

private static readonly Type s_intentResponseFormat = typeof(IntentResult);

As stated in Structured Outputs with System.Type.

Suggestion
Make the test fail if something weird happen:

In https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithProcesses/Step04/Steps/RenderMessageStep.cs, add an Assert.Fail() on RenderError Function:

    /// <summary>
    /// Render exception
    /// </summary>
    [KernelFunction]
    public void RenderError(KernelProcessError error, ILogger logger)
    {
        string message = string.IsNullOrWhiteSpace(error.Message) ? "Unexpected failure" : error.Message;
        Render($"ERROR: {message} [{error.GetType().Name}]{Environment.NewLine}{error.StackTrace}");
        logger.LogError("Unexpected failure: {ErrorMessage} [{ErrorType}]", error.Message, error.Type);
        Assert.Fail();
    }

Thanks,

@Xavina Xavina added the bug Something isn't working label Mar 24, 2025
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Mar 24, 2025
@github-actions github-actions bot changed the title Bug: Step04_AgentOrchestration - Step04_AgentOrchestration: ChatMessageContent error deserializing Intent .Net: Bug: Step04_AgentOrchestration - Step04_AgentOrchestration: ChatMessageContent error deserializing Intent Mar 24, 2025
@Xavina Xavina changed the title .Net: Bug: Step04_AgentOrchestration - Step04_AgentOrchestration: ChatMessageContent error deserializing Intent Bug: Step04_AgentOrchestration: ChatMessageContent error deserializing Intent Mar 24, 2025
github-merge-queue bot pushed a commit that referenced this issue Apr 9, 2025
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Enable sample execution for `GettingStartedWithProcesses` - `Step04`

Fixes: #11147

### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Something change in our support for parsing JSON schema that results in
failure of the static initialization and blocking sample execution.

Switch to using `Type` for `ResponseFormat`.

### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code samples
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants