{
  "nodes": [
    {
      "id": "loop-rows",
      "type": "loop",
      "position": {
        "x": 300,
        "y": 200
      },
      "config": {
        "csv_delimiter": ",",
        "csv_has_headers": true,
        "csv_iteration_mode": "rows",
        "max_iterations": 10,
        "source_type": "auto",
        "items": "{{parsed_csv}}",
        "iterator_variable": "current_row",
        "source_variable": "input.csv_file"
      },
      "label": "Loop Rows",
      "key": ""
    },
    {
      "id": "process-row",
      "type": "llm",
      "position": {
        "x": 625.166194744251,
        "y": 104.04945816781402
      },
      "config": {
        "file_variables": "",
        "is_terminal": false,
        "live_search": 0,
        "model": "gpt-5.4",
        "persona": 1,
        "temperature": 0.3,
        "prompt_template": "Process this current row: {{loop.item}}\n\nInstructions: {{input.processing_instructions}}\n\nOutput as a single CSV row with these new columns added to the original data:\n- Analysis_Result\n- Score\n- Recommendation\n\nFormat: original_col1,original_col2,...,Analysis_Result,Score,Recommendation"
      },
      "label": "Process Row",
      "key": ""
    },
    {
      "id": "format-output",
      "type": "llm",
      "position": {
        "x": 626.5740264182184,
        "y": 319.3532791812898
      },
      "config": {
        "file_variables": "",
        "is_terminal": false,
        "live_search": 0,
        "model": "gpt-5.4",
        "persona": 1,
        "temperature": 0,
        "prompt_template": "Combine these processed rows into a properly formatted CSV with headers, followed by an overall portfolio analysis.\n\n**Processed Rows:**\n{{loop.results}}\n\n**Processing Context:**\n{{input.processing_instructions}}\n\n## Part 1: CSV Output\nOutput a clean CSV table with:\n1. Header row first\n2. All data rows\n3. Proper comma separation\n4. Quoted values if they contain commas\n\n## Part 2: Overall Analysis\nAfter the CSV table, provide a comprehensive portfolio-level summary that includes:\n1. **Overview**: Total number of records processed and key aggregate metrics (totals, averages)\n2. **Top Risks**: Identify the 3 lowest-scoring records and explain why they are the highest priority\n3. **Top Performers**: Identify the 3 highest-scoring records and what makes them stand out\n4. **Trends & Patterns**: Any cross-record patterns, common issues, or notable outliers\n5. **Portfolio Recommendation**: One strategic recommendation for senior leadership based on the full dataset"
      },
      "label": "Format as CSV",
      "key": ""
    },
    {
      "id": "return-response",
      "type": "flat_response",
      "position": {
        "x": 1039.783955739065,
        "y": 323.4998275528533
      },
      "config": {
        "response_type": "text",
        "response_template": "# CSV Processing Complete\n\n## Output CSV\n\n{{format-output.response}}\n\n---\n\n*Copy the CSV above or download as a file.*"
      },
      "label": "Return Response",
      "key": ""
    }
  ],
  "edges": [
    {
      "id": "edge-3",
      "source": "loop-rows",
      "target": "process-row",
      "sourceHandle": "loop",
      "targetHandle": "in"
    },
    {
      "id": "edge-4",
      "source": "loop-rows",
      "target": "format-output",
      "sourceHandle": "aggregated",
      "targetHandle": "in"
    },
    {
      "id": "xy-edge__loop-rowsiteration-process-rowin",
      "source": "loop-rows",
      "target": "process-row",
      "sourceHandle": "iteration",
      "targetHandle": "in"
    },
    {
      "id": "xy-edge__format-outputout-return-responsein",
      "source": "format-output",
      "target": "return-response",
      "sourceHandle": "out",
      "targetHandle": "in"
    },
    {
      "id": "xy-edge__loop-rowscomplete-format-outputin",
      "source": "loop-rows",
      "target": "format-output",
      "sourceHandle": "complete",
      "targetHandle": "in"
    }
  ],
  "agent_config": {
    "version": 1,
    "agent": {
      "name": "CSV Data Query",
      "description": "",
      "agent_mode": "single",
      "primary_workflow_uuid": null,
      "system_prompt": "",
      "model": "auto",
      "temperature": 1,
      "variables": {
        "csv_file": {
          "default": "",
          "type": "file"
        },
        "processing_instructions": {
          "default": "Analyze each facility's fiscal health. Calculate the obligation rate (YTD_Obligations / FY2025_Enacted), expenditure rate (YTD_Expenditures / YTD_Obligations), staffing fill rate (FTEs_Onboard / FTEs_Authorized), and outsourced service leakage rate (Outsourced_Services / Direct_Service_Volume). Flag any facility with an obligation rate below 88%, staffing fill rate below 85%, or outsourced leakage above 8%. In Analysis_Result, summarize the facility's financial and operational posture. Provide a Score from 1-10 (10 = excellent). In Recommendation, give one corrective action for the facility's financial manager.",
          "type": "text"
        }
      }
    }
  }
}
