ANTIGRAVITY LABJP
Articles/Integrations
Integrations/2026-03-29Intermediate

Turn Draw.io Diagrams into AI Prompts — Visual Agent Design with Antigravity

Learn how to use Draw.io flowcharts and sequence diagrams as executable AI agent prompts. This guide covers XML metadata techniques for visual prompt design.

draw-iovisual-promptai-agent18workflow49vscode4multi-agent49

Setup and context — Draw a Diagram, Run an AI Agent

When designing AI agent workflows, most people draw a diagram first, then translate it into code or prompts — a two-step process. What if you could skip the translation and execute the diagram directly? With Draw.io (diagrams.net), this is possible.

Draw.io files are XML under the hood, and each shape can carry custom metadata attributes. This means a single file can serve double duty: a human-readable flowchart and a structured prompt that AI agents can interpret and execute.

This article walks through how to combine Draw.io visual prompts with AI tools like Antigravity and GitHub Copilot, progressing from simple tasks to multi-agent parallel execution.

Why Draw.io?

The Problem with Mermaid Diagrams

Mermaid notation is commonly used to have AI agents auto-generate workflow diagrams. But in practice, several issues arise.

  • AI-generated Mermaid frequently contains syntax errors
  • Complex flows become hard to read
  • No GUI editing — everything is text-based
  • Adding or removing agents requires grammar knowledge

Draw.io's Advantages

Draw.io offers compelling benefits for visual prompt design.

  • Intuitive GUI: Drag and drop shapes, connect with arrows
  • XML-based: The file format is program-readable
  • Custom metadata: Embed hidden text information in each shape
  • VSCode integration: Edit .dio files directly in your editor
  • Version control friendly: Text-based format works with Git diffs

Core Principle: XML Metadata

Draw.io files (.dio / .drawio) are XML documents with a structure like this.

<mxGraphModel>
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    <!-- Shape element -->
    <mxCell id="2" value="Run Google Search"
            style="rounded=1;whiteSpace=wrap;"
            vertex="1" parent="1">
      <mxGeometry x="100" y="100" width="200" height="60" as="geometry"/>
      <!-- Custom metadata -->
      <object label="Run Google Search"
              SystemPrompt="Search Google with the specified keywords and return the top 3 results"
              ToolName="web_search"/>
    </mxCell>
  </root>
</mxGraphModel>

The key is the object element's attributes. label shows visible text on the diagram, while SystemPrompt and ToolName serve as metadata for AI agent execution. Humans see a normal flowchart; AI agents see structured prompts.

Practice 1: Simple Task Execution

Step 1: Create a Draw.io File

Install the "Draw.io Integration" extension in VSCode and create a prompt.dio file.

  1. Place a rounded rectangle and type "Run Google Search"
  2. Right-click the shape → "Edit Style" to add custom attributes
  3. Add a SystemPrompt attribute with processing details

Step 2: Parse the Metadata

Here's Python code to extract metadata from a Draw.io file.

import xml.etree.ElementTree as ET
 
def parse_drawio_prompt(filepath):
    """Extract prompt information from a Draw.io file"""
    tree = ET.parse(filepath)
    root = tree.getroot()
 
    tasks = []
    for cell in root.iter("mxCell"):
        value = cell.get("value", "")
        # Look for cells with object elements
        obj = cell.find("object")
        if obj is not None:
            task = {
                "label": obj.get("label", value),
                "system_prompt": obj.get("SystemPrompt", ""),
                "tool": obj.get("ToolName", ""),
                "id": cell.get("id")
            }
            tasks.append(task)
 
    return tasks
 
# Usage example
tasks = parse_drawio_prompt("prompt.dio")
for task in tasks:
    print(f"Task: {task['label']}")
    print(f"  Prompt: {task['system_prompt']}")
    print(f"  Tool: {task['tool']}")
# Example output:
# Task: Run Google Search
#   Prompt: Search Google with the specified keywords and return the top 3 results
#   Tool: web_search

Practice 2: Building Sequential Workflows

For a more practical example, let's build a 4-stage pipeline: "Fetch RSS feed → Filter by criteria → Extract data → Summarize in 100 words."

Flow Design

[Fetch RSS Feed] → [Filter by Criteria] → [Extract Data] → [Summarize]
   (circle)           (diamond)            (rectangle)     (rounded rect)

Shape types carry semantic meaning.

  • Circle: Input / data source
  • Diamond: Conditional branching / filtering
  • Rectangle: Data transformation / processing
  • Rounded rectangle: Output / final result

Parsing Connection Information

Edge (arrow) information reveals execution order.

def parse_drawio_workflow(filepath):
    """Extract workflow (nodes + edges) from a Draw.io file"""
    tree = ET.parse(filepath)
    root = tree.getroot()
 
    nodes = {}
    edges = []
 
    for cell in root.iter("mxCell"):
        cell_id = cell.get("id", "")
        source = cell.get("source")
        target = cell.get("target")
 
        if source and target:
            # Edge (arrow)
            edges.append({"from": source, "to": target})
        elif cell.get("vertex") == "1":
            # Node (shape)
            obj = cell.find("object")
            if obj is not None:
                nodes[cell_id] = {
                    "label": obj.get("label", cell.get("value", "")),
                    "prompt": obj.get("SystemPrompt", ""),
                    "tool": obj.get("ToolName", "")
                }
 
    return nodes, edges
 
def build_execution_order(nodes, edges):
    """Determine execution order from edge information"""
    # Topological sort starting from nodes with zero in-degree
    in_degree = {nid: 0 for nid in nodes}
    adjacency = {nid: [] for nid in nodes}
 
    for edge in edges:
        if edge["to"] in in_degree:
            in_degree[edge["to"]] += 1
        if edge["from"] in adjacency:
            adjacency[edge["from"]].append(edge["to"])
 
    queue = [nid for nid, deg in in_degree.items() if deg == 0]
    order = []
 
    while queue:
        current = queue.pop(0)
        order.append(current)
        for neighbor in adjacency.get(current, []):
            in_degree[neighbor] -= 1
            if in_degree[neighbor] == 0:
                queue.append(neighbor)
 
    return order
 
# Usage example
nodes, edges = parse_drawio_workflow("sequence_prompt.dio")
order = build_execution_order(nodes, edges)
for node_id in order:
    node = nodes[node_id]
    print(f"Execute: {node['label']} (tool: {node['tool']})")
# Example output:
# Execute: Fetch RSS Feed (tool: rss_fetch)
# Execute: Filter by Criteria (tool: filter)
# Execute: Extract Data (tool: extract)
# Execute: Summarize (tool: summarize)

Practice 3: Multi-Agent Parallel Execution

Draw.io's swimlane (pool/lane) feature enables visual representation of parallel AI agent execution.

Swimlane Design

┌─────────────────────────────────────────┐
│ Agent A (Market Research)                │
│   [Competitor Analysis] → [Trend Extraction] │
├─────────────────────────────────────────┤
│ Agent B (Technical Research)             │
│   [Tech Comparison] → [Cost Estimation]  │
├─────────────────────────────────────────┤
│ Integration Layer                        │
│              [Aggregate Results] → [Generate Report] │
└─────────────────────────────────────────┘

Each lane corresponds to an independent agent, and cross-lane arrows represent result handoffs. Adding or removing agents is as simple as adding or removing lanes in the GUI.

Parallel Execution Implementation

import asyncio
 
async def execute_agent(agent_name, tasks, nodes):
    """Execute a single agent's tasks sequentially"""
    results = []
    for task_id in tasks:
        node = nodes[task_id]
        print(f"[{agent_name}] Executing: {node['label']}")
        # In practice, call the AI API here
        result = f"Result of {node['label']}"
        results.append(result)
        await asyncio.sleep(0.1)  # Simulate API call
    return results
 
async def run_multi_agent_workflow(agents_config, nodes):
    """Run multiple agents in parallel and aggregate results"""
    tasks = [
        execute_agent(name, task_ids, nodes)
        for name, task_ids in agents_config.items()
    ]
    all_results = await asyncio.gather(*tasks)
    return dict(zip(agents_config.keys(), all_results))
 
# Usage example
agents = {
    "Agent A (Market Research)": ["node_1", "node_2"],
    "Agent B (Technical Research)": ["node_3", "node_4"]
}
# results = asyncio.run(run_multi_agent_workflow(agents, nodes))
print("Multi-agent workflow configured")
# Output: Multi-agent workflow configured

Integration with Antigravity

To leverage Draw.io visual prompts within the Antigravity IDE, the most effective approach is to expose the parser as an MCP server.

Antigravity's agent features can invoke external tools via MCP servers. By turning the Draw.io parser into an MCP server, you can trigger visual prompt-based workflows with natural language instructions like "execute the workflow in this diagram."

Business Benefits

Collaboration with Non-Engineers

Since prompt design is expressed as diagrams rather than code, business stakeholders can participate in AI agent workflow design directly.

Documentation-Code Alignment

When the diagram is the prompt, the classic problem of "design docs drifting from implementation" is structurally eliminated.

Easy Change Management

Workflow changes happen through GUI drag-and-drop, and Git tracks the diffs in the underlying XML.

Summary

Using Draw.io as an AI agent prompt is an approach that unifies "human-readable diagrams" and "AI-executable prompts" in a single file. By leveraging XML-based metadata, you can visually design and execute everything from simple tasks to multi-agent parallel workflows.

Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Agents & Manager2026-03-26
Antigravity Multi-Agent Workflow Guide — Accelerate Development with Multiple AIs
Learn how to use Antigravity's multi-agent features to dramatically speed up your development workflow. From Manager Surface basics to advanced agent coordination patterns.
Integrations2026-04-29
Building a Stripe Dunning Recovery Pipeline with Antigravity AI Agents — Stop Failed Payments from Becoming Churn
Wire Antigravity AI agents into Stripe Smart Retries to recover failed payments before they turn into churn. Webhooks, idempotency, AI-tailored email copy, Slack escalation, and winback offers — all in one production-ready pattern.
Integrations2026-04-25
Antigravity × Obsidian — Growing Code and Knowledge in the Same Place
A practical workflow for connecting the code you write in Antigravity to a growing Obsidian knowledge base. Record architecture decisions, accumulate bug patterns, and bring that context into every new AI session.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →