Skip to content

.Net: Kernel function arguments cannot be of type Array<Enum> #5451

@EdenTanami

Description

@EdenTanami

Describe the bug
Kernel function with argument of type Enum[] throws on invocation.

I am writing a kernel function that finds toys with the following signature:
public string FindToy(Color[] colors) {...}
public enum Color { Blue, Red, Green }
Then I ask in the chat question to invoke my function.

  • This is the parameters schema sent to openAI sdk:
    {{"type":"object","required":["colors"],"properties":{"colors":{"type":"array","items":{"enum":["Blue","Red","Green"]}}}}}
  • This is the arguments in the model responses' ToolCalls:
    "{"colors":["Blue","Red"]}"
  • When invoking in this function SK throws this exception:
    Function failed. Error: Object of type 'System.String' cannot be converted to type 'SKCopilotToolkit.Sample.SampleMockScenario.Plugins.ToysPlugin+Color[]'.

To Reproduce
Steps to reproduce the behavior:

  1. Register the function with the following signature to the kernel:
    [KernelFunction("FindToy")] public string FindToy(Color[] colors)
  2. Ask the chat completion service for toys in some colors
  3. examine the errors in the logs

Expected behavior
The function will be called with array of Enum values [Blue, Red]

Platform

  • OS: Windows
  • IDE: Visual Studio,
  • Language: C#
  • Source: SK NuGet package version 1.5.0

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codecore pluginAnything related to core plugins

Type

No type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions