Skip to content

ssarimm/AutoCrew-Meta-Agent-Research

Repository files navigation

AutoCrew

Automatic Generation of Agentic AI Crews for Financial Modeling Tasks

Final Year Project (BSCS) β€” FAST National University, Karachi
Based on: "Agentic AI Systems for Financial Services" by Okpala et al. (arXiv:2502.05439, 2025)


What is AutoCrew?

AutoCrew extends the base paper by introducing a Meta Agent that automatically generates multi-agent crew configurations from natural language. Instead of hardcoding agents, tasks, and tools in Python, you describe the task in English and the system builds everything dynamically.

The project provides two paths for comparison:

  • Path A (Manual): Hardcoded agents, tasks, and tools β€” replicates the base paper
  • Path B (AutoCrew): Meta Agent generates a JSON config, Crew Factory builds live agents from it

Both paths share the same tools, Human-in-the-Loop (HITL) gate, and CrewAI execution engine. A built-in comparison framework evaluates both side-by-side on accuracy, F1 score, timing, and MRM verdict.


Project Structure

AutoCrew/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py                  # Entry point (manual/auto/compare)
β”‚   β”œβ”€β”€ config.py                # LLM provider setup (Groq/Gemini/Ollama/Mock)
β”‚   β”œβ”€β”€ state.py                 # Shared state between crews
β”‚   β”‚
β”‚   β”œβ”€β”€ meta_agent/              # Path B: Auto crew generation
β”‚   β”‚   β”œβ”€β”€ orchestrator.py      # Chains the 5-step pipeline
β”‚   β”‚   β”œβ”€β”€ task_decomposer.py   # NL task β†’ subtask list
β”‚   β”‚   β”œβ”€β”€ agent_selector.py    # Subtask β†’ agent role + persona
β”‚   β”‚   β”œβ”€β”€ tool_assigner.py     # Agent β†’ tool names from registry
β”‚   β”‚   β”œβ”€β”€ instruction_writer.py# Generate detailed task instructions
β”‚   β”‚   └── json_generator.py    # Assemble crew_config.json
β”‚   β”‚
β”‚   β”œβ”€β”€ crew_factory/            # JSON β†’ live CrewAI objects
β”‚   β”‚   β”œβ”€β”€ crew_builder.py      # Parses JSON, builds Agent/Task/Crew
β”‚   β”‚   └── auto_runner.py       # Runs the auto pipeline end-to-end
β”‚   β”‚
β”‚   β”œβ”€β”€ manual/                  # Path A: Base paper replication
β”‚   β”‚   β”œβ”€β”€ modeling_crew.py     # Hardcoded modeling agents
β”‚   β”‚   β”œβ”€β”€ mrm_crew.py          # Hardcoded MRM agents
β”‚   β”‚   └── manual_runner.py     # Runs the manual pipeline
β”‚   β”‚
β”‚   β”œβ”€β”€ tools/                   # Shared tools (both paths use these)
β”‚   β”‚   β”œβ”€β”€ code_execution.py    # Executes Python scripts
β”‚   β”‚   β”œβ”€β”€ eda_tool.py          # Automated EDA on CSV files
β”‚   β”‚   β”œβ”€β”€ cag_tool.py          # Compliance checking tool
β”‚   β”‚   └── tool_registry.py     # String β†’ tool instance mapping
β”‚   β”‚
β”‚   β”œβ”€β”€ evaluation/              # Comparison & reporting
β”‚   β”‚   β”œβ”€β”€ comparison.py        # Run both paths, compare metrics
β”‚   β”‚   β”œβ”€β”€ metrics_collector.py # Extract accuracy/F1/timing from output
β”‚   β”‚   β”œβ”€β”€ generate_charts.py   # Generate all figures (PNG)
β”‚   β”‚   β”œβ”€β”€ report_generator.py  # Generate PDF report (ReportLab)
β”‚   β”‚   └── terminal_logger.py  # Generate Terminal output 
β”‚   β”‚
β”‚   └── hitl/                    # Human-in-the-loop
β”‚       └── human_gate.py        # Y/N approval gate between phases
β”‚
β”œβ”€β”€ data/                        # Place your datasets here
β”‚   └── .gitkeep
β”‚
β”œβ”€β”€ configs/                     # Auto-generated crew configs
β”‚   └── generated/
β”‚       └── .gitkeep
β”‚
β”œβ”€β”€ prompts/                     # LLM prompt templates
β”‚   β”œβ”€β”€ decompose_task.txt
β”‚   β”œβ”€β”€ select_agents.txt
β”‚   β”œβ”€β”€ assign_tools.txt
β”‚   └── write_instructions.txt
β”‚
β”œβ”€β”€ registries/                  # Agent and tool catalogs
β”‚   β”œβ”€β”€ agent_templates.json
β”‚   └── tool_catalog.json
β”‚
β”œβ”€β”€ tests/
β”‚   └── .gitkeep
β”‚
β”œβ”€β”€ .env                         # API keys (create this yourself)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ requirements.txt
└── README.md

Setup

1. Clone the repository

git clone https://github.com/ssarimm/AutoCrew-Meta-Agent-Research

2. Create virtual environment

python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Add your datasets

Place your CSV datasets in the data/ folder:

# Dataset Source Task
1 credit_card_approval.csv UCI ML Repository Binary classification (approve/reject)
2 creditcard_2023.csv Kaggle Fraud detection (imbalanced)
3 cs-training.csv Kaggle - Give Me Some Credit Credit scoring (financial distress)

5. Set up API keys

Create a .env file in the project root:

# Pick one (or more) LLM provider
#Add Api Keys in `.env` file at root directory 
OPENROUTER_API_KEY=                     

Usage

Run the system

python -m src.main

You'll be prompted to select:

  1. LLM Provider β€” Groq / Gemini / Ollama / Mock / Open Router / Others
  2. Dataset β€” Credit Approval / Fraud Detection / Credit Scoring
  3. Mode:
    • 1 Manual Pipeline (Path A - base paper)
    • 2 AutoCrew Pipeline (Path B - meta agent)
    • 3 Comparison Mode (runs both, generates comparison report)

Outputs

After a run, you'll find:

Location Contents
results/AutoCrew_Report.pdf Full PDF report with charts
results/auto_results_*.json Raw metrics from auto path
results/comparison_*.md Markdown comparison report
results/comparison_*.json Raw comparison data
figures/*.png Generated charts (5 figures)
configs/generated/*.json Auto-generated crew configs

How It Works

Meta Agent Pipeline (Path B)

The Meta Agent converts a natural language task into a complete crew configuration in 5 steps:

"Predict credit approval" 
    β†’ Task Decomposer (subtasks)
    β†’ Agent Selector (roles + personas)
    β†’ Tool Assigner (tools from registry)
    β†’ Instruction Writer (detailed prompts)
    β†’ JSON Generator (crew_config.json)

Each step is one LLM call with structured JSON output. Total time: ~6 seconds on Groq.

Execution Flow

User Input β†’ Meta Agent β†’ crew_config.json β†’ Crew Factory β†’ Modeling Crew β†’ HITL Gate β†’ MRM Crew β†’ Verdict

Tips for Best Results

  • Use credit_card_approval.csv for demos β€” it's small (689 rows) and won't exhaust free this
  • If rate-limited, wait 24 hours or switch to Gemini (higher free tier)
  • Run modes 1 and 2 separately if you want to avoid rate limits during comparison mode

Key Contributions

# Contribution Description
1 Meta Agent LLM-powered 5-step orchestrator for automatic crew creation
2 JSON Config Structured crew_config.json generated from natural language
3 Crew Factory JSON parser that builds live CrewAI Agent/Task/Crew objects
4 Dual-Path Architecture Manual vs Auto for fair, controlled comparison
5 Tool Registry Extensible string-to-tool mapping with validation
6 Evaluation Framework Side-by-side metrics (accuracy, F1, timing, verdict)

Tech Stack

  • Framework: CrewAI + LangChain
  • LLM Routing: LiteLLM
  • ML: scikit-learn, pandas, numpy
  • Reporting: ReportLab (PDF), matplotlib (charts)
  • Language: Python 3.10+

License

This project is part of an academic Final Year Project (FYP) at FAST National University, Karachi.

About

πŸ”¬ Research Project: An automated framework to generate, configure, and evaluate multi-agent AI crews for financial modeling using a Meta-Agent pipeline. This study evaluates the performance of dynamically synthesized MAS (Multi-Agent Systems) against manual expert-defined benchmarks in financial risk contexts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages