Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

[spring-ai] ToolConverter silently drops enum and items from tool parameter schemas

Offen Anfängerfreundlich
#1,609 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@hirematha arbeitet bereits daran.

Seit 05.10.2026.

  • #1617 von @caps-xia — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java, spring
Bereich
ai

Rechercherichtung

Der Verlust tritt in ToolConverter#convertSchemaToSpringAi auf, das von convertToSpringAiTools erreicht wird, wenn jedes ToolDefinition input schema erstellt wird; beginne damit, diese Methode und die genai Schema- und Spring AI schema-Typen zu lesen, zwischen denen sie abbildet. Reproduziere mit dem minimalen Beispiel aus dem Issue (eine enum-String-Eigenschaft plus eine Array-Eigenschaft mit items), dann mappe enum_ und items pro Eigenschaft und rekursiere in verschachtelte Eigenschaften. Fertig bedeutet, dass das ausgegebene inputSchema JSON enum und items für diese Parameter enthält, während die bestehenden ToolConverter-Tests weiterhin bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

needs review
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
  1. Define a BaseTool whose declaration() returns a FunctionDeclaration with
    parameters containing an enum property and an array-with-items property.
  2. Convert it via new ToolConverter().convertToSpringAiTools(...).
  3. Inspect getToolDefinition().inputSchema() — no enum, no items.
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 current main, convertSchemaToSpringAi still only emits type/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.

Vorherrschende Sprache
Java
Sterne
1.7k
Forks
431
Ø Merge
3 T. 2 Std.
Gemergte PRs (30 T.)
46

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus google/adk-java

Alle Issues in google/adk-java

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.