An interactive AI-powered political debate simulation game where users engage with dynamically generated characters representing diverse political ideologies.
Politics Agent creates immersive debate experiences using AI-controlled characters. Each character has a distinct political perspective, personality, and argumentation style. Users navigate branching debate trees, exploring different political arguments and perspectives in an educational, roguelike-style experience.
- Dynamic AI Characters: Characters with unique political spectrums, tones, and debate styles generated via GPT-4o-mini
- Branching Debates: Navigate through different argument paths, creating a tree of debate history
- Multiple Perspectives: Classical political positions (liberal, conservative, social-democrat, etc.) plus creative/unusual ideologies
- Educational Tools: Debug panels to visualize AI decision-making, character stats, and export functionality
- Streaming Responses: Real-time character speech generation with SSE streaming
- Session Persistence: Debate history saved to localStorage for session continuity
- Framework: Next.js 16 with App Router
- Language: TypeScript 5 (strict mode)
- UI: React 19 + Tailwind CSS 4
- AI: OpenAI SDK (GPT-4o-mini)
- Validation: Zod for schema validation
- Testing: Vitest
- Node.js 18+
- OpenAI API key
# Clone the repository
git clone https://github.com/your-username/politics-agent.git
cd politics-agent
# Install dependencies
npm install
# Create environment file
cp .env.example .env.localCreate a .env.local file with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here# Development server
npm run dev
# Production build
npm run build
npm startOpen http://localhost:3000 in your browser.
src/
├── agents/ # AI agent logic
│ ├── director-llm.ts # Orchestrates debate turns
│ ├── character-llm.ts # Generates character speeches
│ └── schemas/ # Zod schemas for LLM outputs
├── app/
│ ├── api/ # Backend API routes
│ ├── components/ # React UI components
│ └── page.tsx # Main application page
├── domain/ # Domain types and fixtures
├── hooks/ # Custom React hooks
└── lib/ # Utilities (OpenAI client, context, storage)
| Endpoint | Method | Description |
|---|---|---|
/api/debate/turn |
POST | Process a debate turn |
/api/debate/turn-stream |
POST | Streaming debate turn |
/api/personalities/generate |
POST | Generate personality pool |
- Director Agent: Orchestrates each turn, managing topic focus, character intents, and navigation paths
- Character Agent: Generates contextual speeches based on character profiles and debate context
- Personality Generator: Creates unique political personas combining unexpected ideological elements
present_argument- Present a new argumentcriticize- Challenge another positionreconcile- Find common groundcontextualize- Add historical/social contextquestion- Pose questions to other charactersdefend- Defend a position under attack
moderate- Balanced, measured responsesinflamed- Passionate, intense rhetorictechnical- Academic, detailed analysispopular- Accessible, everyday language
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run test # Run tests
npm run test:watch # Run tests in watch mode
npm run validate # Validate domain typesMIT