{
  "synapse_export": true,
  "version": "1.0",
  "exported_at": "2026-09-09T00:01:06.893021+00:00",
  "has_python_tools": false,
  "custom_tools": [],
  "agents": [
    {
      "id": "agent_site_sql_analyst",
      "name": "SQL Analyst",
      "description": "Drafts read-only SQL against the tables in scope, and explains results in plain language.",
      "avatar": "default",
      "type": "conversational",
      "tools": [
        "list_tables",
        "get_table_schema",
        "run_sql_query"
      ],
      "repos": [],
      "system_prompt": "You write one read-only SQL query that answers a question. Read the schema of the tables the question needs with get_table_schema first. Reply with the SQL only: one SELECT statement, with a LIMIT, no comments and no explanation."
    }
  ],
  "orchestrations": [
    {
      "id": "orch_site_database_qa",
      "name": "Database Question Answering",
      "description": "A plain-language question becomes one read-only query: a model drafts it from the schema, a second step checks it is a bounded SELECT, it runs with writes refused, and the answer comes back with the query that produced it. No rows? It asks you to narrow the question.",
      "avatar": "default",
      "steps": [
        {
          "id": "d_scope",
          "name": "List the tables",
          "type": "tool",
          "position_x": 40,
          "position_y": 190,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "max_turns": 15,
          "next_step_id": "d_draft",
          "forced_tool": "list_tables",
          "prompt_template": "List the tables in the database.",
          "output_key": "tables",
          "agent_id": "agent_site_sql_analyst"
        },
        {
          "id": "d_draft",
          "name": "Draft the SQL",
          "type": "agent",
          "position_x": 340,
          "position_y": 190,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "input_keys": [
            "question",
            "tables"
          ],
          "max_turns": 15,
          "next_step_id": "d_validate",
          "agent_id": "agent_site_sql_analyst",
          "prompt_template": "Question: {state.question}\n\nTables: {state.tables}",
          "output_key": "sql",
          "allowed_tools": [
            "list_tables",
            "get_table_schema"
          ]
        },
        {
          "id": "d_validate",
          "name": "Validate the query",
          "type": "evaluator",
          "position_x": 640,
          "position_y": 190,
          "route_map": {
            "safe": "d_run",
            "rewrite": "d_draft"
          },
          "route_descriptions": {
            "safe": "One SELECT, listed tables only, has a LIMIT, answers the question",
            "rewrite": "Writes data, several statements, other tables, no LIMIT, or off the question"
          },
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "input_keys": [],
          "max_turns": 15,
          "next_step_id": null,
          "evaluator_prompt": "Is this one read-only SELECT statement with a LIMIT, using only tables listed here, that answers the question?\n\nQuestion: {state.question}\n\nTables: {state.tables}\n\nSQL: {state.sql}"
        },
        {
          "id": "d_run",
          "name": "Run it, writes refused",
          "type": "tool",
          "position_x": 940,
          "position_y": 190,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "input_keys": [
            "sql"
          ],
          "max_turns": 15,
          "next_step_id": "d_any_rows",
          "forced_tool": "run_sql_query",
          "prompt_template": "Run exactly this SQL, unchanged:\n\n{state.sql}",
          "output_key": "rows",
          "agent_id": "agent_site_sql_analyst"
        },
        {
          "id": "d_any_rows",
          "name": "Any rows?",
          "type": "if_else",
          "position_x": 1240,
          "position_y": 190,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "input_keys": [],
          "max_turns": 15,
          "next_step_id": null,
          "if_condition": "str(state.rows).strip() not in ('', '[]') and not str(state.rows).startswith('Error') and not str(state.rows).startswith('BLOCKED')",
          "if_true_step_id": "d_explain",
          "if_false_step_id": "d_clarify"
        },
        {
          "id": "d_explain",
          "name": "Explain the answer, show the SQL",
          "type": "llm",
          "position_x": 1540,
          "position_y": 40,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [],
          "input_keys": [],
          "max_turns": 15,
          "next_step_id": null,
          "prompt_template": "Answer the question in plain words from these rows, then show the SQL that produced them.\n\nQuestion: {state.question}\n\nRows: {state.rows}\n\nSQL: {state.sql}",
          "output_key": "answer"
        },
        {
          "id": "d_clarify",
          "name": "Ask the person to narrow it",
          "type": "human",
          "position_x": 1540,
          "position_y": 340,
          "route_map": {},
          "route_descriptions": {},
          "parallel_branches": [],
          "loop_step_ids": [],
          "human_fields": [
            {
              "name": "question",
              "type": "text",
              "label": "The question, narrowed or changed"
            }
          ],
          "input_keys": [],
          "max_turns": 15,
          "next_step_id": "d_apply",
          "human_prompt": "No rows came back for: {state.question}\n\nThe query was: {state.sql}\n\nHow should the question change?",
          "output_key": "clarified"
        },
        {
          "id": "d_apply",
          "name": "Use the new question",
          "type": "print",
          "position_x": 1240,
          "position_y": 340,
          "max_turns": 15,
          "next_step_id": "d_draft",
          "print_content": "{state.clarified.question}",
          "output_key": "question"
        }
      ],
      "entry_step_id": "d_scope",
      "state_schema": {
        "question": {
          "type": "string",
          "default": "",
          "description": "The question, in plain language"
        }
      },
      "max_total_turns": 100,
      "timeout_minutes": 30,
      "trigger": "manual",
      "created_at": "2026-09-09T00:01:06.893021+00:00",
      "updated_at": "2026-09-09T00:01:06.893021+00:00",
      "result_key": "answer"
    }
  ],
  "mcp_servers": []
}
