state property

State? get state

Implementation

State? get state {
  final fromWire = _raw.state?.custom;
  // Server-managed agents omit `state` on the wire; fall back to the chat's
  // locally tracked custom state (already typed) so `res.state == chat.state`.
  // The wire branch is cast/parsed via the optional schema.
  if (fromWire != null) return castOrParseState(fromWire, _stateSchema);
  return _fallbackState?.call();
}