apple: number schema with both minimum and maximum drops the minimum (DynamicGenerationSchema early return)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react-native, swift, typescript
- Área
- machine-learning, mobile
Línea de trabajo
El error está en la conversión del esquema numérico en ios/AppleLLMImpl.swift (alrededor de las líneas 449–462), donde la rama de maximum retorna antes de que se ejecute la comprobación de minimum. Lee la función circundante y luego reproduce el problema con un esquema entero que declare minimum 1 y maximum 90. Está terminado cuando ambos límites se aplican a las guías de generación, las ramas de límites exclusivos se corrigen de la misma forma y una prueba cubre el caso combinado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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!
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.4k
- Forks
- 64
- Merge medio
- 11 h 24 min
- PR fusionados (30 d)
- 91
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de callstackincubator/ai
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
callstackincubator/ai#366 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
callstackincubator/ai#365 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Blocked enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
callstackincubator/ai#364 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Blocked enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
callstackincubator/ai#363 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Blocked enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
callstackincubator/ai#362 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de callstackincubator/ai
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
cursor/community-plugins#583 ·
Los mantenedores suelen responder en 1 día
-
afk-ok importer size:S
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
enorm-labs/event-junkie#5404 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Wavvon/Wavvon-clients#493 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
answerLoops/answerLoops#679 ·
Los mantenedores suelen responder en 1 día