Class AbortAwareMutator

java.lang.Object
com.google.genkit.ai.agent.internal.AbortAwareMutator

public final class AbortAwareMutator extends Object
Wraps a SnapshotMutator so that it returns null (no-op) when the current row is already SnapshotStatus.ABORTED, preventing a completed or failed write from clobbering a concurrent abort.

Usage: pass AbortAwareMutator.wrap(inner) to SessionStore.saveSnapshot(...) instead of the bare inner mutator.

  • Method Details

    • wrap

      public static <S> SnapshotMutator<S> wrap(SnapshotMutator<S> inner)
      Wraps inner so that it returns null when the existing snapshot has status SnapshotStatus.ABORTED; otherwise delegates to inner.
      Type Parameters:
      S - the type of custom session state
      Parameters:
      inner - the underlying mutator to wrap
      Returns:
      a new mutator that is abort-aware