AgentTool

abstract class AgentTool


Base class for tools that the Agent can invoke automatically.

All tools used with Agent must originate from Android AppFunctions (either registered via Agent.Builder.enableAppFunctions / Agent.Builder.addAppFunctionIds or discovered via AppFunctionAgentTools.discover).

Developers can subclass AgentTool using AgentTool (delegate, ...) to wrap an existing AppFunction tool (for example, to add human-in-the-loop confirmation before delegating to delegate.execute(args)).

Summary

Public constructors

AgentTool(delegate: AgentTool, name: String, description: String)

Constructs a decorating AgentTool that wraps an underlying AppFunction tool (for example, to add human-in-the-loop confirmation before calling delegate.execute(args)).

Public functions

abstract suspend Map<String, Any?>
execute(args: Map<String, Any>)

Executes the tool logic with the arguments supplied by the model.

Public properties

AgentTool?

The underlying AgentTool wrapped by this decorator, or null if this is a root AppFunction tool.

String

Human-readable summary of what the tool does.

String

The unique identifier of the tool.

Public constructors

AgentTool

AgentTool(
    delegate: AgentTool,
    name: String = delegate.name,
    description: String = delegate.description
)

Constructs a decorating AgentTool that wraps an underlying AppFunction tool (for example, to add human-in-the-loop confirmation before calling delegate.execute(args)).

Parameters
delegate: AgentTool

The underlying AgentTool to wrap. Must be an AppFunction tool discovered via AppFunctionAgentTools.discover (or another decorator wrapping one).

name: String = delegate.name

Optional override for the tool's name; defaults to delegate.name.

description: String = delegate.description

Optional override for the tool's description; defaults to delegate.description.

Throws
IllegalArgumentException

if delegate does not wrap an AppFunction tool.

Public functions

execute

abstract suspend fun execute(args: Map<String, Any>): Map<String, Any?>

Executes the tool logic with the arguments supplied by the model.

Optional schema arguments that evaluate to null are omitted from args.

Parameters
args: Map<String, Any>

Map of argument names to non-null argument values.

Returns
Map<String, Any?>

Execution results to be returned to the model.

Public properties

delegate

val delegate: AgentTool?

The underlying AgentTool wrapped by this decorator, or null if this is a root AppFunction tool.

description

val description: String

Human-readable summary of what the tool does.

name

val name: String

The unique identifier of the tool.