throwIfAborted method

void throwIfAborted()

Raises CancellationTokenException when aborted, at a cancellation point in the agent's tool loop.

Both conditions aborted folds are enforced here: an explicitly cancelled token throws through the token's own throwIfCancelled, and an expired Deadline throws the same exception type without cancelling the shared token — the deadline is advisory, so expiry must not flip the token other consumers read.

Implementation

void throwIfAborted() {
  _context.cancellation.throwIfCancelled();
  final deadline = _context.deadline;
  if (deadline != null && deadline.isExpired) {
    throw const CancellationTokenException('deadline expired');
  }
}