Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#1,609 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hirematha đang làm issue này rồi.

Từ ngày 5/10/2026.

  • #1617 của @caps-xia — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, spring
Lĩnh vực
ai

Hướng nghiên cứu

Sự mất mát xảy ra trong ToolConverter#convertSchemaToSpringAi, được gọi từ convertToSpringAiTools khi mỗi input schema của ToolDefinition được xây dựng; hãy bắt đầu bằng việc đọc phương thức đó và các kiểu genai Schema và Spring AI schema mà nó ánh xạ giữa chúng. Tái hiện với ví dụ tối thiểu của issue (một thuộc tính string enum cộng với một thuộc tính array có items), sau đó ánh xạ enum_ và items cho mỗi thuộc tính, đệ quy vào các thuộc tính lồng nhau. Hoàn thành nghĩa là inputSchema JSON được phát ra chứa enum và items cho các tham số đó trong khi các bài kiểm tra ToolConverter hiện có vẫn vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
1.7k
Fork
431
Merge trung bình
3 ngày 2 giờ
Pull request đã merge (30 ngày)
46

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/adk-java

Tất cả issue của google/adk-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.