apple: number schema with both minimum and maximum drops the minimum (DynamicGenerationSchema early return)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đá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
- 62/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ệ
- react-native, swift, typescript
- Lĩnh vực
- machine-learning, mobile
Hướng nghiên cứu
Lỗi nằm ở phần chuyển đổi schema số trong ios/AppleLLMImpl.swift (khoảng dòng 449–462), nơi nhánh maximum trả về trước khi kiểm tra minimum được thực thi. Hãy đọc hàm xung quanh, sau đó tái hiện lỗi bằng một schema số nguyên khai báo minimum 1 và maximum 90. Công việc hoàn thành khi cả hai giới hạn đều được áp dụng vào các hướng dẫn sinh nội dung, các nhánh giới hạn loại trừ được sửa theo cách tương tự, và có một bài kiểm thử bao phủ trường hợp kết hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
In @react-native-ai/apple 0.12.0, a JSON Schema number or integer that declares both minimum and maximum loses its minimum when converted to a DynamicGenerationSchema. The model can then generate values below the declared lower bound, e.g. 0 or a negative for a field declared minimum: 1, maximum: 90.
Where
ios/AppleLLMImpl.swift (v0.12.0), around lines 449–462:
if let maximum = schemaDict["maximum"] as? Double {
if type == "integer" {
return DynamicGenerationSchema(type: Int.self, guides: [GenerationGuide.maximum(Int(maximum))])
} else {
return DynamicGenerationSchema(type: Double.self, guides: [GenerationGuide.maximum(maximum)])
}
}
if let minimum = schemaDict["minimum"] as? Double { // never reached when "maximum" is present
...
}
The maximum branch returns early, so the minimum branch is only reached when there is no maximum. The exclusiveMaximum / exclusiveMinimum branches below have the same early-return shape.
Repro
A tool with this parameter schema (e.g. from Zod z.number().int().min(1).max(90)):
{ "type": "object", "properties": { "days": { "type": "integer", "minimum": 1, "maximum": 90 } }, "required": ["days"] }
- Expected: a generation guide constraining
daysto 1…90. - Actual: only
maximum(90)is applied, and the model can emitdays: 0or a negative.
Suggested fix
Collect all bound guides for the property and pass them together, instead of returning on the first one. For example:
var guides: [GenerationGuide<Int>] = []
if let min = schemaDict["minimum"] as? Double { guides.append(.minimum(Int(min))) }
if let max = schemaDict["maximum"] as? Double { guides.append(.maximum(Int(max))) }
// same for exclusive bounds (+1 / -1), and the Double variant
if !guides.isEmpty { return DynamicGenerationSchema(type: Int.self, guides: guides) }
Or use a single range guide when both bounds are present.
Impact / workaround
We now validate tool arguments ourselves before executing, so out-of-range values are rejected. That still wastes a model turn, though, and anyone relying on the schema alone gets invalid arguments.
Thanks for the library!
- Ngôn ngữ chính
- TypeScript
- Star
- 1.4k
- Fork
- 64
- Merge trung bình
- 11 giờ 24 phút
- Pull request đã merge (30 ngày)
- 91
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của callstackincubator/ai
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
callstackincubator/ai#366 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
callstackincubator/ai#365 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Blocked enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
callstackincubator/ai#364 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Blocked enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
callstackincubator/ai#363 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Blocked enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
callstackincubator/ai#362 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của callstackincubator/ai
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
cursor/community-plugins#583 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A model answer with prose after its fenced JSON is rejected as NOT_JSONCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởafk-ok importer size:S
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
enorm-labs/event-junkie#5404 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Wavvon/Wavvon-clients#493 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
answerLoops/answerLoops#679 ·
Maintainer thường phản hồi trong vòng 1 ngày