iflytek/astron-agent · error · CustomException

CODE_REQUEST_ERROR

CODE_REQUEST_ERROR

Error message

Retry attempts exceeded 5 times

What it means

In ifly_executor_v2._execute_with_retry, when the remote code-execution service keeps returning retryable error codes, the loop sleeps 1s and retries; after the retry budget is exhausted (message says 5 times) it raises CODE_REQUEST_ERROR with a fixed 'Retry attempts exceeded 5 times' message. It means the code service never produced a successful (or definitively non-retryable-failed) response within the retry window.

Solutions

  1. Inspect the code service logs for the 5 retryable responses to find the underlying code (rate limit, overload, 5xx).
  2. Reduce concurrency or add backoff/capacity to the code-executor service; scale the sandbox workers.
  3. Increase the retry count or sleep interval if the service recovers under short load spikes (edit _execute_with_retry constants).
  4. Verify endpoint configuration points at the correct, healthy service instance.

Example fix

# before
if resp_code in RETRYABLE_ERROR_CODES:
    await asyncio.sleep(1)
    continue
// after: exponential backoff with jitter
if resp_code in RETRYABLE_ERROR_CODES:
    await asyncio.sleep(min(2 ** attempt, 30) + random.random())
    continue
Defensive patterns

Strategy: retry

Validate before calling

# pre-check service load before dispatching
resp = await http.get(f"{code_service_url}/health")
if resp.status_code != 200:
    raise RuntimeError("code executor unhealthy, abort before retry loop")

Try / catch

try:
    output = await executor.execute(...)
except CustomException as e:
    if "Retry attempts exceeded" in str(e.err_msg):
        await asyncio.sleep(backoff)
        output = await executor.execute(...)  # one outer-level retry

Prevention

When it happens

Trigger: Calling execute() on a code node backed by the v2 iFly executor where each HTTP response carries a retryable error code (per RETRYABLE_ERROR_CODES), causing `continue` on every iteration until the loop falls through to the final raise.

Common situations: The remote code service is overloaded or rate-limiting; the sandbox queue is backed up under concurrent workflow runs; intermittent 5xx/429 responses for the whole retry window; misconfigured endpoint hitting a busy shared instance.

Related errors


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

Appendix: source

Thrown at core/workflow/engine/nodes/code/executor/ifly/ifly_executor_v2.py:117

                            resp_json, ensure_ascii=False
                        )
                    }
                )
                runner_result = (
                    resp_json.get("data", {}).get("code_resp", {}).get("stdout", "")
                )
                if isinstance(runner_result, str) and runner_result.endswith("\n"):
                    runner_result = runner_result[:-1]
                return runner_result

            resp_code = resp_json.get("code", 0)
            if resp_code in RETRYABLE_ERROR_CODES:
                await asyncio.sleep(1)
                continue

            self._handle_error_response(resp_json, span)

        raise CustomException(
            err_code=CodeEnum.CODE_REQUEST_ERROR,
            err_msg="Retry attempts exceeded 5 times",
            cause_error="Retry attempts exceeded 5 times",
        )

    def _handle_error_response(self, resp_json: dict, span: Span) -> None:
        """
        Handle error response and raise appropriate exception.

        :param resp_json: Response json dictionary
        :param span: Tracing span for logging
        :raises CustomExceptionCD: Based on error type
        """

        err_type = resp_json.get("type", "")
        resp_message = resp_json.get("message", "")
        span.add_error_event(f"err_type: {err_type}")
        span.add_error_event(f"response message: {resp_message}")

View on GitHub (pinned to 5e758547a8)