update method

void update({
  1. required String id,
  2. required AgentToolCallStatus status,
  3. AgentApprovalDecision? recorded,
})

Records the call's latest id and status.

A new request re-arms the guard: a different id that awaits approval, or a return to AgentToolCallStatus.awaitingApproval. So does the host clearing a recorded decision it had set while the call still awaits approval, as it does when it could not act on the decision.

Implementation

void update({
  required String id,
  required AgentToolCallStatus status,
  AgentApprovalDecision? recorded,
}) {
  final awaiting = status == AgentToolCallStatus.awaitingApproval;
  final newRequest = id != _id && awaiting;
  final returned = !_status.needsDecision && awaiting;
  final cleared = _recorded != null && recorded == null && awaiting;
  _id = id;
  _status = status;
  _recorded = recorded;
  if (newRequest || returned || cleared) _decision = null;
  if (awaiting && recorded != null) _decision = recorded;
}