$ python graph_demo.py faq
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_faq",
      "intent": "faq",
      "topic": "hours"
    },
    "route": "research",
    "evidence": {
      "source_id": "demo-hours",
      "text": "Учебная мастерская работает с 10:00 до 18:00 по будням."
    },
    "review_ok": true,
    "reason": "source_match",
    "answer": "Учебная мастерская работает с 10:00 до 18:00 по будням.",
    "status": "completed_local",
    "path": [
      "router",
      "research",
      "reviewer",
      "finish"
    ]
  },
  "next": [],
  "interrupts": [],
  "checkpoint_count": 6,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py price
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_price",
      "intent": "faq",
      "topic": "price"
    },
    "route": "research",
    "evidence": {
      "source_id": "demo-price",
      "text": "Учебная консультация стоит 1200 рублей. Это вымышленная цена для примера."
    },
    "review_ok": true,
    "reason": "source_match",
    "answer": "Учебная консультация стоит 1200 рублей. Это вымышленная цена для примера.",
    "status": "completed_local",
    "path": [
      "router",
      "research",
      "reviewer",
      "finish"
    ]
  },
  "next": [],
  "interrupts": [],
  "checkpoint_count": 6,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py missing
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_missing",
      "intent": "faq",
      "topic": "missing"
    },
    "route": "research",
    "evidence": null,
    "review_ok": false,
    "reason": "missing_or_mismatched_source",
    "answer": null,
    "status": "running_local",
    "path": [
      "router",
      "research",
      "reviewer"
    ]
  },
  "next": [
    "human"
  ],
  "interrupts": [
    {
      "request_id": "demo_missing",
      "reason": "missing_or_mismatched_source",
      "allowed_decisions": [
        "close",
        "keep_for_human"
      ],
      "external_action": false
    }
  ],
  "checkpoint_count": 5,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py change
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_change",
      "intent": "change",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "running_local",
    "path": [
      "router"
    ]
  },
  "next": [
    "human"
  ],
  "interrupts": [
    {
      "request_id": "demo_change",
      "reason": "not_read_only_faq",
      "allowed_decisions": [
        "close",
        "keep_for_human"
      ],
      "external_action": false
    }
  ],
  "checkpoint_count": 3,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py unknown
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_unknown",
      "intent": "unknown",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "running_local",
    "path": [
      "router"
    ]
  },
  "next": [
    "human"
  ],
  "interrupts": [
    {
      "request_id": "demo_unknown",
      "reason": "not_read_only_faq",
      "allowed_decisions": [
        "close",
        "keep_for_human"
      ],
      "external_action": false
    }
  ],
  "checkpoint_count": 3,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py change --decision close
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_change",
      "intent": "change",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "running_local",
    "path": [
      "router"
    ]
  },
  "next": [
    "human"
  ],
  "interrupts": [
    {
      "request_id": "demo_change",
      "reason": "not_read_only_faq",
      "allowed_decisions": [
        "close",
        "keep_for_human"
      ],
      "external_action": false
    }
  ],
  "checkpoint_count": 3,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}
{
  "phase": "after_resume",
  "state": {
    "request": {
      "request_id": "demo_change",
      "intent": "change",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "closed_without_action",
    "path": [
      "router",
      "human",
      "finish"
    ]
  },
  "next": [],
  "interrupts": [],
  "checkpoint_count": 5,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py change --decision keep_for_human
exit=0
{
  "phase": "after_start",
  "state": {
    "request": {
      "request_id": "demo_change",
      "intent": "change",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "running_local",
    "path": [
      "router"
    ]
  },
  "next": [
    "human"
  ],
  "interrupts": [
    {
      "request_id": "demo_change",
      "reason": "not_read_only_faq",
      "allowed_decisions": [
        "close",
        "keep_for_human"
      ],
      "external_action": false
    }
  ],
  "checkpoint_count": 3,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}
{
  "phase": "after_resume",
  "state": {
    "request": {
      "request_id": "demo_change",
      "intent": "change",
      "topic": "hours"
    },
    "route": "human",
    "review_ok": false,
    "reason": "not_read_only_faq",
    "answer": null,
    "status": "needs_human",
    "path": [
      "router",
      "human",
      "finish"
    ]
  },
  "next": [],
  "interrupts": [],
  "checkpoint_count": 5,
  "storage": "in_memory_only",
  "model_calls": 0,
  "external_writes": 0,
  "authenticated": false
}

$ python graph_demo.py faq --force-cycle --recursion-limit 6
exit=2
{
  "ok": false,
  "error": "graph_recursion_limit",
  "partial": {
    "state": {
      "request": {
        "request_id": "demo_faq",
        "intent": "faq",
        "topic": "hours"
      },
      "route": "research",
      "evidence": {
        "source_id": "demo-hours",
        "text": "Учебная мастерская работает с 10:00 до 18:00 по будням."
      },
      "review_ok": true,
      "reason": "source_match",
      "answer": null,
      "status": "running_local",
      "path": [
        "router",
        "research",
        "reviewer",
        "research",
        "reviewer",
        "research"
      ]
    },
    "next": [
      "reviewer"
    ],
    "interrupts": [],
    "checkpoint_count": 8,
    "storage": "in_memory_only",
    "model_calls": 0,
    "external_writes": 0,
    "authenticated": false
  }
}

$ python graph_demo.py faq --recursion-limit 1
exit=2
{
  "ok": false,
  "error": "graph_recursion_limit",
  "partial": {
    "state": {
      "request": {
        "request_id": "demo_faq",
        "intent": "faq",
        "topic": "hours"
      },
      "route": "research",
      "review_ok": false,
      "reason": "needs_lookup",
      "answer": null,
      "status": "running_local",
      "path": [
        "router"
      ]
    },
    "next": [
      "research"
    ],
    "interrupts": [],
    "checkpoint_count": 3,
    "storage": "in_memory_only",
    "model_calls": 0,
    "external_writes": 0,
    "authenticated": false
  }
}
