refuse static method

FutureOr<Object?> refuse(
  1. AgentToolContext context,
  2. String name,
  3. Map<String, Object?> arguments,
  4. Object? refusal(),
)

Refuses a call to name with whatever refusal throws, recording the refusal as a call — for a presentation that must turn a call away without running any tool, and must not let it vanish from the trail.

Implementation

static FutureOr<Object?> refuse(
  AgentToolContext context,
  String name,
  Map<String, Object?> arguments,
  Object? Function() refusal,
) {
  // Bounded: the name is the caller's string, and the trail records
  // identifiers, not whatever a caller chose to send in their place.
  final recorded = name.length <= 64 ? name : '${name.substring(0, 64)}…';
  return AgentAuditRecording.run(recorded, context, arguments, refusal);
}