[spring-ai] ToolConverter silently drops enum and items from tool parameter schemas
維護者通常 1 天內回覆
評估
研究方向
丟棄發生在 ToolConverter#convertSchemaToSpringAi 中,當每個 ToolDefinition input schema 被建構時,從 convertToSpringAiTools 到達;首先閱讀該方法以及它在其間映射的 genai Schema 和 Spring AI schema 類型。用 issue 的最小範例(一個 enum 字串屬性加上一個帶 items 的陣列屬性)重現,然後按屬性映射 enum_ 和 items,遞迴進入巢狀屬性。完成意味著發出的 inputSchema JSON 包含這些參數的 enum 和 items,同時現有的 ToolConverter 測試仍然通過。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Java
- 星號
- 1.8k
- 分支
- 440
- 平均合併
- 4 天 17 小時
- 30 天內合併 PR
- 87
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/adk-java 的其他 Issue
-
InMemorySessionService.appendEvent recreates a deleted session可能已有人在做 @hirematha 於 1 天前認領。 未關閉needs review
難度 2/5 1-3 小時 新手友好度 84/100
google/adk-java#1697 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Runner drops callbackContextData written in onUserMessageCallback when it resumes an invocation可能已有人在做 @hirematha 於 1 天前認領。 未關閉needs review
難度 2/5 1-3 小時 新手友好度 78/100
google/adk-java#1695 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
GeminiUtil placeholder user turn ("Continue output. DO NOT look at this line ...") is flagged by prompt injection filters可能已有人在做 @hemasekhar-p 於 19 天前認領。 未關閉needs review
難度 2/5 1-3 小時 新手友好度 76/100
google/adk-java#1628 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[spring-ai] Streaming responses ending with CJK punctuation (。!?) are misclassified as partial and never persisted to the session可能已有人在做 @hirematha 於 22 天前認領。 未關閉needs review
難度 2/5 1-3 小時 新手友好度 84/100
google/adk-java#1608 · 3 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
McpToolset hangs silently for ~5 minutes per retry (3 retries) when stdio command is an npm shim ("npx") on Windows可能已有人在做 @hemasekhar-p 於 5 天前認領。 未關閉needs review
google/adk-java#1686 · 4 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
相似的 Issue
-
agent:working bug follow-up lane:auto
難度 2/5 1-3 小時 新手友好度 72/100
Sanne/incus-spawn#1765 · 2 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
checkstyle/checkstyle#22260 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
strimzi/strimzi-kafka-operator#13328 · 1 則留言 · 3 個 reaction ·
維護者通常 1 天內回覆