copyWith method

AgentToolCallPart copyWith({
  1. String? summary,
  2. String? description,
  3. String? detail,
  4. List<AgentToolInput>? input,
  5. AgentToolCallStatus? status,
  6. String? output,
  7. Object? result,
  8. String? error,
  9. AgentApprovalDecision? decision,
  10. Duration? duration,
  11. bool clearSummary = false,
  12. bool clearDescription = false,
  13. bool clearDetail = false,
  14. bool clearOutput = false,
  15. bool clearResult = false,
  16. bool clearError = false,
  17. bool clearDecision = false,
  18. bool clearDuration = false,
})

Returns a copy with the given fields replaced.

The usual update moves status and fills in the result: call.copyWith(status: AgentToolCallStatus.running).

A null argument keeps the current value, so it cannot clear one. To retry a failed call, set the matching clear... flag, such as call.copyWith(status: AgentToolCallStatus.running, clearError: true). A clear... flag wins over its value.

Implementation

AgentToolCallPart copyWith({
  String? summary,
  String? description,
  String? detail,
  List<AgentToolInput>? input,
  AgentToolCallStatus? status,
  String? output,
  Object? result,
  String? error,
  AgentApprovalDecision? decision,
  Duration? duration,
  bool clearSummary = false,
  bool clearDescription = false,
  bool clearDetail = false,
  bool clearOutput = false,
  bool clearResult = false,
  bool clearError = false,
  bool clearDecision = false,
  bool clearDuration = false,
}) => AgentToolCallPart(
  id: id,
  name: name,
  summary: clearSummary ? null : summary ?? this.summary,
  description: clearDescription ? null : description ?? this.description,
  detail: clearDetail ? null : detail ?? this.detail,
  input: input ?? this.input,
  status: status ?? this.status,
  output: clearOutput ? null : output ?? this.output,
  result: clearResult ? null : result ?? this.result,
  error: clearError ? null : error ?? this.error,
  decision: clearDecision ? null : decision ?? this.decision,
  duration: clearDuration ? null : duration ?? this.duration,
);