HKUDS/DeepTutor · error · GenerationFailure
interactive html failed validation: {validation_error}
Error message
interactive html failed validation: {validation_error} What it means
After InteractiveGenerator returns HTML code, the block validates it with validate_visualization(code, 'html'). If the generated HTML fails validation (syntax/structure rules), GenerationFailure is raised with the specific validation error.
Source
Thrown at deeptutor/book/blocks/interactive.py:96
language=ctx.language,
)
analysis = await pipeline.run_analysis(
user_input=user_input,
history_context=history_context,
render_mode="html",
)
code = await pipeline.run_code_generation(
user_input=user_input,
history_context=history_context,
analysis=analysis,
)
except Exception as exc:
logger.warning(f"InteractiveGenerator failed: {exc}", exc_info=True)
raise GenerationFailure(f"interactive generation failed: {exc}") from exc
ok, validation_error = validate_visualization(code, "html")
if not ok:
raise GenerationFailure(f"interactive html failed validation: {validation_error}")
return (
{
"render_type": "html",
"code": {"language": "html", "content": code},
"description": analysis.description,
"chart_type": analysis.chart_type,
},
[],
{
"review_changed": False,
"review_notes": "Passed local validation.",
},
)
__all__ = ["InteractiveGenerator"]
View on GitHub (pinned to 3e82f13042)
Solutions
- Read validation_error to find the offending construct in the HTML
- Retry, possibly with higher max_tokens so output isn't truncated
- Use a stronger model or simplify the requested interactive widget
- If persistent, hand-edit or externally supply the HTML
Defensive patterns
Strategy: retry
Type guard
def plausible_html(code: str) -> bool:
return bool(code) and code.lstrip().lower().startswith('<!doctype') or '<html' in code.lower() Try / catch
try:
return await interactive_block.generate(ctx)
except GenerationFailure as exc:
if 'failed validation' in str(exc):
return await interactive_block.generate(ctx) # retry once
raise Prevention
- Raise max_tokens so generated HTML isn't truncated
- Use a stronger model for large interactive documents
- Validate returned HTML client-side before rendering it in the app
When it happens
Trigger: Calling interactive _generate when the generated HTML string fails validate_visualization — e.g. unbalanced tags, script syntax errors, or whatever structural rules the 'html' validator enforces.
Common situations: LLM emits truncated HTML due to max-token limits; broken inline <script> JS; validator tightened in a newer version; model too weak for large interactive documents.
Related errors
- interactive generation failed: {exc}
- Model not configured for agent {self.agent_name}. Please act
- Render failed because local LaTeX is missing. Please avoid T
- Document not found
- Unsupported import source: {value!r}
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/2cf4e3af6786f124.
Report an issue: GitHub.