-
Notifications
You must be signed in to change notification settings - Fork 865
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
The json schema definition at toolConfig.tools.10.toolSpec.inputSchema is invalid #3731
Comments
@cristiursachi Good morning. Thanks for opening the GitHub issue. Reproducible using below code as an example: using Amazon.BedrockRuntime;
using Microsoft.Extensions.AI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
namespace BedRockMEAITest
{
internal class Program
{
delegate string GetWeather();
static async Task Main(string[] args)
{
// Enable verbose logging
Amazon.AWSConfigs.LoggingConfig.LogResponses = Amazon.ResponseLoggingOption.Always;
Amazon.AWSConfigs.LoggingConfig.LogTo = Amazon.LoggingOptions.Console;
Amazon.AWSConfigs.AddTraceListener("Amazon", new System.Diagnostics.ConsoleTraceListener());
var runtime = new AmazonBedrockRuntimeClient();
IChatClient chatClient = runtime.AsChatClient("us.anthropic.claude-3-7-sonnet-20250219-v1:0");
GetWeather weatherDelegate = () => { return (new Random()).NextDouble() > 0.5 ? "It's sunny" : "It's raining"; };
AITool aiTool = AIFunctionFactory.Create(weatherDelegate);
ChatOptions chatOptions = new ChatOptions
{
Tools = new List<AITool> { aiTool }
};
await foreach (var response in chatClient.GetStreamingResponseAsync("Is this working?", chatOptions))
{
Console.Write(response.Text);
}
}
}
} It gives below error:
If we remove addition of Tools, then it works fine giving below output:
Even if we specify ...
GetWeather weatherDelegate = () => { return (new Random()).NextDouble() > 0.5 ? "It's sunny" : "It's raining"; };
AITool aiTool = AIFunctionFactory.Create(weatherDelegate,
new AIFunctionFactoryOptions()
{
Name = "WeatherAITool",
Description = "Weather AI Tool",
AdditionalProperties = new Dictionary<string, object>() { { "dummyproperty" , "dummyValue" } }
}
);
ChatOptions chatOptions = new ChatOptions() { Tools = new List<AITool>() };
chatOptions.Tools.Add(aiTool);
... While initializing ToolConfig here, the ValueKind = Object : "{
"title": "WeatherAITool",
"description": "Weather AI Tool",
"type": "object",
"properties": {}
}" Looks like an issue with Needs review with the team. Similar issues:
Possible Fix: (working) ...
Dictionary<string, Document> inputSchema = new()
{
["type"] = new Document("object"),
["required"] = new Document(required),
};
if (inputs.Type != DocumentType.Null) inputSchema["properties"] = inputs;
return new Tool()
{
ToolSpec = new ToolSpecification()
{
Name = f.Name,
Description = !string.IsNullOrEmpty(f.Description) ? f.Description : f.Name,
InputSchema = new()
{
Json = new(inputSchema)
},
},
};
}).ToList();
... @cristiursachi Could you please share how you are creating ...
AITool toolInLine = MyTools.GetAITestTool();
chatOptions.Tools.Add(toolInLine);
... Thanks, |
Sure, my code to create AITool: ` public static AITool GetAITestTool()
|
I tested your Possible Fix above. While I do not get the error anymore, the tool is not called (when it should). |
Describe the bug
I'm trying to use the new AWSSDK.Extensions.Bedrock.MEAI extensions but I get a server side error:
The json schema definition at toolConfig.tools.10.toolSpec.inputSchema is invalid. Fix the following errors and try again: $.properties: null found, object expected
This is thrown when I use an AITool in ChatOptions as following:
Regression Issue
Expected Behavior
I should get a valid response from Bedrock LLM and invoke the AITool if required. But despite if the prompt will require or not the call to AITool, I get the the exception which seems generated on serverSide.
Current Behavior
This is the full exception I get:
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.Extensions.Bedrock.MEAI - 4.0.0-preview.11
Targeted .NET Platform
.NET Core 3.1
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered: