Skip to content

Conversation

a-klos
Copy link
Member

@a-klos a-klos commented Sep 2, 2025

This pull request introduces a robust, configurable retry decorator with exponential backoff and rate-limit handling for both synchronous and asynchronous functions. It also integrates the retry decorator settings into the infrastructure configuration, making them easily adjustable via environment variables and Kubernetes ConfigMaps. Comprehensive tests have been added to ensure correct behavior. The main changes are grouped below:

Retry Decorator Implementation and Utilities

  • Added retry_with_backoff decorator in libs/rag-core-lib/src/rag_core_lib/impl/utils/retry_decorator.py, supporting configurable retries, exponential backoff, jitter, and rate-limit awareness for sync/async functions.
  • Introduced utility functions in libs/rag-core-lib/src/rag_core_lib/impl/utils/utils.py for parsing rate-limit headers, normalizing dictionaries, and extracting status codes/headers from exceptions.

Configuration and Infrastructure Integration

  • Created RetryDecoratorSettings in libs/rag-core-lib/src/rag_core_lib/impl/settings/retry_decorator_settings.py using Pydantic, allowing environment-based configuration of retry logic parameters.
  • Added retryDecorator configuration block to infrastructure/rag/values.yaml for setting retry parameters via Helm values.
  • Generated a new ConfigMap in infrastructure/rag/templates/configmap.yaml to expose retry decorator settings to Kubernetes deployments.
  • Updated deployment templates (admin-backend/deployment.yaml, backend/deployment.yaml) to mount the new retry decorator ConfigMap. [1] [2]
  • Added a Helm template helper for naming the retry decorator ConfigMap in _helpers.tpl.

Testing

  • Added comprehensive unit tests in libs/rag-core-lib/tests/retry_decorator_test.py to validate retry logic, rate-limit handling, and configuration.

This PR covers the following feature request
#87

@huhn511 huhn511 requested a review from Copilot September 23, 2025 15:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a robust retry decorator with exponential backoff and rate-limit handling for both synchronous and asynchronous functions, enabling configurable retry behavior through environment variables and Kubernetes configuration.

  • Implements a configurable retry decorator with exponential backoff, jitter, and rate-limit awareness
  • Integrates retry settings into infrastructure configuration via Helm values and ConfigMaps
  • Adds comprehensive test coverage for retry scenarios including rate-limit handling

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
retry_decorator_test.py Comprehensive test suite covering sync/async retry scenarios and rate-limit handling
utils.py Utility functions for parsing rate-limit headers and extracting exception metadata
retry_decorator.py Core retry decorator implementation with exponential backoff and rate-limit awareness
retry_decorator_settings.py Pydantic settings model for configuring retry behavior via environment variables
pyproject.toml Adds pytest-asyncio dependency for async test support
README.md Documentation for retry decorator usage and configuration
values.yaml Default retry configuration values for Helm deployment
configmap.yaml ConfigMap template for retry decorator environment variables
deployment.yaml files Integration of retry decorator ConfigMap into backend deployments
_helpers.tpl Helm template helper for retry decorator ConfigMap naming

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants