应用程序(App)函数Toolset
Exposes Android AppFunctions to an agent as ADK BaseTools.
An app discovers and executes the functions it declares itself with no permission, which is the default here. Pass the toolset straight to an LlmAgent's toolsets:
val agent = LlmAgent(name = "notes", model = model, toolsets = listOf(AppFunctionsToolset(context)))AppFunctions needs Android 16, or Android 14 on a device shipping the AppFunctions extension library; a device without it contributes no tools rather than failing, so an agent can carry this toolset without gating on the version itself. A function is likewise absent for a short while after its app is installed or updated, until the platform has indexed it.
A function that answers with a screen to open rather than data is not offered, since the model cannot read a PendingIntent and nothing here can act on one.
An app may also declare guidance covering its functions as a whole -- how they work together, which to call first -- and that is added to the model's instructions unless injectAppMetadata turns it off.
ADK declares androidx.appfunctions as compileOnly, so an app using this toolset must add that dependency itself.
构造函数(Constructors)
函数
该功能会检测设备上的应用程序功能,并将这些功能分别作为独立的工具提供给用户使用。
将每个应用程序关于其整体功能的说明添加到模型的使用指南中。