concept

LangGraph Agent Pattern

created 2026-04-19 updated 2026-04-27 ai · langchain · langgraph · pattern · architecture

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

ComponentPurposeUsed In
StateGraph with AnnotationState management with typed reducersmanzas, fajb-next, vorma
createReactAgent()Prebuilt ReAct agent loopfajb-next
PostgresSaverPersistent conversation checkpointsfajb-next, vorma, master-bot
Structured tools (Zod)Type-safe tool definitionsall 4
Streaming SSEReal-time token deliverymaster-bot, vorma
Custom event handlersUI state management via streamfajb-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.