diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 30e8951..f4483cf 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -86,6 +86,17 @@ func init() { Name: "auth-token", Sources: cli.EnvVars("ANTHROPIC_AUTH_TOKEN"), }, + &cli.IntFlag{ + Name: "max-retries", + Usage: "Maximum number of retries for failed API requests (0 to disable)", + Value: 3, + Validator: func(n int) error { + if n < 0 || n > 10 { + return fmt.Errorf("max-retries must be between 0 and 10") + } + return nil + }, + }, }, Commands: []*cli.Command{ { diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index 1c34fe6..326e982 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -58,6 +58,11 @@ func getDefaultRequestOptions(cmd *cli.Command) []option.RequestOption { opts = append(opts, option.WithBaseURL(baseURL)) } + // Configure max retries (SDK defaults to 2, 0 disables retry) + if maxRetries := cmd.Int("max-retries"); maxRetries >= 0 { + opts = append(opts, option.WithMaxRetries(int(maxRetries))) + } + return opts }