DEV Community

Cover image for Multi-Agent Code Review System
PIYUSH KASHYAP
PIYUSH KASHYAP

Posted on

Multi-Agent Code Review System

Agentic Postgres Challenge Submission

Agentic Postgres Challenge Submission

This is a submission for the Agentic Postgres Challenge with Tiger Data

What I Built

I built a Multi-Agent Code Review System - an experimental AI-powered code review platform that leverages Agentic Postgres capabilities to enable multiple AI agents to review code simultaneously using database forks, semantic code search, and collaborative review processes.

The system demonstrates how Postgres can become the "brain" of AI systems by:

  • Using pg_text search for semantic code pattern matching
  • Implementing fast, zero-copy forks for parallel agent processing
  • Creating a multi-agent collaboration system where different agents (Security, Performance, Quality, Best Practices) work in parallel
  • Utilizing hybrid search combining vector similarity with traditional text search

Inspiration: Traditional code review tools are slow and sequential. I wanted to showcase how Agentic Postgres could enable parallel, intelligent code analysis where multiple specialized agents collaborate simultaneously, each working on their own database fork.

Demo

Repository: https://github.com/piyushkashyap07/multi-agent-code-review

Live Demo: Run locally - see setup instructions in the repository README

Video Demo

How I Used Agentic Postgres

1. pg_text Search for Semantic Code Search

I implemented semantic code search using PostgreSQL's pg_trgm extension for fuzzy text matching. The system indexes code chunks and allows developers to search their codebase using natural language queries (e.g., "authentication logic", "database connection handling"). This enables developers to find similar code patterns even when exact matches don't exist.

Implementation: semantic_search.py uses similarity() function from pg_trgm to match code snippets with similarity scores, enabling semantic search across the entire codebase.

2. Fast, Zero-Copy Forks for Multi-Agent Processing

Each review agent gets its own database fork ID, enabling parallel processing without interference. While the full fork functionality would require Tiger Cloud's fork API, I've simulated this architecture where:

  • SecurityBot works on fork_SecurityBot_[id]
  • PerfBot works on fork_PerfBot_[id]
  • QualityBot works on fork_QualityBot_[id]
  • BestPracticesBot works on fork_BestPracticesBot_[id]

Each agent stores its review results independently, demonstrating how forks enable isolation and parallel processing.

Implementation: agents.py creates unique fork IDs for each agent and stores reviews with fork metadata, simulating the fork-based architecture.

3. Hybrid Search Combining Multiple Search Methods

The system combines:

  • Trigram similarity for fuzzy text matching
  • Metadata filtering for structured searches
  • Vector embeddings (schema ready for timescale-vector integration)

This hybrid approach provides more accurate and relevant search results than any single method alone.

Implementation: The hybrid_search() method in semantic_search.py combines text similarity with metadata queries.

4. Fluid Storage for Real-Time Collaboration

Using asyncpg with connection pooling, the system enables real-time updates as agents complete their reviews. The database schema supports concurrent writes from multiple agents, demonstrating Fluid Storage capabilities.

5. Tiger MCP Integration Ready

The architecture is designed to integrate with Tiger MCP for agent coordination. Each agent is structured to communicate through the database, enabling MCP-based agent orchestration.

Key Features Demonstrated:

  • ✅ Multi-agent collaboration using separate database forks
  • ✅ Semantic code search with pg_text search
  • ✅ Hybrid search combining multiple methods
  • ✅ Parallel processing architecture
  • ✅ Real-time collaborative reviews

Overall Experience

What Worked Well

  • Semantic Search: The pg_trgm extension provides excellent fuzzy matching capabilities that make code search intuitive
  • Parallel Architecture: The fork-based design makes it easy to add new agents without modifying existing ones
  • Database as AI Brain: Storing code embeddings, reviews, and metadata in Postgres makes everything queryable and enables powerful aggregations

Surprises

  • How seamlessly PostgreSQL extensions (pg_trgm, vector) integrate for hybrid search
  • The flexibility of JSONB columns for storing agent-specific metadata
  • How asyncpg enables truly concurrent database operations

Challenges & Learnings

  • Challenge: Understanding how to structure database forks for agent isolation
  • Learning: Using unique fork IDs per agent maintains isolation while keeping data queryable

  • Challenge: Balancing semantic search accuracy with performance

  • Learning: Combining trigram similarity with metadata filters provides the best balance

Future Enhancements

  • Full integration with Tiger Cloud's fork API for true zero-copy forks
  • Vector embeddings integration using timescale-vector for even better semantic search
  • Tiger MCP integration for agent orchestration
  • Real-time WebSocket updates as agents complete reviews

Technical Stack

  • Backend: Python 3.9+, FastAPI
  • Database: Agentic Postgres (Tiger Cloud)
  • Extensions: pg_trgm, vector
  • Async Operations: asyncpg
  • Frontend: Vanilla JavaScript (can be enhanced with React/Vue)

Setup Instructions

  1. Clone the repository
  2. Install dependencies: pip install -r requirements.txt
  3. Set up database: python setup_db.py
  4. Run application: python main.py
  5. Access at http://localhost:8000

Testing Credentials

For judges testing the application:

  • The application runs locally and doesn't require login
  • Use the provided example code in the textarea or paste your own code
  • Try semantic searches like "authentication", "database connection", "security patterns"

Team Members:

Top comments (0)