Skip to content

Refactor built-in AppFunctions to internal tools and make them actually working - #46

Open
ksemenova wants to merge 3 commits into
mainfrom
make_af_internal_tools
Open

Refactor built-in AppFunctions to internal tools and make them actually working#46
ksemenova wants to merge 3 commits into
mainfrom
make_af_internal_tools

Conversation

@ksemenova

@ksemenova ksemenova commented Jul 31, 2026

Copy link
Copy Markdown

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

3946

After

3945

Key Changes

  1. Internal Tools Refactoring:
    • Moved geocodeAddress, getCurrentLocation, and generateImage from BaseBuiltInAppFunctionService to a new AgentInternalTools class.
    • Intercepted tool execution in AgentOrchestrator to execute in-process and simplified the flow to return Kotlin Result<String>.
    • Deleted BaseBuiltInAppFunctionService.kt and removed its service declaration from AndroidManifest.xml.
  2. Robust Argument Conversion:
    • Fixed ClassCastException where the LLM passes a raw String URI to a custom object or array parameter (e.g., ChatApp's Attachment).
    • Introduced automatic fallback wrapping of String values into the target object's primary Uri or String property inside ConvertInputToAppFunctionDataUseCase.toAppFunctionData().
    • Added unit tests covering both singular and list-based auto-wrapping scenarios.

…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.
@ksemenova
ksemenova requested a review from a team as a code owner July 31, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant