Repository navigation
Description
Describe the Bug
ToolConverter#convertSchemaToSpringAi (used by convertToSpringAiTools) maps only
type, properties, description and required when converting a genai Schema
to a Spring AI ToolDefinition input schema. enum and items are silently
dropped.
Impact: any ADK tool whose parameters use enum-constrained strings or typed arrays —
including the mainstream path of annotated FunctionTool methods (enum Java fields,
List<String> parameters) — ends up with a degraded schema sent to the model:
enum parameters become free-form strings (models then send invalid values), and array
parameters lose their element type.
Steps to Reproduce
- Define a
BaseToolwhosedeclaration()returns aFunctionDeclarationwith
parameterscontaining an enum property and an array-with-items property. - Convert it via
new ToolConverter().convertToSpringAiTools(...). - Inspect
getToolDefinition().inputSchema()— noenum, noitems.
Expected Behavior
enum, items (and ideally format, nullable, minItems/maxItems) survive the
conversion, so the model receives the same parameter constraints the ADK tool declared.
Observed Behavior
Identical output on 1.9.0 and 1.11.0 (latest):
declared: color = string + enum ["red","green"], tags = array of string (items)
converted inputSchema:
{"description":"参数","type":"object","properties":{"color":{"description":"颜色","type":"string"},"tags":{"description":"标签","type":"array"}},"required":["color"]}
^ no "enum" ^ no "items"
Environment Details
- ADK Library Version: verified on 1.9.0 and 1.11.0 with identical output;
on currentmain,convertSchemaToSpringAistill only emitstype/properties - OS: macOS (logic bug, OS-independent)
- TS Version: N/A (Java)
Model Information
Model-independent — the loss happens in tool-definition conversion before any model
call. Observed with GLM via an OpenAI-compatible gateway.
Regression
N/A.
Additional Context
We maintain a patched bridge for this reason (among others): we bypass the wrapped
conversion and restore the original callbacks per tool name so the raw schema reaches
the model. A minimal fix is to map enum_ and items in convertSchemaToSpringAi;
serializing the genai Schema to JSON directly would also work and would future-proof
against further field drift.
Minimal Reproduction Code
Schema color = Schema.builder().type("string")
.description("颜色").enum_(List.of("red", "green")).build();
Schema tags = Schema.builder().type("array")
.description("标签").items(Schema.builder().type("string").build()).build();
Schema params = Schema.builder().type("object")
.properties(Map.of("color", color, "tags", tags))
.required(List.of("color"))
.build();
BaseTool tool = new BaseTool("probeTool", "probe") {
@Override public Optional<FunctionDeclaration> declaration() {
return Optional.of(FunctionDeclaration.builder()
.name("probeTool").description("probe").parameters(params).build());
}
@Override public Single<Map<String, Object>> runAsync(Map<String, Object> args, ToolContext ctx) {
return Single.just(Map.of());
}
};
String schema = new ToolConverter()
.convertToSpringAiTools(Map.of("probeTool", tool))
.get(0).getToolDefinition().inputSchema();
// schema contains no "enum" and no "items"How often has this issue occurred?
Always (100%) — every enum/array tool parameter.
Activity
caps-xia commentedon Oct 5, 2026
Thanks for triaging, @hirematha!
I also hit this in production — my current workaround restores the original tool callbacks so the unconverted schema reaches the model, so I have good reproduction coverage for the failure mode as well.
Happy to submit a PR unless one is already in progress. On the shape of the fix in
convertSchemaToSpringAi, I see two options:Minimal fix — additionally map
enumanditems, recursing into nested schemas so arrays of objects and nested enums survive the conversion too.Broader fix — serialize the original schema instead of rebuilding it field-by-field, so no keyword gets silently dropped in the future. This class of bug is hard to catch precisely because the drop is silent.
For a first PR I'd lean toward option 1 (small and easy to review), with option 2 as a possible follow-up if you agree it's worth it. Any preference before I open the PR?
fix(spring-ai): preserve enum and items in tool schema conversion
hirematha commentedon Oct 6, 2026
Hi @caps-xia, Thank you for reporting this issue and we appreciate you putting together a PR to fix it. I have successfully reproduced the issue you described. Both the issue and associated PR are now under review by the team. We will keep you updated and let you know if we need any additional information. Thank you.
fix(spring-ai): preserve enum and items in tool schema conversion
fix(spring-ai): preserve enum and items in tool schema conversion