{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "JAZ: tail-recursive delegation trên StuLife",
    "quality_profile": "showcase",
    "viewBox": [
      930,
      530
    ],
    "views": [
      {
        "id": "delegate",
        "label": "Giao việc không mất dữ liệu",
        "focus": [
          "top",
          "hook",
          "sub"
        ],
        "note": "Context gần đầy thì giao phần còn lại cho sub-invoke, truyền lịch sử theo tham chiếu."
      },
      {
        "id": "recall",
        "label": "Nhớ xa bằng code",
        "focus": [
          "sub",
          "repl"
        ],
        "note": "Subagent tìm chính xác trong prev_history thay vì search keyword/vector."
      }
    ],
    "column_fit": "spread",
    "legend": {
      "mode": "hidden"
    }
  },
  "participants": [
    {
      "id": "env",
      "type": "external",
      "label": "StuLife",
      "sublabel": "1284 task"
    },
    {
      "id": "top",
      "type": "backend",
      "label": "invoke",
      "sublabel": "agent hiện tại"
    },
    {
      "id": "hook",
      "type": "security",
      "label": "Hook",
      "sublabel": "ContextWindowWarning"
    },
    {
      "id": "sub",
      "type": "backend",
      "label": "sub-invoke",
      "sublabel": "agent kế tiếp"
    },
    {
      "id": "repl",
      "type": "database",
      "label": "REPL",
      "sublabel": "biến trong REPL"
    }
  ],
  "segments": [
    {
      "from": 154,
      "to": 220,
      "label": "Làm việc"
    },
    {
      "from": 236,
      "to": 302,
      "label": "Giao việc"
    },
    {
      "from": 318,
      "to": 452,
      "label": "Nhớ xa"
    }
  ],
  "messages": [
    {
      "from": "env",
      "to": "top",
      "y": 176,
      "label": "task tiếp theo",
      "variant": "emphasis"
    },
    {
      "from": "top",
      "to": "repl",
      "y": 210,
      "label": "code + tool, lưu __history__",
      "variant": "default"
    },
    {
      "from": "hook",
      "to": "top",
      "y": 258,
      "label": "context gần đầy: delegate",
      "variant": "security"
    },
    {
      "from": "top",
      "to": "sub",
      "y": 292,
      "label": "prev_history + __history__",
      "variant": "emphasis"
    },
    {
      "from": "env",
      "to": "sub",
      "y": 340,
      "label": "câu hỏi thi #1282",
      "variant": "emphasis"
    },
    {
      "from": "sub",
      "to": "repl",
      "y": 374,
      "label": "tìm tên protocol",
      "variant": "default"
    },
    {
      "from": "repl",
      "to": "sub",
      "y": 408,
      "label": "bài giảng task #785",
      "variant": "return"
    },
    {
      "from": "sub",
      "to": "env",
      "y": 442,
      "label": "đáp án đúng",
      "variant": "return"
    }
  ],
  "activations": [
    {
      "participant": "top",
      "from": 170,
      "to": 300,
      "type": "backend"
    },
    {
      "participant": "sub",
      "from": 286,
      "to": 450,
      "type": "backend"
    },
    {
      "participant": "repl",
      "from": 368,
      "to": 416,
      "type": "database"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Truyền theo tham chiếu",
      "items": [
        "Lịch sử đầy đủ đi qua biến, không chép vào prompt",
        "Một lần chạy: độ sâu 70 sau 69 lần giao việc"
      ]
    },
    {
      "dot": "rose",
      "title": "Baseline sai ở đâu",
      "items": [
        "CodeAct+subagents: chép prompt qua nhiều tầng, mất hướng dẫn",
        "Letta: search keyword/vector trả nhầm protocol"
      ]
    }
  ]
}
