Skip to content

Commit 49bdf32

Browse files
committed
feat: read MaxRetries from OPENAI_MAX_RETRIES env var
When MaxRetries is not set in config, fall back to the OPENAI_MAX_RETRIES environment variable. Invalid values are silently ignored, preserving the SDK default of 2 retries.
1 parent 8ee1e8b commit 49bdf32

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

provider/openai.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"net/http"
88
"os"
9+
"strconv"
910
"strings"
1011

1112
"github.com/google/uuid"
@@ -51,6 +52,13 @@ func NewOpenAI(cfg config.OpenAI) *OpenAI {
5152
if cfg.APIDumpDir == "" {
5253
cfg.APIDumpDir = os.Getenv("BRIDGE_DUMP_DIR")
5354
}
55+
if cfg.MaxRetries == nil {
56+
if v := os.Getenv("OPENAI_MAX_RETRIES"); v != "" {
57+
if n, err := strconv.Atoi(v); err == nil {
58+
cfg.MaxRetries = &n
59+
}
60+
}
61+
}
5462
if cfg.CircuitBreaker != nil {
5563
cfg.CircuitBreaker.OpenErrorResponse = openAIOpenErrorResponse
5664
}

0 commit comments

Comments
 (0)