Skip to content

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Adaptive Multi-Agent Orchestrator

A lightweight Planner β†’ Executor β†’ Reviewer AI pipeline (FastAPI + Python) β€” fully local, deterministic, and free (uses a MockLLM).


πŸ“‘ Table of Contents


Overview

This repository implements a simple but complete multi-agent architecture where multiple autonomous agents collaborate to solve a user-defined goal. The pipeline includes:

  • Planner Agent β€” converts a high-level goal into actionable, ordered steps.
  • Executor Agent β€” performs each step and produces intermediate outputs.
  • Reviewer Agent β€” evaluates the final result and issues a pass/fail review.
  • Orchestrator β€” central coordinator that submits, runs and monitors tasks.
  • FastAPI backend β€” exposes task APIs for submission and retrieval.
  • Demo script β€” run the full pipeline locally without a frontend or external LLM.

All agents are wired to a MockLLM adapter so the whole system runs offline and deterministically with zero API cost.


🧩 1. Primary Use Case

A user submits a high-level goal, for example:

"Analyze global water scarcity and propose 5 practical solutions."

The system will:

  1. Break the goal into numbered steps (Planner).
  2. Execute each step sequentially and record intermediate results (Executor).
  3. Review and QA the consolidated result (Reviewer).
  4. Return a structured task record including plan, execution outputs, and review.

Typical applications include research assistants, automated planning workflows, educational demonstrations of multi-agent collaboration, and experiments in task decomposition.


πŸ“‚ 2. Project Structure

agents-capstone/
β”œβ”€ app/
β”‚  β”œβ”€ main.py                # FastAPI endpoints
β”‚  β”œβ”€ orchestrator.py        # Task management + agent loop
β”‚  β”œβ”€ llm.py                 # MockLLM (offline), adapter layer
β”‚  β”œβ”€ storage.py             # In-memory task storage
β”‚  β”œβ”€ agents/
β”‚  β”‚  β”œβ”€ planner.py          # Planner agent
β”‚  β”‚  β”œβ”€ executor.py         # Executor agent
β”‚  β”‚  └─ reviewer.py         # Reviewer agent
β”œβ”€ demo.py                   # CLI demo runner
β”œβ”€ requirements.txt          # Python dependencies
β”œβ”€ Dockerfile                # Backend container (optional)
└─ README.md                 # Documentation

πŸ—οΈ 3. System Architecture

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚          Client           β”‚
        β”‚ (curl, frontend, demo.py) β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      POST /tasks
                            β”‚
                            β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚       FastAPI API       β”‚
              β”‚ (app/main.py endpoints) β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚      Orchestrator      β”‚
               β”‚ (Submit, run, monitor) β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β–Ό                        β–Ό                          β–Ό

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Planner β”‚ β”‚ Executor β”‚ β”‚ Reviewer β”‚ β”‚ (steps) β”‚ β”‚ (per step) β”‚ β”‚ (final QA) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                           β–Ό  
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  Task Storage  β”‚
                 β”‚ (in-memory)    β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ 4. Components

MockLLM (app/llm.py)

A lightweight simulated LLM that returns predictable outputs. It avoids external API calls so tests are reproducible and free.

Planner (app/agents/planner.py)

Parses the high-level goal and emits a clear, numbered list of instructions. Output is parsed into an ordered JSON list suitable for the Orchestrator to consume.

Executor (app/agents/executor.py)

Processes each instruction, simulates working on the step (using MockLLM) and produces deterministic reasoning text which becomes part of the task's execution log.

Reviewer (app/agents/reviewer.py)

Inspects the entire execution bundle, drafts a final review summary, and returns a boolean pass/fail along with comments.

Orchestrator (app/orchestrator.py)

Manages task lifecycle: submission, execution, status updates, and result storage. Typical lifecycle statuses: queued β†’ executing β†’ reviewing β†’ done.

FastAPI Backend (app/main.py)

Exposes the following endpoints:

  • POST /tasks β€” submit a new task with a goal JSON field.
  • GET /tasks/{task_id} β€” retrieve task status & results.
  • GET /health β€” basic health check.

Example POST body:

{ "goal": "Analyze global water scarcity" }

Example POST response:

{ "task_id": "abcd-1234", "status": "queued" }

πŸ“¦ 5. Requirements

  • Python 3.11.x (Suggestion: 3.11.9 is a stable version for this project)

Packages requirements.txt:

fastapi==0.95.2
uvicorn==0.22.0
pydantic==1.10.11
python-multipart==0.0.6
numpy==1.26.4
scikit-learn==1.4.2
aiohttp==3.9.5
faiss-cpu==1.7.4  # optional

πŸ› οΈ 6. Installation

git https://github.com/SANJAI-s0/Adaptive-Multi-Agent-Orchestrator-for-Automated-Task-Planning-Execution.git
cd Adaptive-Multi-Agent-Orchestrator-for-Automated-Task-Planning-Execution
python -m venv .venv
source .venv/bin/activate  # Windows PowerShell: .venv\Scripts\Activate.ps1
pip install -r requirements.txt

πŸš€ 7. Running the Project

Option 1 β€” Run the demo (no API)

python demo.py

This will run the Planner β†’ Executor β†’ Reviewer loop locally and print structured, readable output to the console.

Option 2 β€” Start the backend (FastAPI)

uvicorn app.main:app --reload --host 127.0.0.1 --port 8000

Open the interactive docs at: http://127.0.0.1:8000/docs


8. API Workflow Example

  1. Submit a Task
curl -X POST "http://127.0.0.1:8000/tasks" \
     -H "Content-Type: application/json" \
     -d '{"goal":"Analyze global water scarcity"}'

Response:

{"task_id":"abcd-1234","status":"queued"}
  1. Poll for Status
curl "http://127.0.0.1:8000/tasks/abcd-1234"

πŸ“ 9. Example Full Output (Illustrative)

Plan

  1. Research background and collect sources.
  2. Extract key facts and statistics.
  3. Analyze drivers and craft recommendations.
  4. Produce final report with citations.

Execution

  • Step 1: fetched sources
  • Step 2: calculated trend
  • Step 3: analyzed drivers
  • Step 4: produced final report

Review

  • Drafted a 600-word summary and a list of 5 proposed interventions.
  • passed: true

πŸ† 10. Why This Project Is Valuable

  • Demonstrates multi-agent collaboration and task decomposition.
  • Shows chained reasoning in a reproducible, deterministic environment (no API costs).
  • Clean architecture suitable for extension (real LLM adapters, persistent storage, UI).
  • Good fit for educational demos and Kaggle Freestyle-style projects.

βœ”οΈ 11. Extending the Project

Ideas for improvements:

  • Replace MockLLM with a real LLM adapter (OpenAI, Anthropic, etc.) for non-deterministic, high-quality outputs.
  • Add persistent storage (database) instead of in-memory task storage.
  • Add asynchronous/concurrent execution for independent steps.
  • Add authentication and authorization for the API.
  • Build a simple frontend to visualize plan, execution logs, and review results.

12. Contributing

Contributions are welcome. Suggested workflow:

  1. Fork the repo
  2. Create a feature branch
  3. Open a pull request with clear description and tests/examples

13. License

Choose an appropriate license for your project (e.g., MIT). Add a LICENSE file if you publish this repo.


About

A deterministic multi-agent system that plans, executes, and reviews complex tasks using a fully local LLM-simulated pipeline.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages