Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug]: Testing agent fails on numeric array parameters from the LLM (ClassCastException: Double cannot be cast to String)

Abierto Apto para principiantes
#62 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin
Área
backend

Línea de trabajo

Empieza por agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt, especialmente por setArrayValue y setStringList, y compara sus conversiones con las ramas escalares de setParameterValue. Reproduce el problema con valores numéricos de un array JSON como [0.0, 1.0]; la tarea estará completada cuando los elementos numéricos del array procedentes del LLM se conviertan sin ClassCastException y lleguen a la función de la aplicación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

When the LLM calls a function whose parameters contain a numeric array (here a DoubleArray inside an @AppFunctionSerializable), the Testing Agent fails before the call reaches the app:

Failed to convert arguments for com.example.app.DesignAppFunctionService#setLayerProperties
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
Cause

ConvertInputToAppFunctionDataUseCase.setArrayValue assumes every numeric array item is a String:

// agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt
val intArray = values.map { (it as String).toInt() }.toIntArray()          // line 158
val longArray = values.map { (it as String).toLong() }.toLongArray()       // line 162
val doubleArray = values.map { (it as String).toDouble() }.toDoubleArray() // line 170
val floatArray = values.map { (it as String).toFloat() }.toFloatArray()    // line 174

That holds for values typed into the Debug screen, but the Gemini provider passes real JSON numbers. The scalar branches in setParameterValue already accept both (is Number / is String); the array branches don't.

Steps to reproduce
  1. Expose a function taking a serializable with a numeric array, e.g.
    @AppFunctionSerializable(isDescribedByKDoc = true)
    class GradientSpec(val colors: List<String>, val stops: DoubleArray? = null)
    
  2. In Agent Demo, ask for something that makes the model fill the array (e.g. "a gradient from red to gold").
  3. The model sends "stops": [0.0, 1.0] and the conversion throws.
Suggested fix

Accept both forms, as the scalar branches do:

private fun Any.asDouble(): Double = when (this) {
    is Number -> toDouble()
    else -> toString().toDouble()
}
// ...
val doubleArray = values.map { it.asDouble() }.toDoubleArray()

(and the same for Int, Long and Float). setStringList (line 155) also casts with it as String; it.toString() would be safer there.

Environment
  • Testing Agent at a3a2a89 (main, Oct 23, 2026), standard flavor, debug
  • androidx.appfunctions 1.0.0-beta01 (both the agent and the app)
  • Emulator, Android 17 (API 37), model gemini-3.5-flash

Related: #50 (number conversion in cmd app_function, scalar parameters).

Lenguaje dominante
Kotlin
Estrellas
210
Forks
45
Merge medio
12 h 24 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de android/appfunctions

Todos los issues de android/appfunctions

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.