agentic_tools library
Tool and function-calling layer of the agentic framework.
A tool is a capability an agent can invoke. This package defines what a tool is, how a catalogue of them is kept, how a subset is handed to an agent, and what happens between the model asking for a call and the tool's code running: argument repair, schema validation, human approval, time budgets, cancellation, tracing and events.
import 'package:agentic_core/agentic_core.dart';
import 'package:agentic_tools/agentic_tools.dart';
final registry = ToolRegistry()
..register(FunctionTool.text(
name: 'now',
description: 'Returns the current time in ISO-8601 UTC.',
handler: (i) async => i.context.clock.now().toIso8601String(),
));
final executor = ToolExecutor(tools: registry.all);
final messages = await executor.executeAllAsMessages(
response.toolCalls,
context: context,
);
Pure Dart: platform tools that need Flutter — camera, GPS, contacts — live in their own packages and depend on this one, so a server or CLI can use the tool system without pulling in a UI framework.
Classes
- DelegatingTool
- Wraps another Tool, delegating everything by default.
- FunctionTool
- A Tool backed by a closure.
- RenamedTool
- Presents a tool under a different name.
- Tool
- A capability an agent can invoke.
- ToolApprovalRequest
- A pending human-in-the-loop decision.
- ToolApprovalRequested
- A tool call is waiting for a human decision.
- ToolCallCompleted
- A tool finished, successfully or not.
- ToolCallStarted
- A tool is about to run.
- ToolEvent
- Base for every tool lifecycle event.
- ToolExample
- A worked example of calling a tool.
- ToolExecutor
- Executes tool calls on behalf of an agent.
- ToolFunction
- Marks a function or method as a tool.
- ToolInvocation
- One request to run a tool.
- ToolParam
- Describes one parameter of a ToolFunction to the model.
- ToolRegistry
- The application's catalogue of tools.
- ToolResult
- What a tool produced.
- ToolSet
- An immutable selection of tools from a ToolRegistry.
- ToolSpec
- What a tool is called, what it does and what it accepts.
Enums
- ToolFailureKind
- Why a tool call failed.
- UntrustedContentPolicy
- What a ToolExecutor does with a tool that changes state, once the run has read untrusted content.
Constants
- kUntrustedContentClose → const String
- The marker that closes an untrusted tool result in the model's view.
Typedefs
-
ToolApprovalHandler
= Future<
bool> Function(ToolApprovalRequest request) - Asks a human whether a tool may run.
-
ToolHandler
= FutureOr<
ToolResult> Function(ToolInvocation invocation) - The body of a FunctionTool.