Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte Adaptée aux débutants
#62 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
android, kotlin
Domaine
backend

Piste de recherche

Commencez par agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt, en particulier setArrayValue et setStringList, et comparez leurs conversions avec les branches scalaires de setParameterValue. Reproduisez le problème avec des valeurs numériques dans un tableau JSON, par exemple [0.0, 1.0] ; le travail est terminé lorsque les éléments numériques du tableau provenant du LLM sont convertis sans ClassCastException et atteignent la fonction de l’application.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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).

Langage dominant
Kotlin
Étoiles
210
Forks
45
Merge moyen
12 h 24 min
PR mergées (30 j)
3

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de android/appfunctions

Toutes les issues de android/appfunctions

Issues similaires

Plus d'issues Kotlin

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.