Documentation
¶
Overview ¶
Package codeagent provides intelligent retry and fallback strategies tailored to code agent workloads. It distinguishes rate-limit errors, context window overflows, and tool-call failures from generic errors, applying appropriate retry or model-fallback behavior for each.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeAgentRetry ¶
type CodeAgentRetry struct {
// contains filtered or unexported fields
}
CodeAgentRetry provides intelligent retry and fallback strategies specifically for code agent workloads. Unlike generic retry, this understands code-specific failures and adapts accordingly.
func NewCodeAgentRetry ¶
func NewCodeAgentRetry(opts ...Option) *CodeAgentRetry
NewCodeAgentRetry creates a retry system with code-agent-specific strategies. Default strategies do not pin fallback model IDs; configure fallbacks explicitly via WithFallback (or override a whole strategy via WithStrategy) so the catalog remains the single source of truth for model names.
func (*CodeAgentRetry) DecideRetry ¶
func (cr *CodeAgentRetry) DecideRetry(ctx context.Context, err error, provider, model string) *RetryDecision
DecideRetry determines how to handle a failure.
func (*CodeAgentRetry) Stats ¶
func (cr *CodeAgentRetry) Stats() map[string]interface{}
Stats returns retry statistics.
type Option ¶
type Option func(*CodeAgentRetry)
Option configures a CodeAgentRetry.
func WithFallback ¶
WithFallback configures a fallback model+provider for a given error type (e.g. "context_length", "budget_exceeded"). Model and provider names should be resolved from the catalog by the caller — no defaults are baked in.
func WithStrategy ¶
func WithStrategy(errorType string, strategy RetryStrategy) Option
WithStrategy overrides the retry strategy for a given error type.
type RetryDecision ¶
type RetryDecision struct {
ShouldRetry bool
Delay time.Duration
Reason string
FallbackModel string
FallbackProvider string
}
RetryDecision describes what to do after a failure.
type RetryRecord ¶
type RetryRecord struct {
Timestamp time.Time
Provider string
Model string
ErrorType string
ErrorMessage string
RetryCount int
Recovered bool
FallbackUsed bool
}
RetryRecord captures a retry attempt for learning.
type RetryStrategy ¶
type RetryStrategy struct {
Name string
MaxRetries int
BaseDelay time.Duration
MaxDelay time.Duration
Backoff float64
FallbackModel string // switch to this model on failure
FallbackProvider string // switch to this provider on failure
}
RetryStrategy defines retry behavior for a specific failure type.