Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent

A modular LangGraph team that answers a task by routing work through specialist agents.

The supervisor decides who works next. A researcher gathers notes, a writer drafts the answer, and a reviewer approves it or sends it back for revision.

START → supervisor → researcher → writer → reviewer → finish → END
                         ↑                      |
                         └──── revise (optional)┘

Requirements

  • Python 3.10+
  • A Metis or OpenAI-compatible API key

Setup

pip install -r requirements.txt

Copy the example env file (or edit the existing .env) and put a real API key in it:

copy .env.example .env
METIS_API_KEY=
OPENAI_API_KEY=
OPENAI_BASE_URL=https://api.metisai.ir/openai/v1
LLM_MODEL=gpt-4o-mini
LLM_TEMPERATURE=0
MAX_REVISIONS=2
RECURSION_LIMIT=25

Set METIS_API_KEY or OPENAI_API_KEY. A placeholder such as your-metis-api-key will not work.

The default API base URL is https://api.metisai.ir/openai/v1. Override it with OPENAI_BASE_URL or METIS_BASE_URL if you use another endpoint.

Usage

One-shot:

python main.py "Explain how LangGraph supervisor agents work"

Interactive session:

python main.py

Type a task, or exit / quit to leave.

Hide node progress logs:

python main.py --quiet "Summarize the difference between agents and workflows"

How it works

  1. Supervisor reads shared state and picks the next worker: researcher, writer, reviewer, or finish.
  2. Researcher collects structured notes for the task.
  3. Writer turns those notes (and any review feedback) into a draft.
  4. Reviewer approves the draft or requests changes.
  5. Finish delivers final_answer.

If structured routing fails, the supervisor falls back to simple rules (research first, then write, then review). Revisions stop after MAX_REVISIONS (default 2) so the graph cannot loop forever.

Project layout

config/          Env-based settings
models/          Shared AgentState and Pydantic schemas
prompts/         System and user prompts
agents/          One module per worker
graph/           Graph wiring, routing, and run_task
utils/           LLM factory and logging
main.py          CLI entry point

Call the team from code:

from graph.runner import run_task

result = run_task("What is a LangGraph state graph?")
print(result["final_answer"])

Configuration

Variable Default Purpose
METIS_API_KEY Preferred API key
OPENAI_API_KEY Fallback API key
OPENAI_BASE_URL / METIS_BASE_URL https://api.metisai.ir/openai/v1 OpenAI-compatible endpoint
LLM_MODEL gpt-4o-mini Chat model
LLM_TEMPERATURE 0 Sampling temperature
MAX_REVISIONS 2 Reviewer rewrite limit
RECURSION_LIMIT 25 LangGraph step limit

Extending

  1. Add a node in agents/.
  2. Register it in graph/builder.py.
  3. Teach the supervisor the new name in models/schemas.py and prompts/templates.py.
  4. Update graph/routing.py so the supervisor can send work there.

About

Multi-agent LangGraph system with supervisor/researcher/writer/reviewer routing, structured state, OpenAI-compatible LLMs and bounded revision logic.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages