AI CTO Agent Swarm
A 6-microservice system where 4 specialized AI agents sequentially analyze startup ideas, explicitly challenge each other's recommendations, and produce comprehensive technical strategy reports. Built in 12 minutes for $6.36.
SCREENSHOTS
Research Question
Can AI agents autonomously coordinate through structured disagreement to provide trustworthy technical advisory comparable to a fractional CTO?
Video Walkthrough
Key Results
- Services: 6 microservices
- Lines of code: ~2,500
- Total endpoints: 16 REST APIs
- Build cost: $6.36 (27% cheaper than Day 01)
- Build time: 12 minutes (70% faster than Day 01)
- Cost per analysis: $0.036 (3.6 cents)
- Pipeline time: ~45 seconds (real API)
- AI Model: Claude Haiku 4.5 (claude-haiku-4-5-20251001)
- Database: SQLite (embedded, no separate container)
- Real-time: Server-Sent Events (SSE)
- Success rate: 100% (2/2 real API tests)
- Test assertions: 35+ passing
- Grade: A+ (98%)
- Documentation: 7 files, 2,500+ lines including bug fixes
Architecture
Case Study
Overview
Built a multi-agent AI system that acts as a virtual CTO advisory team for startup founders. Four specialized AI agents analyze a startup idea sequentially, with each agent seeing previous outputs and explicitly challenging recommendations.
Key Innovation: Structured disagreement - agents don't just analyze in parallel; they actively debate and challenge each other's recommendations.
Architecture
The system consists of 6 microservices:
Web UI Service (Port 3000)
- Single-page application with real-time feed
- Server-Sent Events (SSE) for live agent updates
- HTML/CSS/JavaScript (no frameworks)
- Download endpoint for full JSON reports
Orchestrator Service (Port 3001)
- Pipeline manager coordinating all agents
- SQLite for session storage
- Sequential execution with context accumulation
- File storage for completed reports
Architect Agent (Port 3002)
- Recommends tech stack and architecture
- Analyzes based on: tech skills, budget, expected users
- Uses Claude Haiku 4.5
Security Agent (Port 3003)
- Challenges architect with security concerns
- Sees architect's recommendations in context
- Points out vulnerabilities and compliance issues
- Uses Claude Haiku 4.5
Cost Agent (Port 3004)
- Pushes back on expensive choices
- Suggests cheaper alternatives
- Projects infrastructure costs
- Uses Claude Haiku 4.5
DevOps Agent (Port 3005)
- Warns about over-engineering
- Recommends deployment strategy
- Simplifies complexity
- Uses Claude Haiku 4.5
Technical Implementation
Sequential Pipeline with Context Accumulation
``
User Input (startup description)
↓
Architect Agent
context: [user input]
output: tech recommendations
↓
Security Agent
context: [user input + architect output]
output: security concerns + challenges architect
↓
Cost Agent
context: [user input + architect + security]
output: cost analysis + cheaper alternatives
↓
DevOps Agent
context: [user input + all 3 previous agents]
output: deployment strategy + complexity warnings
↓
Synthesis (Claude Haiku)
context: [all 4 agent outputs]
output: final cohesive strategy with 9 sections
`Real-Time Updates via Server-Sent Events
- Browser establishes SSE connection to orchestrator
- Each agent streams progress updates
- User watches debate unfold in real-time
- Fallback to polling if SSE fails
Robust JSON Parsing
Handles multiple edge cases:
- Markdown code fences (
`json...``)Key Technical Challenges
Challenge 1: Synthesis Truncation
Problem: Final synthesis was being cut off mid-sentence
Solution: Increased max_tokens from 4096 to 8192
Challenge 2: JSON Parsing Failures
Problem: AI responses wrapped JSON in markdown code fences
Solution: Implemented 6-pattern extraction system to handle all edge cases
Challenge 3: UI Display Bug
Problem: [object Object] appearing instead of agent names
Solution: Proper object-to-string formatting in frontend
All bugs fixed autonomously by Claude Code. Full documentation in SYNTHESIS-TRUNCATION-FIX.md (30+ pages).
Performance Observations
- Pipeline execution time: ~45 seconds (real API)
- Cost per analysis: $0.036 (3.6 cents)
- Build cost: $6.36 (under $10 budget)
- Success rate: 100% (2/2 real API tests)
- Test assertions: 35+ passing
Comparison: AI Agents vs Human CTO
Fractional CTO:
- Cost: $5,000-15,000/month
- Availability: Limited hours
- Expertise: Single perspective
- Response time: Hours to days
AI Agent Swarm:
- Cost: $0.036 per analysis (3.6 cents)
- Availability: Instant, 24/7
- Expertise: 4 specialized perspectives
- Response time: 45 seconds
Verdict: 99.9% cost reduction with multi-perspective analysis
Key Learnings
1. Sequential Context Beats Parallel Processing
Each agent seeing previous outputs creates richer debate than parallel analysis. Security Agent challenges Architect because it sees what was recommended.
2. Explicit Disagreement Improves Trust
Visible challenges between agents make final synthesis more trustworthy. Users see competing perspectives, not just one AI opinion.
3. Server-Sent Events Enable Real-Time AI
SSE provides smooth real-time updates without WebSocket complexity. Perfect for unidirectional server → client streams.
4. Robust Parsing is Critical for AI Outputs
LLMs don't always return pure JSON. Need multiple extraction patterns to handle markdown, preambles, and edge cases.
5. SQLite Perfect for Session Storage
Embedded database eliminates separate container. Simple, fast, zero configuration.
Future Improvements
- Add user accounts and saved analyses
- Implement follow-up questions to agents
- Add comparison view (analyze multiple ideas)
- Export to PDF with formatting
- Add industry-specific agent variants
- Implement voting system for recommendations
Key Findings & Learnings
- Sequential context accumulation creates richer agent debates than parallel processing
- Explicit disagreement between agents improves trust - users see competing perspectives
- Server-Sent Events (SSE) provide smooth real-time updates without WebSocket complexity
- Robust JSON parsing with 6-pattern extraction handles LLM output edge cases
- SQLite embedded database eliminates separate container while providing session persistence
- AI agent swarms reduce fractional CTO costs by 99.9% ($5k-15k/month → $0.036/analysis)
- Structured disagreement prevents groupthink in multi-agent systems