You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The old implementation (MethodInvokingFunctionCallback) skips ToolContext when generating JSON schemas for method inputs, but the new implementation (JsonSchemaGenerator) does not.
public static String generateForMethodInput(Method method, SchemaOption... schemaOptions) {
ObjectNode schema = JsonParser.getObjectMapper().createObjectNode();
schema.put("$schema", SchemaVersion.DRAFT_2020_12.getIdentifier());
schema.put("type", "object");
ObjectNode properties = schema.putObject("properties");
List<String> required = new ArrayList<>();
for (int i = 0; i < method.getParameterCount(); i++) {
String parameterName = method.getParameters()[i].getName();
Type parameterType = method.getGenericParameterTypes()[i];
if (isMethodParameterRequired(method, i)) {
required.add(parameterName);
}
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType);
String parameterDescription = getMethodParameterDescription(method, i);
if (StringUtils.hasText(parameterDescription)) {
parameterNode.put("description", parameterDescription);
}
properties.set(parameterName, parameterNode);
}
var requiredArray = schema.putArray("required");
required.forEach(requiredArray::add);
processSchemaOptions(schemaOptions, schema);
return schema.toPrettyString();
}
Refer to the documentation (Spring AI ToolContext Documentation), which shows ToolContext is meant for passing user-provided or framework-managed context to tools, not as part of the input schema for the AI model. Including it might mislead users into thinking they need to provide it, potentially causing errors or confusion.
This change could lead to inconsistent behavior compared to previous versions, confuse users who expect ToolContext to be handled externally, or cause errors if users don't provide it when it's included in the schema.
The text was updated successfully, but these errors were encountered:
The old implementation (MethodInvokingFunctionCallback) skips ToolContext when generating JSON schemas for method inputs, but the new implementation (JsonSchemaGenerator) does not.
Old implementation:
New implementation:
Refer to the documentation (Spring AI ToolContext Documentation), which shows ToolContext is meant for passing user-provided or framework-managed context to tools, not as part of the input schema for the AI model. Including it might mislead users into thinking they need to provide it, potentially causing errors or confusion.
This change could lead to inconsistent behavior compared to previous versions, confuse users who expect ToolContext to be handled externally, or cause errors if users don't provide it when it's included in the schema.
The text was updated successfully, but these errors were encountered: