FallbackStreamFunction class final
A StreamFunction over an ordered ChainEntry list with omp's rate-limit policy: rotate keys for free, retry the entry with capped exponential backoff, then fail over to the next entry — every step announced through onNotice.
One instance is stateful and long-lived (a session): entry cooldowns and
the activeIndex persist across calls, and a later call starts at the
first entry not in cooldown (omp's cooldown-expiry revert policy — the
primary model is retried once its cooldown lapses).
Constructors
-
FallbackStreamFunction({required List<
ChainEntry> entries, ModelRolesRetryPolicy policy = const ModelRolesRetryPolicy(), void onNotice(FallbackNotice notice)?, DateTime now()?, double jitterFraction()?, Future<bool> sleeper(Duration delay, CancelToken? cancelToken)?, QueueDeathClassifier? queueClassifier, ProviderQueueState? queueState}) -
Creates the wrapper.
entriesmust be non-empty.jitterFractionandsleeperare injectable for deterministic tests.
Properties
- activeIndex → int
-
The chain entry the last call started on (display state for
/model).no setter - currentModel → Model
-
The model currently considered primary for this chain (first entry not
in cooldown).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- length → int
-
The chain entry count.
no setter
- onNotice → void Function(FallbackNotice notice)?
-
Receives a FallbackNotice before every retry/rotation/failover.
final
- policy → ModelRolesRetryPolicy
-
Retry/fallback knobs.
final
- queueClassifier → QueueDeathClassifier?
-
The queue death classifier (issue #418); null in roles mode.
final
- queueState → ProviderQueueState?
-
The queue's sticky cursor + per-entry health; null in roles mode.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Model model, Context context, {CancelToken? cancelToken}) → AssistantMessageEventStream -
The StreamFunction entry point. The passed
modelis ignored — the chain position decides which model is called (the loop passes its configured model; the resolver keepsAgentState.modelin sync). -
cooldownRemaining(
int index) → Duration? -
Remaining cooldown of entry
index, or null when not cooling down. -
isInCooldown(
int index) → bool -
Whether chain entry
indexis cooling down right now. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited