This repository houses a powerful, dual-mode multi-agent system built with LangGraph and Langchain Google GenAI. The system is designed to autonomously analyze, review, and write code by orchestrating specialized AI agents.
Both modes utilize Google's Gemini LLMs and structured state-graphs to handle planning, context gathering, and execution.
The system features a single CLI entry point (cli.py) that acts as a router, dropping the user into one of two specialized state graphs based on the mode provided:
- Scan Mode (
--mode scan): Analyzes an existing repository for security vulnerabilities, logic errors, and code quality issues. - Code Mode (
--mode code): An autonomous coding agent that plans out a feature or fix, breaks it into tasks, and iteratively writes code until a reviewer agent approves.
graph TD
%% Nodes
CLI[/"Dragon CLI — cli.py"/]
UserInput(("User Input"))
ChatAgent["Chat Agent — Memory & Query Refinement"]
ModeSwitch{"Mode Selection"}
subgraph ScanGraph ["🔍 Scan Mode (graph.py)"]
Scanner["Project Scanner Agent"]
ScanPlanner["Planner Agent — Strategy"]
Security["Security Agent"]
Logic["Logic Agent"]
Quality["Code Quality Agent"]
Report["Report Aggregator"]
end
subgraph CodeGraph ["💻 Code Mode (code.py)"]
CodePlanner["Code Planner Agent — Task Breakdown"]
Coder["Coding Agent — Workspace Execution"]
Reviewer["Reviewer Agent — Feedback Loop"]
end
FinalOutput[/"Final Result to User"/]
%% Data Flow
UserInput --> CLI
CLI --> ChatAgent
ChatAgent -->|Extracts Goal| ModeSwitch
ModeSwitch -->|--mode scan| Scanner
ModeSwitch -->|--mode code| CodePlanner
%% Scan Flow
Scanner -->|Project Map| ScanPlanner
ScanPlanner -->|Review Plan| Security
ScanPlanner -->|Review Plan| Logic
ScanPlanner -->|Review Plan| Quality
Security --> Report
Logic --> Report
Quality --> Report
Report --> FinalOutput
%% Code Flow
CodePlanner --> Coder
Coder <--> Reviewer
Reviewer --> FinalOutput
%% Styling
classDef io fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a;
classDef core fill:#e0e7ff,stroke:#4338ca,stroke-width:1.5px,color:#312e81;
classDef code_agent fill:#dbeafe,stroke:#1d4ed8,stroke-width:1.5px,color:#1e3a8a;
classDef scan_agent fill:#dcfce7,stroke:#15803d,stroke-width:1.5px,color:#14532d;
classDef data fill:#ffedd5,stroke:#c2410c,stroke-width:1.5px,color:#7c2d12;
class UserInput,CLI,FinalOutput io;
class ChatAgent,ModeSwitch core;
class CodePlanner,Coder,Reviewer code_agent;
class Scanner,ScanPlanner,Security,Logic,Quality,Report scan_agent;
In Scan Mode, the agent system acts as a multi-threaded code reviewer. The state graph passes an AgentState containing the project map, review plan, and individual reports between nodes.
- Input & Chat Memory: The CLI collects the user query and project path. A
Chat Agentrefines the user's raw input into a concise, actionable goal (and respects exclusions, e.g., "Skip security checks"). - Context Gathering: The
Project Scanneruses terminal tools to list files, read directories, and build a high-levelproject_mapof the codebase. - Planning & Routing: The
Planner Agentconsumes the map and query to generate a reviewplan. It also outputs a structured dictionary (agents_required) dictating which specific review agents should run. - Parallel Execution: The state graph uses conditional routing to trigger the
Security,Logic, andCode Qualityagents. These agents run concurrently, each appending their findings to the state. - Aggregation: The
Report Nodeformats the individual reports into a single, comprehensive markdown output.
graph TD
%% Nodes
Input[/"Input: user_query, project_path"/]
Chat["Chat Agent\nRefines Query"]
Scanner["Scanner Agent\nGenerates project_map"]
Planner["Planner Agent\nGenerates plan & agents_required dict"]
Router{"Conditional Router\nChecks agents_required"}
Security["Security Agent\nGenerates security_report"]
Logic["Logic Agent\nGenerates logic_report"]
Quality["Code Quality Agent\nGenerates quality_report"]
Report["Report Node\nCompiles final_report"]
End((END))
%% Connections
Input --> Chat
Chat --> Scanner
Scanner --> Planner
Planner --> Router
Router -->|if security_agent: true| Security
Router -->|if logic_agent: true| Logic
Router -->|if code_quality_agent: true| Quality
Security --> Report
Logic --> Report
Quality --> Report
Router -->|if no agents required| Report
Report --> End
%% Styling
classDef io fill:#e0e7ff,stroke:#4f46e5,stroke-width:2px,color:#1e1b4b;
classDef process fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d;
classDef router fill:#ffedd5,stroke:#ea580c,stroke-width:2px,color:#7c2d12;
classDef report fill:#fae8ff,stroke:#c026d3,stroke-width:2px,color:#4a044e;
class Input,End io;
class Chat,Scanner,Planner,Security,Logic,Quality process;
class Router router;
class Report report;
In Code Mode, the system acts as an autonomous pair programmer. It features an iterative feedback loop where code is written, reviewed, and rewritten until it passes validation.
- Task Breakdown: The
Code Planner Agentlooks at the user query and generates a step-by-step implementation plan. This is converted into an ordered queue oftasks(e.g., [1. Setup Node project, 2. Write UI, 3. Add API integration]). - Execution (Coder): The
Coding Agentis given the current task, the overarching plan, and access to an array of tools (file reading, writing, terminal commands). It executes the task in the actual file system. - Validation (Reviewer): Once the coder finishes, the
Reviewer Agentanalyzes the changes made. It checks if the specific task requirements were met without breaking existing functionality. - Feedback Loop:
- If the reviewer fails the code, it populates
feedback_on_current_task_ifany. The graph routes back to the Coder, which tries again with the feedback in mind. - If the reviewer passes the code,
current_taskis incremented.
- If the reviewer fails the code, it populates
- Completion: This loop repeats until
current_taskexceeds the number of items in the queue, at which point the graph terminates.
graph TD
%% Nodes
Input[/"Input: user_query, working_dir"/]
Planner["Code Planner Agent\nGenerates plan & tasks queue"]
CheckTasks{"Are all tasks\ncompleted?"}
Coder["Coding Agent\nExecutes task using tools\n(reads, writes, terminal)"]
Reviewer["Reviewer Agent\nValidates task completion"]
FeedbackCheck{"Did Review\nPass?"}
UpdateFeedback["State Update:\nProvide Feedback"]
NextTask["State Update:\nIncrement current_task"]
End((END))
%% Flow
Input --> Planner
Planner -->|Initializes plan, tasks,\ncurrent_task=0| CheckTasks
CheckTasks -->|Yes| End
CheckTasks -->|No| Coder
Coder -->|Reads plan, task,\nfeedback, tools| Reviewer
Reviewer --> FeedbackCheck
FeedbackCheck -->|No| UpdateFeedback
UpdateFeedback -->|Passes feedback back to coder| Coder
FeedbackCheck -->|Yes| NextTask
NextTask --> CheckTasks
%% Styling
classDef io fill:#e0e7ff,stroke:#4f46e5,stroke-width:2px,color:#1e1b4b;
classDef agent fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a8a;
classDef condition fill:#fef08a,stroke:#ca8a04,stroke-width:2px,color:#713f12;
classDef state_update fill:#d1fae5,stroke:#059669,stroke-width:2px,color:#064e3b;
class Input,End io;
class Planner,Coder,Reviewer agent;
class CheckTasks,FeedbackCheck condition;
class UpdateFeedback,NextTask state_update;
Execute the vulnerability scanner or the coding agent using the Dragon CLI. The CLI features rich progress spinners and interactive prompts.
# Scan Mode (Vulnerability & Quality analysis)
python cli.py --mode scan -q "Find bugs" -p /path/to/project
# Code Mode (Autonomous coding & building)
python cli.py --mode code -q "Build a tic tac toe app" -p /path/to/project
# Interactive Mode (Prompts for inputs)
python cli.py --mode code(Make sure to specify a valid absolute or relative path to your project).
Create a .env file in the root directory with the following variables:
GOOGLE_API_KEY_1=
GOOGLE_API_KEY_2=
GOOGLE_API_KEY_3=
GOOGLE_API_KEY=
SERPAPI_API_KEY=
OPENROUTER_API_KEY=
GROQ_API_KEY=
AGENT_WORKING_DIR=
LANGSMITH_TRACING=
LANGSMITH_API_KEY=
LANGSMITH_PROJECT=
CODEGUARD_AUTO_APPROVE=1This project is open-source. Feel free to use and modify the agents for your personal workflows.