retrysched

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package retrysched classifies the errors a model call can end in: the parsed Err shape, the timeout and context-overflow predicates the step loop consults, and the StatusError a failed provider response becomes. senior-dev issues one request per model call; nothing here schedules or re-issues a request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeaderPairs

func HeaderPairs(headers map[string][]string) map[string]string

HeaderPairs flattens response headers into a lowercase-keyed map.

func IsContextOverflow

func IsContextOverflow(err Err) bool

IsContextOverflow reports whether a classified error says the prompt did not fit the model's context: a 413, a known overflow message, or a context_length_exceeded code in the response body.

func IsTimeoutError

func IsTimeoutError(err Err) bool

IsTimeoutError reports whether the classified error is timeout-shaped: an AbortError by name, or a timeout-shaped message. A missing message is not a match.

Types

type Err

type Err struct {
	Name string  `json:"name"`
	Data ErrData `json:"data"`
}

Err is a classified error: a name plus the payload fields the predicates probe.

func FromError

func FromError(err error) Err

FromError classifies a Go error into the Err shape.

func FromStreamError

func FromStreamError(raw json.RawMessage) Err

FromStreamError classifies an in-band error payload from a model stream.

func (Err) IsAPIError

func (e Err) IsAPIError() bool

IsAPIError reports whether the classified error is a provider API error.

type ErrData

type ErrData struct {
	Message         *string           `json:"message,omitempty"`
	StatusCode      *float64          `json:"statusCode,omitempty"`
	IsRetryable     *bool             `json:"isRetryable,omitempty"`
	ResponseHeaders map[string]string `json:"responseHeaders,omitempty"`
	ResponseBody    *string           `json:"responseBody,omitempty"`
	Metadata        map[string]string `json:"metadata,omitempty"`
}

ErrData models the error payload for the keys the predicates probe. Every field is a pointer because a provider error can omit any of them, including the message.

type StatusError

type StatusError struct {
	Message         string
	Name            string
	Status          *float64
	Cause           error
	ResponseHeaders map[string]string
	ResponseBody    *string
}

StatusError is the error the OpenRouter path returns for a failed HTTP response: a message plus the status, headers and body the response carried. It exposes the status, name, body and cause through the small interfaces the adaptive router's classifiers probe.

func NewProviderError

func NewProviderError(message string, status float64, headers map[string]string, body *string) *StatusError

NewProviderError builds the StatusError for a failed HTTP response.

func (*StatusError) Error

func (e *StatusError) Error() string

func (*StatusError) ErrorDetail

func (e *StatusError) ErrorDetail() string

ErrorDetail is the response body, so classifiers can match provider messages that only appear there.

func (*StatusError) ErrorName

func (e *StatusError) ErrorName() string

ErrorName is the symbolic error name; it defaults to "Error".

func (*StatusError) ErrorStatusCode

func (e *StatusError) ErrorStatusCode() (float64, bool)

ErrorStatusCode reports the HTTP status, when the error carries one.

func (*StatusError) RetryError

func (e *StatusError) RetryError() Err

RetryError projects the failure into the classified Err shape: an APIError, or a ContextOverflowError when the message or body says the prompt did not fit.

func (*StatusError) Unwrap

func (e *StatusError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL