Give agents your app's own diagnostics and actions
Expose focused Flutter app data and operations so agents can answer questions the built-in tools cannot.
Custom tools let an agent ask your Dart app code for a precise answer, such as the current user or an app-specific state snapshot. Expose small, structured results and only the development actions your workflow needs.
final registration = await Ansight.instance.registerTool(
const AnsightToolDefinition(
id: 'app.current_user',
name: 'Current user',
category: 'app',
policy: AnsightToolPolicy.read,
),
(arguments, context) async => const AnsightToolResult.success(
result: <String, Object?>{'signedIn': true},
),
);
await registration.unregister();
Use stable ids, narrow structured results, an explicit read, write, or
critical policy, and the least-permissive tool guard. Reserve critical for
destructive, secret-bearing, or arbitrary code-invoking operations.
Native tool entries report dynamic runtime availability and remediation through the shared catalog. Dart-backed custom tools are advertised as available while registered; when one becomes unusable, unregister it or return a stable failure errorCode from the handler. The Dart registration API does not currently expose a pre-invocation availability callback.