Skip to content

Provider client retry loop blocks event loop with time.sleep #150

Open

Description

@hazelscot

Provider client retry loop blocks event loop with time.sleep

Severity: High
File: backend/app/llm/provider_client.py:245

The chat method's retry loop uses synchronous time.sleep(backoff) between retry attempts. With exponential backoff and multiple retries, this can block the event loop for tens of seconds, especially when structured output is enabled with longer timeouts.

if retries <= max_retries:
    backoff = self.settings.RETRY_BACKOFF * (2 ** (retries - 1))
    logger.warning(
        "Provider request failed (attempt %s/%s): %s. Retrying in %ss...",
        retries,
        max_retries,
        e,
        backoff,
    )
    time.sleep(backoff)

Why it matters

A single failing LLM provider can block all concurrent requests across the platform. During provider outages, the entire backend becomes unresponsive.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions