{
  "schema_version": 1,
  "diagram_type": "workflow",
  "meta": {
    "title": "Agent Tool Call Workflow",
    "subtitle": "Renderer-driven workflow prototype with lanes, anchored nodes, and orthogonal edges",
    "animation": "trace",
    "visual_preset": "signal-flow",
    "quality_profile": "showcase",
    "views": [
      {
        "id": "happy-path",
        "label": "Request to result",
        "focus": ["user", "chat", "planner", "router", "approval", "tool", "external", "final"],
        "note": "Follow the successful request from user intent to the final reply."
      },
      {
        "id": "safety-gate",
        "label": "Policy and recovery",
        "focus": ["router", "approval", "blocked", "retry"],
        "note": "See where risky work stops, waits for consent, or returns for revision."
      },
      {
        "id": "evidence-loop",
        "label": "Evidence and memory",
        "focus": ["external", "store", "trace"],
        "note": "Isolate the durable trace and context path behind the visible answer."
      }
    ],
    "output": "examples/workflow-agent-tool-call-rendered.html",
    "viewBox": [720, 900]
  },
  "lanes": [
    { "id": "ui", "label": "User Interface" },
    { "id": "agent", "label": "Agent Runtime" },
    { "id": "policy", "label": "Policy Boundary" },
    { "id": "exceptions", "label": "Exception Handling", "variant": "exception" },
    { "id": "tools", "label": "Tool Execution" },
    { "id": "trace", "label": "Observability" }
  ],
  "phases": [
    { "id": "intake", "label": "Intake", "fromCol": 0, "toCol": 1 },
    { "id": "reasoning", "label": "Plan + route", "fromCol": 2, "toCol": 3, "variant": "emphasis" },
    { "id": "execution", "label": "Execute + report", "fromCol": 4, "toCol": 5, "variant": "dashed" }
  ],
  "groups": [
    { "id": "agent_loop", "label": "Planning loop", "lane": "agent", "fromCol": 2, "toCol": 3, "variant": "emphasis" },
    { "id": "tool_work", "label": "Tool work", "lane": "tools", "fromCol": 4, "toCol": 5, "variant": "dashed" },
    { "id": "exception_path", "label": "Human or policy stop", "lane": "exceptions", "fromCol": 3, "toCol": 5, "variant": "security" }
  ],
  "mainPath": ["user", "chat", "planner", "router", "approval", "tool", "external", "final"],
  "nodes": [
    { "id": "user", "lane": "ui", "col": 0, "type": "external", "label": "User", "sublabel": "asks for work" },
    { "id": "chat", "lane": "ui", "col": 1, "type": "frontend", "label": "Chat Surface", "sublabel": "thread + files" },
    { "id": "final", "lane": "ui", "col": 5, "type": "backend", "label": "Final Reply", "sublabel": "answer + changes" },
    { "id": "planner", "lane": "agent", "col": 2, "type": "backend", "label": "Agent Planner", "sublabel": "plan next step", "tag": "context aware" },
    { "id": "router", "lane": "agent", "col": 3, "type": "backend", "label": "Tool Router", "sublabel": "choose capability" },
    { "id": "approval", "lane": "policy", "col": 3, "type": "security", "label": "Approval Gate", "sublabel": "scope + consent", "tag": "block risky ops" },
    { "id": "blocked", "lane": "exceptions", "col": 4, "type": "security", "label": "Blocked", "sublabel": "wait or reject" },
    { "id": "retry", "lane": "exceptions", "col": 5, "type": "messagebus", "label": "Retry Path", "sublabel": "revise request" },
    { "id": "tool", "lane": "tools", "col": 4, "type": "messagebus", "label": "Tool Call", "sublabel": "shell / browser / MCP", "tag": "structured result" },
    { "id": "external", "lane": "tools", "col": 5, "type": "cloud", "label": "External API", "sublabel": "network service" },
    { "id": "store", "lane": "trace", "col": 1, "type": "database", "label": "Context Store", "sublabel": "repo + memory" },
    { "id": "trace", "lane": "trace", "col": 4, "type": "database", "label": "Trace Log", "sublabel": "events + output" }
  ],
  "edges": [
    { "id": "request-chat", "from": "user", "to": "chat", "variant": "default" },
    { "id": "plan-request", "from": "chat", "to": "planner", "label": "plan", "variant": "emphasis", "fromSide": "bottom", "toSide": "top", "route": "drop", "labelSegment": 1 },
    { "id": "planner-route", "from": "planner", "to": "router", "variant": "default" },
    { "id": "approval-check", "from": "router", "to": "approval", "label": "needs approval?", "variant": "security", "fromSide": "bottom", "toSide": "top", "route": "drop", "labelSegment": 0, "labelDx": 34, "labelDy": 18 },
    { "id": "approved-tool", "from": "approval", "to": "tool", "variant": "emphasis", "fromSide": "left", "toSide": "left", "route": "return-left" },
    { "id": "approval-denied", "from": "approval", "to": "blocked", "label": "denied", "variant": "security", "role": "error", "fromSide": "bottom", "toSide": "top", "route": "drop", "labelSegment": 1, "labelDy": 12 },
    { "id": "retry-request", "from": "blocked", "to": "retry", "variant": "dashed", "role": "branch" },
    { "id": "tool-external-call", "from": "tool", "to": "external", "variant": "default" },
    { "id": "external-reply", "from": "external", "to": "final", "variant": "emphasis", "role": "return", "fromSide": "right", "toSide": "right", "route": "outside-right", "width": 1.2 },
    { "id": "record-result", "from": "external", "to": "trace", "label": "record result", "variant": "dashed", "fromSide": "bottom", "toSide": "bottom", "route": "bottom-channel", "labelSegment": 1 },
    { "id": "write-trace-memory", "from": "store", "to": "trace", "label": "trace + memory", "variant": "dashed", "labelAt": [365, 735] }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Renderer Rules",
      "items": [
        "Lanes and columns determine node placement",
        "Edges attach to explicit node anchors",
        "Cross-lane paths use orthogonal routing",
        "Short adjacent links stay unlabeled"
      ]
    },
    {
      "dot": "rose",
      "title": "Workflow Semantics",
      "items": [
        "Approval is a first-class policy step",
        "Consent gates are visible in the main path",
        "External calls stay inside the tool lane",
        "Trace writes are separate from the hot path"
      ]
    },
    {
      "dot": "emerald",
      "title": "Why It Matters",
      "items": [
        "This is closer to a diagram_type renderer",
        "The graph can be edited without SVG surgery",
        "Layout rules can be tested and improved",
        "A future IR can reuse this shape directly"
      ]
    }
  ]
}
