concept
LangGraph Agent Pattern
LangGraph Agent Pattern
A recurring architecture pattern across kulify projects for building agentic AI workflows.
Core Pattern
StateGraph → Agent Node → Conditional Router → Tool Execution → Loop back
All 4 existing projects (manzas, fajb-next, vorma-ai-designer, master-bot) implement variants of this pattern.
Common Components
| Component | Purpose | Used In |
|---|---|---|
StateGraph with Annotation | State management with typed reducers | manzas, fajb-next, vorma |
createReactAgent() | Prebuilt ReAct agent loop | fajb-next |
PostgresSaver | Persistent conversation checkpoints | fajb-next, vorma, master-bot |
| Structured tools (Zod) | Type-safe tool definitions | all 4 |
| Streaming SSE | Real-time token delivery | master-bot, vorma |
| Custom event handlers | UI state management via stream | fajb-next |
Variants
RAG Graph (manzas)
Multi-node pipeline: retrieve context → retrieve past questions → generate answers with retry logic and source validation.
ReAct Agent (fajb-next)
Prebuilt agent with 12+ tools for article manipulation. PostgreSQL checkpointing for resumable threads. BullMQ workers for async AI jobs.
Chat-to-Config (vorma)
Tools return __stateUpdate to incrementally build a configuration object. Streaming partial configs drive real-time 3D rendering.
Conversational Agent (master-bot)
Simple agent loop with availability-checking tools. Session-based state hydration. Language detection and mirroring.
Reusable Starter Kit Opportunity
~80% boilerplate is shared across projects:
- LangGraph graph definition
- Streaming API route (Next.js)
- Chat hook (
useChatStream) - PostgreSQL checkpointer setup
- Tool schema patterns
This could become a projects/_template/ starter.
Related
- AI Agent Architectures — full spectrum from ReAct to deep agents (comprehensive guide)
- ReAct Pattern — detailed breakdown of the think-act-observe loop
- LangGraph Multi-Agent Patterns — handoffs, subagents, skills, router, custom
- LangGraph Skills Pattern — pluggable skills and bundles
- Model Context Protocol — standardized tool provision for agents
- Autoresearch — autonomous agent loop (different domain, same spirit)
- RAG Pipeline — retrieval-augmented generation pattern