An advanced, Web-based application for comprehensive code analysis. This platform orchestrates a team of specialized Large Language Model (LLM) agents to provide deep, structured, and actionable feedback on code quality, security, performance, and architecture.
Built with a Python (Flask) backend for orchestration and a single-page application (SPA) frontend for a responsive, desktop-like user experience.
The primary goal is to move beyond simple keyword-based analysis by enforcing a structured analysis output. The system uses Pydantic to strictly constrain the LLMs, forcing them to produce reliable, machine-readable JSON reports.
This structured approach ensures:
- Reliability: Reports are guaranteed to match a defined schema, making them easy for the frontend to consume.
- Actionability: Every finding includes specific fields like
severity,issue_type, andlinenumber. - Depth: All analysis reports inherit from
BaseLLMResponse, which requires a highly detailed, Markdown-formattedMarkdownDescriptionfield, ensuring every result comes with a comprehensive, human-readable explanation.
The platform employs a robust system of nine specialized LLM agents, each strictly constrained by its unique system_prompt and Pydantic schema to deliver reliable, structured reports.
| Category | Agent Name | Core Focus Area | Output Schema | System Prompt Focus |
|---|---|---|---|---|
| Foundation | Summarizer | High-level, neutral explanation of the code's purpose and component roles. | SummaryResponse |
Neutrality, Clarity, Functionality. |
| Static Analysis | Code Smell | Identifies anti-patterns: Long Methods, Magic Numbers, Poor Naming, duplication. | CodeSmellReport |
Maintainability, Readability, Refactoring Candidates. |
| Complexity | Measures code difficulty using metrics like Cyclomatic Complexity and deep nesting. | ComplexityReport |
Cognitive Load and Testability. | |
| Dependency | Flags unused imports, deprecated/outdated packages, and unpinned dependencies. | DependencyReport |
Security, Stability, and Build Reliability. | |
| Quality & Design | SOLID | Analyzes adherence to the fundamental SOLID object-oriented principles. | SolidReport |
Interface segregation, Single Responsibility, Liskov Substitution. |
| Architecture | Focuses on structural issues: Tight Coupling, Low Cohesion, Layer Violations, God Classes. | ArchitectureReport |
Scalability, Modularity, and Extensibility. | |
| Refactor | Provides practical, human-friendly, and actionable suggestions for code improvement. | RefactorReport |
Practical, Developer-friendly Code Improvements. | |
| Risk & Performance | Security | Detects critical vulnerabilities: Injection, Hardcoded Secrets, Path Traversal, weak cryptography. | SecurityReport |
Real-world exploitation, OWASP Top 10, Secure Coding Practices. |
| Performance | Pinpoints runtime bottlenecks: O(n²) behavior, inefficient data structures, caching issues, blocking I/O. | PerformanceReport |
Algorithmic Complexity, Runtime Efficiency, Resource Usage. |
The backend manages job state, file I/O, configuration, and coordinates the LLM calls.
app.py: The main entry point. It sets up the Flask application and handles routing. Crucially, it integrates the Hybrid Threading Model to facilitate native file dialogs (see Key Technologies).analysis_orchestration.py: The Analysis Orchestrator. This class is the core of the analysis workflow:- Job Management: It starts and tracks batch analysis jobs, maintaining real-time
statusandprogress. - Reliability: It enforces retry logic (default 3 attempts) for transient LLM errors or malformed JSON responses, ensuring high job completion rates.
- Concurrency: It executes agents in a non-blocking, multi-threaded batch, allowing the UI to remain responsive during long-running LLM calls.
- Job Management: It starts and tracks batch analysis jobs, maintaining real-time
base_agent.py: Defines the BaseAgent class from which all LLM agents inherit. It abstracts thepydantic-ailibrary, enforcing thesystem_promptandoutput_typefor every agent instance.llm_loader.py: An abstraction layer that resolves the correct LLM provider (e.g., Google, OpenAI, local Ollama) based on the centralized configuration inllm_config.yaml.
A fast, responsive Single-Page Application designed to feel like a desktop IDE, using vanilla JavaScript for efficiency.
- UI Components:
- File Tree: Navigation sidebar for selecting files within the project root.
- Code Editor: Resizable panel for viewing code.
- Analysis Results: Tabbed view for displaying structured JSON reports and their corresponding
MarkdownDescription. - Run Modal: Non-blocking modal for starting, tracking, and cancelling batch analysis jobs, featuring a real-time progress bar and log stream.
- Styling & Theme: Uses Tailwind CSS for utility-first styling and a custom VS Code-like dark theme (
styles.css) for a familiar developer experience. - State Management:
store.jsmanages global variables (projectRoot,currentFile,agentResults) and provides data persistence across sessions.
Follow these steps to set up and run the Code Analysis Studio locally.
- Python 3.9+
- A stable internet connection (for cloud LLM) or a local Ollama installation.
- A valid API Key for your chosen cloud LLM provider (e.g., Google Gemini).
Clone the repository and install dependencies.
# Clone the repository
git clone https://github.com/DeepActionPotential/AgentsStudio
cd multi-agent-ai-code-review
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt Set your LLM connection details and core analysis parameters.
-
LLM Provider: Configure your API access in
src/config/llm_config.yaml.- Set
default_llm_type: cloudand provide yourapi_keyunder thecloudsection. - Alternatively, set
default_llm_type: localand configure theidandbase_urlfor your local Ollama instance. (Configuration updates can also be done via thesettings.htmlUI).
- Set
-
Analysis Parameters: Review
src/config/analysis_config.yamlfor key limits:max_file_size_kb: 300: The file size limit for LLM processing.file_loader.pyenforces this check to prevent oversized API requests.timeout.seconds: 40: The maximum time an individual agent is allowed to execute.
# analysis_config.yaml snippet
max_file_size_kb: 300
retry:
attempts: 3
timeout:
seconds: 40 Start the Flask development server:
python app.pyThe console will confirm the dual-thread startup:
🚀 Server running on http://127.0.0.1:5000 (Flask in background thread) Tk dialog handler running on the main thread. Press Ctrl+C to stop.
-
Open your browser and navigate to the local address (
http://127.0.0.1:5000). -
Click "Open Folder" to trigger the native OS folder dialog (handled by the main thread). Select your project root.
-
The File Tree will populate. Select files for analysis.
-
Run a Batch Analysis from the modal. Monitor the progress bar and real-time logs (Errors, Warnings, Success messages).
-
View results. Click on the tab for any file/agent combination to see the detailed JSON report and the associated
MarkdownDescription.
| Issue | Root Cause & Code Component | Solution |
|---|---|---|
| LLM Timeout | The LLM exceeded the configured timeout.seconds (default 40s) during a complex or large file analysis. |
Increase timeout.seconds in analysis_config.yaml. Break up very large files or review code complexity. |
| Malformed JSON / Retry Failure | The LLM failed to produce output strictly conforming to the required Pydantic schema after all retry.attempts. |
Try a higher-tier LLM (e.g., a "Pro" or "Turbo" model) known for better instruction following. Check the agent's system_prompt for clarity. |
| File Skipped | The file exceeded the max_file_size_kb limit (default 300KB) or had a disallowed extension. |
Increase max_file_size_kb in analysis_config.yaml. The file_loader.py module enforces this. |
| Native Folder Dialog Not Appearing | This is typically a failure in the Hybrid Threading Model where the main process is blocked or the tkinter library is not fully functional on the system (e.g., in a non-GUI environment). |
Ensure all tkinter dependencies are installed for your OS. If running headless, ensure you have a configured X-server (or use a remote desktop GUI). |
| Configuration Not Saving | Errors in updating llm_config.yaml from the Settings UI. |
Verify that src/logic/utils/config_editor.py can correctly load/save the YAML without permission errors. The ruamel.yaml library is used to preserve file formatting. |
The primary technical challenge of building a web application that needs to access the local file system (to load source code) is solved by this hybrid model.
- Limitation: A web browser cannot securely initiate a file dialog to read an arbitrary local directory path without user interaction.
- Solution: The application runs Flask (Web UI) in a background daemon thread and reserves the Main Thread for a hidden Tkinter instance.
- Workflow: When the user clicks "Open Folder" in the browser:
- The Flask endpoint receives the request.
- Flask places a message into a thread-safe
queue.Queue. - The main thread's
handle_dialogs()function constantly listens to this queue. - The main thread executes
tkinter.filedialog.askdirectory(), which presents the native OS dialog. - The selected path is returned via a different queue to the Flask thread, which then begins scanning and loading files.
This platform relies heavily on the pydantic-ai library to guarantee output quality.
- Agent Constraint: Every LLM agent (e.g.,
SecurityAgent,PerformanceAgent) defines a Pydanticoutput_type. - Model Guidance: The agent's
system_promptand the Pydantic schema are sent to the LLM, instructing it to produce a JSON object strictly conforming to that schema. - Validation: If the LLM returns non-conforming JSON, the
pydantic-aivalidation fails, triggering theAnalysisOrchestrator's retry mechanism for reliability.







