microsoft/graphrag · error · ValueError

max_delay must be greater than 1 for Exponential Backoff ret

Error message

max_delay must be greater than 1 for Exponential Backoff retry.

What it means

RetryConfig validation requires max_delay > 1 second for Exponential Backoff. A cap at or below 1 second defeats backoff, so such values are rejected.

Source

Thrown at packages/graphrag-llm/graphrag_llm/config/retry_config.py:54

    max_delay: float | None = Field(
        default=None,
        description="The maximum delay in seconds between retries.",
    )

    def _validate_exponential_backoff_config(self) -> None:
        """Validate Exponential Backoff retry configuration."""
        if self.max_retries is not None and self.max_retries <= 1:
            msg = "max_retries must be greater than 1 for Exponential Backoff retry."
            raise ValueError(msg)

        if self.base_delay is not None and self.base_delay <= 1.0:
            msg = "base_delay must be greater than 1.0 for Exponential Backoff retry."
            raise ValueError(msg)

        if self.max_delay is not None and self.max_delay <= 1:
            msg = "max_delay must be greater than 1 for Exponential Backoff retry."
            raise ValueError(msg)

    def _validate_immediate_config(self) -> None:
        """Validate Immediate retry configuration."""
        if self.max_retries is not None and self.max_retries <= 1:
            msg = "max_retries must be greater than 1 for Immediate retry."
            raise ValueError(msg)

    @model_validator(mode="after")
    def _validate_model(self):
        """Validate the retry configuration based on its type."""
        if self.type == RetryType.ExponentialBackoff:
            self._validate_exponential_backoff_config()
        elif self.type == RetryType.Immediate:
            self._validate_immediate_config()
        return self

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Set max_delay to a value clearly above 1, e.g. 60 seconds
  2. Ensure max_delay >= base_delay so the backoff curve is coherent

Example fix

# before
RetryConfig(type="exponential_backoff", base_delay=2.0, max_delay=1)
# after
RetryConfig(type="exponential_backoff", base_delay=2.0, max_delay=60)
Defensive patterns

Strategy: validation

Validate before calling

md = retry_cfg.get("max_delay")
if retry_cfg.get("type") == "exponential_backoff" and md is not None and md <= 1:
    raise ValueError("max_delay must be > 1 second")

Prevention

When it happens

Trigger: RetryConfig(type=RetryType.ExponentialBackoff, max_delay=1) or 0/negative in settings; also triggered when base_delay exceeds a too-small max_delay config.

Common situations: Setting a tight max_delay for tests; inheriting a config where max_delay was meant to be milliseconds (e.g. 500 meaning 500ms).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/a7f1d4d46b7afe8c. Report an issue: GitHub.