iflytek/astron-agent · error · CustomException

OPEN_AI_REQUEST_ERROR

OPEN_AI_REQUEST_ERROR

Error message

No valid content to send to Google API

What it means

In GoogleChatAI._recv_messages, messages are converted to the google-genai 'contents' + system_instruction format. If the conversion produces an empty contents list (no text/parts survived), the provider raises CustomException(OPEN_AI_REQUEST_ERROR, 'No valid content to send to Google API') rather than sending a request Gemini would reject. It indicates the input message list contained nothing convertible (e.g. only tool messages, or messages with empty content).

Solutions

  1. Inspect the messages passed to achat and ensure at least one message has non-empty text content (typically a user message).
  2. Fix the upstream workflow node so the prompt variable is actually populated before invoking the LLM.
  3. Extend _convert_messages_to_genai_format if valid content lives in a field/role it currently skips.
  4. Add a caller-side guard that raises a clearer business error when the assembled prompt is empty.

Example fix

// before
msgs = [{'role': 'assistant', 'content': ''}]
await llm.achat(msgs)
// after
if not any((m.get('content') or '').strip() for m in msgs):
    raise ValueError('prompt is empty: refusing to call LLM')
await llm.achat(msgs)
Defensive patterns

Strategy: validation

Validate before calling

def has_sendable_content(messages):
    return any(
        isinstance(m, dict) and str(m.get('content') or '').strip()
        and m.get('role') not in (None, 'tool')
        for m in messages
    )

Try / catch

try:
    async for chunk in llm.achat(messages):
        handle(chunk)
except CustomException as e:
    if 'No valid content' in e.err_msg:
        raise PromptError('workflow produced an empty prompt') from e
    raise

Prevention

When it happens

Trigger: Calling achat/_recv_messages with a user_message whose converted contents list is empty: all messages have None/empty string content, only unsupported roles are present, or content parts were all filtered out during _convert_messages_to_genai_format.

Common situations: A workflow node passes an empty prompt (upstream variable not filled in), a chat history containing only assistant/system messages with no user text, or content stored in a field the converter ignores.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at core/workflow/infra/providers/llm/google/google_chat_llm.py:253

        Args:
            url: API endpoint URL (used for custom Google-compatible endpoints)
            user_message: List of user messages to send
            extra_params: Additional parameters for the API call
            span: OpenTelemetry span for tracing
            timeout: Request timeout in seconds

        Yields:
            LLMResponse objects containing normalized API responses
        """
        # Convert messages to Google GenAI format
        contents, system_instruction = await self._convert_messages_to_genai_format(
            user_message
        )

        # Validate we have content to send
        if not contents:
            raise CustomException(
                err_code=CodeEnum.OPEN_AI_REQUEST_ERROR,
                err_msg="No valid content to send to Google API",
                cause_error="Empty content after conversion",
            )

        # Build generation configuration
        generation_config = GenerateContentConfig(
            max_output_tokens=self.max_tokens,
            temperature=self.temperature,
        )

        # Add system instruction if present
        if system_instruction:
            generation_config.system_instruction = system_instruction

        # Handle extra parameters
        if extra_params:
            # Map common parameters to GenerateContentConfig fields

View on GitHub (pinned to 5e758547a8)