iflytek/astron-agent · error · CustomException

WORKFLOW_EXEC_RESP_FORMAT_ERROR

WORKFLOW_EXEC_RESP_FORMAT_ERROR

Error message

Workflow response format error. Response: {result_content}, Expected deserialization keys: {self.output_identifier}

What it means

In VARIABLE_MODE the flow node expects the child workflow's end node to return a JSON object parseable against output_identifier keys. When json.loads fails (or the body is not valid JSON), the node raises WORKFLOW_EXEC_RESP_FORMAT_ERROR including the raw response and expected keys.

Solutions

  1. Inspect the raw response in the error's cause_error to see what was actually returned
  2. Reconfigure the child workflow's end node to output variables (VARIABLE_MODE) so the body is JSON
  3. Check intermediate proxies/gateways for HTML error pages replacing the JSON body
  4. Fix JSON escaping/encoding in the child's end-node output values

Example fix

// child end-node output, before
"done"  // plain text, not JSON
// after
{"result": "done"}  // JSON object matching output_identifier
Defensive patterns

Strategy: type-guard

Validate before calling

def is_valid_json_object(s: str) -> bool:
    try:
        return isinstance(json.loads(s), dict)
    except Exception:
        return False

Type guard

def parse_outputs(s: str):
    try:
        v = json.loads(s)
        return v if isinstance(v, dict) else None
    except json.JSONDecodeError:
        return None

Try / catch

try:
    outputs = await flow_node.async_execute(ctx)
except CustomException as e:
    if e.err_code == CodeEnum.WORKFLOW_EXEC_RESP_FORMAT_ERROR:
        logger.error('child returned non-JSON: %s', e.cause_error)
        # inspect cause_error, fix child end-node mode, or retry once
    raise

Prevention

When it happens

Trigger: _handle_outputs with output_mode==VARIABLE_MODE calls json.loads(result_content) and it throws — e.g. the response is a plain string, HTML error page, or truncated JSON.

Common situations: Child workflow's end node not configured in variable mode so it returns free text; upstream proxy returned an HTML error page; response truncated at size/streaming limits; encoding issues corrupting JSON.

Understand the failure class

Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at core/workflow/engine/nodes/flow/flow_node.py:453

        Different output modes handle the response content differently:
        - VARIABLE_MODE: Parse JSON content as structured variables
        - OLD_PROMPT_MODE: Return content as a single output
        - PROMPT_MODE: Return both content and reasoning content

        :param output_mode: Configured output mode for the workflow
        :param result_content: Main content from the workflow response
        :param result_reasoning_content: Reasoning content from the workflow response
        :return: Processed outputs dictionary
        :raises CustomException: When output mode is invalid or content parsing fails
        """
        outputs = {}

        if output_mode == EndNodeOutputModeEnum.VARIABLE_MODE.value:
            # Parse JSON content as structured workflow parameters
            try:
                outputs = json.loads(result_content)
            except Exception as e:
                raise CustomException(
                    err_code=CodeEnum.WORKFLOW_EXEC_RESP_FORMAT_ERROR,
                    cause_error=f"Workflow response format error. Response: {result_content}, "
                    f"Expected deserialization keys: {self.output_identifier}",
                ) from e
        elif output_mode == EndNodeOutputModeEnum.OLD_PROMPT_MODE.value:
            # Return content as a single output parameter
            outputs[self.output_identifier[0]] = result_content
        elif output_mode == EndNodeOutputModeEnum.PROMPT_MODE.value:
            # Return both content and reasoning content
            outputs["content"] = result_content
            outputs["reasoning_content"] = result_reasoning_content
        else:
            raise CustomException(
                err_code=CodeEnum.WORKFLOW_EXECUTION_ERROR,
                cause_error=f"Invalid workflow output mode: {output_mode}",
            )

        return outputs

View on GitHub (pinned to 5e758547a8)