Refactor built-in AppFunctions to internal tools and make them actually working - #46
Open
ksemenova wants to merge 3 commits into
Open
Refactor built-in AppFunctions to internal tools and make them actually working#46ksemenova wants to merge 3 commits into
ksemenova wants to merge 3 commits into
Conversation
…ent conversion fallback - Moved `geocodeAddress`, `getCurrentLocation`, and `generateImage` to `AgentInternalTools`. - Updated `AgentOrchestrator` to intercept and execute internal tools in-process, returning `Result<String>`. - Removed `BuiltInAppFunctionService` and cleaned up `AndroidManifest.xml`. - Resolved argument mapping `ClassCastException` by adding a fallback to wrap string inputs (e.g., URIs) into custom serializable object/array parameters in `ConvertInputToAppFunctionDataUseCase`. - Refactored argument conversion to use a unified `toAppFunctionData` helper.
mingweiliao
reviewed
Jul 31, 2026
| } | ||
|
|
||
| private fun convertObject( | ||
| private fun toAppFunctionData( |
Contributor
There was a problem hiding this comment.
I'm not quite sure why this is needed. The Uri handling is done separately already, what was the issue this is trying to resolve?
There was a problem hiding this comment.
and also why can't those internal tools to be implemented as app functions? :)
I thought they were "actually working" before the change...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors 3 built-in AppFunctions to run as internal agent tools, cleans up unused service declarations, and fixes an argument conversion failure (
ClassCastException) during integration with external apps.Before
After
Key Changes
geocodeAddress,getCurrentLocation, andgenerateImagefromBaseBuiltInAppFunctionServiceto a newAgentInternalToolsclass.AgentOrchestratorto execute in-process and simplified the flow to return KotlinResult<String>.BaseBuiltInAppFunctionService.ktand removed its service declaration fromAndroidManifest.xml.ClassCastExceptionwhere the LLM passes a rawStringURI to a custom object or array parameter (e.g., ChatApp'sAttachment).ConvertInputToAppFunctionDataUseCase.toAppFunctionData().