getEffectiveRetries returns the number of retries to use for the agent. If no retries are explicitly configured (retries == 0), returns the default to provide sensible retry behavior out of the box. This ensures that transient errors (e.g., Anthropic 529 overloaded) are retried even when no fallback
(a *agent.Agent)
| 134 | // Note: Users who explicitly want 0 retries can set retries: -1 in their config |
| 135 | // (though this is an edge case - most users want some retries for resilience). |
| 136 | func getEffectiveRetries(a *agent.Agent) int { |
| 137 | retries := a.FallbackRetries() |
| 138 | // -1 means "explicitly no retries" (workaround for Go's zero value) |
| 139 | if retries < 0 { |
| 140 | return 0 |
| 141 | } |
| 142 | // 0 means "use default" - always provide retries for transient error resilience |
| 143 | if retries == 0 { |
| 144 | return modelerrors.DefaultRetries |
| 145 | } |
| 146 | return retries |
| 147 | } |
| 148 | |
| 149 | // chainStartIndex returns the index in the model chain (primary at 0, |
| 150 | // fallbacks at 1+) at which to begin trying. Normally 0, but during an |