Repository navigation
Closed
Description
Summary
enableRetries is exposed on ProviderFactoryConfig, FromEnvOverrides, and createCostOptimizedFactory(), but it is not wired to provider retry behavior. Providers always construct a RetryManager from provider-level maxRetries / retryDelay, defaulting to 3 retries.
As a result, enableRetries: false does not disable retries, and enableRetries: true is effectively decorative unless the provider config already has retry settings.
Fractal Decomposition
Macro: Control-plane knobs must match runtime behavior
- Retry policy affects latency, cost, duplicate requests, and provider-side rate-limit pressure.
- A no-op factory-level retry flag makes production behavior hard to reason about, especially when consumers expect one request attempt for non-idempotent tool or JSON-generation paths.
Meso: Factory config vs provider config
ProviderFactoryConfigincludesenableRetries, butinitializeProviders()forwards only provider config, logger, and hooks into provider constructors.BaseProvideralways creates aRetryManager.- There is no factory-level mapping from
enableRetriesto providermaxRetries.
Micro: Concrete code paths
src/factory.ts:53-57:enableRetriesis part of the factory config.src/index.ts:152-159andsrc/index.ts:228-230:fromEnv()exposes and copies the override.src/factory.ts:604-615:createCostOptimizedFactory()setsenableRetries: true.src/providers/base.ts:37-50: every provider defaultsmaxRetriesto 3 and constructsRetryManagerregardless ofenableRetries.
Impact
- Consumers cannot disable retry from the high-level factory config.
- Tests assert the override is accepted, but do not assert any runtime effect.
- Package docs advertise "configurable delays, jitter, and per-error-class behavior"; the most visible high-level config knob for this behavior is currently misleading.
Suggested Fix
- Decide the public contract:
- If
enableRetriesis kept, mapfalsetomaxRetries: 0unless provider config explicitly overrides it. - If retries should be provider-only, remove
enableRetriesfrom public factory/fromEnv config and update docs/tests.
- If
- Add tests that count provider request attempts for retryable errors with
enableRetries: falseandenableRetries: true. - Consider emitting retry hooks from
RetryManager, sinceObservabilityHooksdefinesonRetrybut retry events are not currently wired through.
Verification
npm run typecheckpasses.npm testpasses: 169 tests.
Metadata
Metadata
Assignees
Labels
No labels
Activity