iflytek/astron-agent · error · CustomExceptionCD

CODE_EXECUTION_TIMEOUT_ERROR

CODE_EXECUTION_TIMEOUT_ERROR

Error message

Code execution timeout

What it means

CODE_EXECUTION_TIMEOUT_ERROR is raised by _handle_error_response when the iFly v2 code service responds with type == 'exec_code_timeout', meaning the sandbox killed the user's code because it exceeded its execution time budget. The err_msg is the fixed string 'Code execution timeout'.

Solutions

  1. Optimize or shorten the code in the code node: vectorize loops, remove sleeps, add internal timeouts to network calls.
  2. Split the work into multiple code nodes or process data in chunks.
  3. Raise the code-execution timeout limit in the executor/sandbox configuration if legitimate long runs are expected.
  4. Fix the root cause if an upstream node change made a loop non-terminating (e.g. unexpected empty input).

Example fix

# before (inside user code node)
while True:
    process(rows)
// after
import itertools
for _ in itertools.islice(iter_process(rows), MAX_ITERATIONS):
    pass
Defensive patterns

Strategy: validation

Validate before calling

# static sanity check before submitting user code
import ast
tree = ast.parse(user_code)
if any(isinstance(n, ast.While) for n in ast.walk(tree)) and "break" not in user_code and "return" not in user_code:
    raise ValueError("while loop without break/return likely exceeds execution timeout")

Try / catch

try:
    output = await executor.execute(...)
except CustomExceptionCD as e:
    if e.err_code == CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR.code:
        logger.error("code node exceeded time budget; chunk the workload")
        output = partial_result_or_empty

Prevention

When it happens

Trigger: A code node whose script runs longer than the sandbox's time limit — infinite loops, very large data processing, long sleeps, or blocking network calls without timeouts inside the user code.

Common situations: Users paste heavy data-wrangling scripts into code nodes; a loop that never terminates after an upstream node changed its output shape; sandbox timeout lowered via config making previously-fine scripts fail.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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

Appendix: source

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

            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}")

        if err_type == "exec_code_timeout":
            raise CustomExceptionCD(
                err_code=CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR.code,
                err_msg="Code execution timeout",
            )
        elif err_type == "exec_code_failed":
            raise CustomExceptionCD(
                err_code=CodeEnum.CODE_EXECUTION_ERROR.code,
                err_msg=self._remove_traceback_stdin_line(resp_message),
            )
        else:
            raise CustomExceptionCD(
                err_code=CodeEnum.CODE_EXECUTION_ERROR.code,
                err_msg="Code execution failed",
            )

    def _remove_traceback_stdin_line(self, traceback_str: str) -> str:
        """
        Remove traceback line with V2-specific preprocessing.

View on GitHub (pinned to 5e758547a8)