HKUDS/DeepTutor · error · GenerationFailure

LLM did not return any flashcards.

Error message

LLM did not return any flashcards.

What it means

The flash_cards block parses the LLM response into flashcards (front/back/hint); if zero cards survive extraction, it raises GenerationFailure. This happens when the LLM returns no items, or every item lacks usable front/back text.

Source

Thrown at deeptutor/book/blocks/flash_cards.py:65

        cards_raw = data.get("cards") if isinstance(data, dict) else None
        cards: list[dict[str, str]] = []
        if isinstance(cards_raw, list):
            for item in cards_raw[:count]:
                if not isinstance(item, dict):
                    continue
                front = str(item.get("front") or "").strip()
                back = str(item.get("back") or "").strip()
                if not front or not back:
                    continue
                cards.append(
                    {
                        "front": front[:300],
                        "back": back[:600],
                        "hint": str(item.get("hint") or "").strip()[:200],
                    }
                )
        if not cards:
            raise GenerationFailure("LLM did not return any flashcards.")
        return (
            {"cards": cards},
            [],
            data.get("_metadata") if isinstance(data.get("_metadata"), dict) else {},
        )


__all__ = ["FlashCardsGenerator"]

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Retry once — empty LLM outputs are frequently transient
  2. Log the raw LLM payload to see whether cards were absent or dropped during parsing
  3. Constrain the prompt with an explicit JSON schema and a minimum card count
  4. Switch to a model with reliable JSON/structured output (or enable structured output mode if available)
Defensive patterns

Strategy: retry

Try / catch

try:
    return await flash_cards_block.generate(ctx)
except GenerationFailure as exc:
    if 'did not return any flashcards' in str(exc):
        return await flash_cards_block.generate(ctx)  # one retry
    raise

Prevention

When it happens

Trigger: Calling flash_cards _generate when the LLM response has an empty cards list, non-conforming JSON where items have blank front/back fields, or a refusal message that parses to nothing.

Common situations: Prompt drift so the model returns a different JSON shape; items filtered out because front/back were empty strings after strip(); weak model producing refusals; truncated JSON from token limits producing zero parsed items.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/6bc59430e579aafc. Report an issue: GitHub.