[Bug]: Testing agent fails on numeric array parameters from the LLM (ClassCastException: Double cannot be cast to String)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
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
- 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) - In Agent Demo, ask for something that makes the model fill the array (e.g. "a gradient from red to gold").
- 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),
standardflavor, 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from android/appfunctions
-
Difficulty 4/5 1-2 days Newbie friendliness 55/100
android/appfunctions#64 ·
-
[FR]: Testing agent should handle AppFunctionUriGrant results and pass returned images to the modelOpen
Difficulty 4/5 3-5 days Newbie friendliness 45/100
android/appfunctions#63 ·
-
Clarify production invocation, Android Auto support, and Android 16 fallback in AppFunctions docsOpen
Difficulty 4/5 3-5 days Newbie friendliness 52/100
android/appfunctions#51 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
android/appfunctions#50 · 1 comment ·
-
[Bug]:Openbug
Difficulty 4/5 3-5 days Newbie friendliness 20/100
android/appfunctions#49 ·
All issues in android/appfunctions
Similar issues
-
Feature
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug 🐞 Untriaged user issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
valkey-io/valkey-glide#7443 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pengchujin/aerial-tv#713 ·
Maintainers usually reply within 1 day
-
unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
thunderbird/thunderbird-android#11797 · 1 comment ·
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day