Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,7 @@ public static String generateForMethodInput(Method method, SchemaOption... schem
for (int i = 0; i < method.getParameterCount(); i++) {
String parameterName = method.getParameters()[i].getName();
Type parameterType = method.getGenericParameterTypes()[i];
if (parameterType instanceof Class<?> parameterClass
&& ClassUtils.isAssignable(parameterClass, ToolContext.class)) {
// A ToolContext method parameter is not included in the JSON Schema
// generation.
// It's a special type used by Spring AI to pass contextual data to tools
// outside the model interaction flow.
if (shouldIgnoredInJsonSchema(parameterType)) {
continue;
}
if (isMethodParameterRequired(method, i)) {
Expand All @@ -155,6 +150,15 @@ public static String generateForMethodInput(Method method, SchemaOption... schem
return schema.toPrettyString();
}

private static boolean shouldIgnoredInJsonSchema(final Type parameterType) {
// A ToolContext method parameter is not included in the JSON Schema
// generation.
// It's a special type used by Spring AI to pass contextual data to tools
// outside the model interaction flow.
return parameterType instanceof Class<?> parameterClass
&& ClassUtils.isAssignable(parameterClass, ToolContext.class);
}

/**
* Generate a JSON Schema for a class type.
*/
Expand Down