feat(proxy): make connection-level retries configurable per provider#148
Merged
feat(proxy): make connection-level retries configurable per provider#148
Conversation
Add `connectionRetries` config field (default 3) to control how many times forwardWithRetry() retries a provider on TTFB/stall/connection errors before escalating to fallback. Operators can now set low values (1-2) to fail fast on known-bad providers, reducing worst-case latency from ~35s to ~8-17s on connection failures. - src/types.ts: add _connectionRetries to ProviderConfig - src/config.ts: add to Zod schema, peekConfig type, and loadConfig mapping - src/proxy.ts: use provider._connectionRetries ?? CONNECTION_RETRY_MAX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connectionRetriesper-provider config (default 3) to control retry count before fallback escalationFiles changed
src/types.ts—_connectionRetries?: numberon ProviderConfigsrc/config.ts— Zod schema, peekConfig type, loadConfig mappingsrc/proxy.ts—forwardWithRetry()readsprovider._connectionRetries ?? 3Config example
Motivation
From 2hr production log analysis: 108 connection errors on GLM with 3 retries each wasted ~35s per failed request before fallback. With
connectionRetries: 1, that drops to ~8.5s.Test plan
npm run buildpasses with no type errorsconnectionRetries: 0on a provider and confirm it skips retries, goes straight to fallbackconnectionRetries: 1and confirm exactly 1 retry before fallbackconnectionRetriesand confirm default behavior (3 retries) preserved