Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
backend

Research direction

Start with agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt, especially setArrayValue and setStringList, and compare their conversions with the scalar branches in setParameterValue. Reproduce with numeric JSON array values such as [0.0, 1.0]; done means numeric array items from the LLM convert without a ClassCastException and reach the app function.

Written by the indexing model from the issue text.

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

Dominant language
Kotlin
Stars
209
Forks
43
Avg merge
12h 24m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/appfunctions

All issues in android/appfunctions

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.