iflytek/astron-agent · error · Exception

All retry attempts failed

Error message

All retry attempts failed

What it means

Defensive terminal raise at the end of _make_request's retry loop in ragflow_client.py. Because every failed attempt is supposed to raise (final API error, session-retry exhaustion, or the logged-and-re-raised exception), the loop should never fall through; if it does (e.g. a retry path returns None instead of raising), the code raises Exception('All retry attempts failed').

Solutions

  1. Inspect the logs immediately above the raise (Request URL / Request data are logged) to find the per-attempt failure
  2. Fix the swallowing except branch so the genuine error propagates instead of falling through the loop
  3. Increase max_retries only if the failures are transient (server restarts); otherwise fix the root cause
  4. Ensure RAGFlow server availability during the retry window

Example fix

# before
except Exception as e:
    logger.error(f"... {e}")
    # falls through, eventually hits 'All retry attempts failed'
# after
except Exception as e:
    logger.error(f"Request failed: {e}")
    raise
Defensive patterns

Strategy: try-catch

Try / catch

try:
    result = await retrieval_with_dataset(dataset_id, query)
except Exception as e:
    if str(e) == 'All retry attempts failed':
        logger.error('RAGFlow exhausted retries; check earlier logs for per-attempt cause')
        raise

Prevention

When it happens

Trigger: Exhausting max_retries in _make_request without any earlier raise — practically triggered when session-error handling or a future code path returns control without raising, or when the retry loop condition is off-by-one relative to error handling.

Common situations: Bug in retry logic after modifying max_retries; partial failures across a RAGFlow server outage where each attempt fails in a way currently swallowed; running with a custom build where an except branch was changed to log-and-continue.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/13ac6d401f7d2b65. Report an issue: GitHub.

Appendix: source

Thrown at core/knowledge/infra/ragflow/ragflow_client.py:363

                raise Exception(f"API request failed: {status} - {result}")

            return result

        except (aiohttp.ClientConnectionError, RuntimeError) as e:
            if _is_session_closed_error(e):
                await _handle_session_error(attempt, max_retries, e)
                continue
            else:
                raise e
        except Exception as e:
            logger.error(f"Request failed: {method} {endpoint} - {e}")
            logger.error(f"Request URL: {url}")
            if data:
                logger.error(f"Request data: {data}")
            raise

    # This should never be reached due to exceptions being raised
    raise Exception("All retry attempts failed")


async def cleanup_session() -> None:
    """
    Clean up session resources (called when application shuts down)
    """
    global _session_cache

    if _session_cache and not _session_cache.closed:
        await _session_cache.close()
        _session_cache = None
        logger.info("RAGFlow HTTP session cleaned up")


def reload_config() -> None:
    """
    Reload configuration (called after configuration changes)
    """

View on GitHub (pinned to 5e758547a8)