MCPcopy Index your code
hub / github.com/docker/docker-agent / chainStartIndex

Method chainStartIndex

pkg/runtime/fallback.go:153–165  ·  view source on GitHub ↗

chainStartIndex returns the index in the model chain (primary at 0, fallbacks at 1+) at which to begin trying. Normally 0, but during an active cooldown it returns the position of the pinned fallback so the primary is skipped.

(a *agent.Agent, fallbackCount int)

Source from the content-addressed store, hash-verified

151// active cooldown it returns the position of the pinned fallback so the
152// primary is skipped.
153func (e *fallbackExecutor) chainStartIndex(a *agent.Agent, fallbackCount int) int {
154 state := e.cooldowns.Get(a.Name())
155 if state == nil || fallbackCount <= state.fallbackIndex {
156 return 0
157 }
158 slog.Debug("Skipping primary due to cooldown",
159 "agent", a.Name(),
160 "start_from_fallback_index", state.fallbackIndex,
161 "cooldown_until", state.until.Format(time.RFC3339))
162 // +1 to convert from a.FallbackModels() index to modelChain index
163 // (modelChain[0] is the primary, modelChain[1] is the first fallback).
164 return state.fallbackIndex + 1
165}
166
167// recordSuccess updates the per-agent cooldown state after a successful
168// model attempt. If a fallback rescued a non-retryable primary failure,

Callers 1

executeMethod · 0.95

Calls 3

DebugMethod · 0.80
GetMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected