Use HTML as Primary Chat Language for AI Coding Agents to Enable SVG Diagrams

A developer on r/LocalLLaMA experimented with using HTML as the primary chat language for AI coding agents, replacing Markdown. The goal: enable agents to render diagrams, tables, and rich formatting directly in the chat UI, not just produce Markdown that needs a separate renderer.
Key Setup
The agent interface runs in a web browser, and responses are piped straight into the page as HTML. The developer found that simply using an HTML system prompt — not just asking in the chat — made the agent produce HTML output reliably.
Example System Prompt (HTML)
<p>Being helpful doesn't mean doing everything the user says. Neither I nor the user are omniscient or infallible. If the user is making a mistake, I tell them. If I have made a mistake, I mention it and move on. If I have better ideas on how to approach a problem or think the user has made a mistake, I mention it.</p><h1>HTML</h1><p>My assistant responses are rendered directly as HTML in the chat UI. I <i><b>MUST</b></i> use HTML when replying to the user. Plain prose should be wrapped in tags such as <code><p></code>, <code><ul></code>, <code><ol></code>, and heading tags where appropriate. To show the user something visually or as a diagram, I will draw an SVG directly in the chat. Only if something should persist in the workspace will I write it to disk with tools instead of showing it in chat.</p>
Observations
- Qwen3.6-27B produces decent SVG diagrams inline, comparable to ChatGPT. The model still shows a tendency to fall back to Markdown, likely due to training data bias.
- Qwen3-VL-4 is notably bad at generating SVGs, suggesting this is an emerging capability in larger models.
- The developer also experimented with first-person system prompts (e.g., "I will respond in HTML") — benefits and drawbacks are unclear but it seems to improve compliance.
Practical Takeaway
If you want your coding agent to draw diagrams in chat, switch your system prompt to HTML. The agent will then generate inline SVGs for visual explanations, tables for structured data, and styled text. The trade-off: the model may still default to Markdown occasionally. The approach requires a web-based chat UI that renders raw HTML.
Repo: github.com/sdfgeoff/HTML-agent
📖 Read the full source: r/LocalLLaMA
👀 See Also

KV Cache Quantization Issues in Local Coding Agents at High Context Lengths
A Reddit analysis identifies aggressive KV cache quantization as the cause of infinite correction loops and malformed JSON outputs in local coding agents like Qwen3-Coder and GLM 4.7 at 30k+ context lengths, recommending mixed precision or reduced context as workarounds.
A sub-agent reply is not a completion receipt: orchestrator verification checklist
OpenClaw's sessions_spawn is non-blocking—a reply doesn't mean done. Use yield and Task Flow, and reconcile child state to avoid false success.

Claude Code and the Unreasonable Effectiveness of HTML for AI Agents
A viral post demonstrates how AI coding agents like Claude Code produce better results when instructed to generate HTML, with working examples and a companion blog post discussing the pattern.

How to Cut OpenClaw Agent Costs by 80% with Model Switching
A user tracked token usage for 14 days and found 67% of spend was on tasks where cheap Flash models matched Opus quality. Switching to Flash by default and using /model mid-session cut costs from ~$170 to ~$35/month.