Class PendingAbortRegistry
PENDING detached turn's snapshot id to the live AtomicBoolean abort signal handed to that turn's AgentFnContext.
This is the only case where an external caller can know a turn's snapshot id WHILE the turn is
still running: DetachController.detach(...) writes the pending snapshot and returns its
id immediately, before the background work finishes. Foreground turns have no resolvable id until
after they return, so there is no reachable window in which to abort them externally — the
registry intentionally only covers detached turns.
DetachController.detach(com.google.genkit.ai.agent.SessionRunner<S>, com.google.genkit.ai.agent.SessionStore<S>, com.google.genkit.ai.agent.SessionStoreOptions, com.google.genkit.ai.agent.internal.StreamEmitter<S>, java.util.concurrent.atomic.AtomicBoolean, com.google.genkit.ai.agent.internal.DetachController.DetachedTurn<S>) registers the signal for a snapshot id when the background
turn starts, and removes it in a finally block when the turn finishes (success, failure,
or abort) so entries never leak. Agent.abort(String) looks up the signal and flips it (in
addition to the existing snapshot-store status mutation, which remains the source of truth for
anything that reads the snapshot after the fact, e.g. a poller that only checks status).
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidregister(String snapshotId, AtomicBoolean signal) Registerssignalas the abort flag for the pending detached turn identified bysnapshotId.static booleanFlips the abort signal registered forsnapshotIdtotrue, if one is currently registered (i.e. the turn is a still-running detached turn).static voidunregister(String snapshotId) Removes the registration forsnapshotId, if present.
-
Method Details
-
register
Registerssignalas the abort flag for the pending detached turn identified bysnapshotId.- Parameters:
snapshotId- the pending snapshot idsignal- the abort signal handed to that turn'sAgentFnContext
-
unregister
Removes the registration forsnapshotId, if present. Safe to call more than once.- Parameters:
snapshotId- the pending snapshot id
-
signal
Flips the abort signal registered forsnapshotIdtotrue, if one is currently registered (i.e. the turn is a still-running detached turn).- Parameters:
snapshotId- the snapshot id to signal- Returns:
trueif a signal was found and flipped;falseif no turn is currently registered under that id (already finished, foreground, or unknown)
-