Skip to content

.Net Bug: OpenApiSpec plugin does not work if RetainArgumentTypes = True #13187

@zhzho1995

Description

@zhzho1995

.Net Bug: OpenApiSpec plugin does not work if RetainArgumentTypes = True.

I’ve run into a bit of a dilemma.

I have an agent based on SK. In this SK, I have some APIs imported into SK as plugins via OpenApiSpec, and I also have some MCP servers imported as SK plugins. Some of these MCP server tools have inputs that are objects or enums.

If I don’t set RetainArgumentTypes as true, the OpenApiSpec plugins work well, but for MCP server tools that accept objects as input, the MCP server side will throw errors like:

JSON value could not be converted to ...

Image

On the other hand, if I do set RetainArgumentTypes = true, MCP server tools work correctly, but OpenApiSpec plugins fail. For example, when calling REST APIs (e.g., POST http requests), the payload’s value is no longer a string but a JsonElement with ValueKind = String.

Image This causes downstream execution to fail because SK’s internal code expects the type to be string. Image

if (!arguments.TryGetValue(RestApiOperation.PayloadArgumentName, out object? argument) || argument is not string payload)

Currently, I work around this by adding a FunctionInvocationFilters that checks whether the argument comes from an MCP tool or an OpenAPI tool and manually adjusts the argument type.

I believe this should ideally be fixed inside the SK package itself.

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions