How bhushanmaheshwari/ai-langgraph works
Project type and purpose
• This is an open-source toolkit/monorepo for building and experimenting with various “agent” patterns (e.g., retrieval-augmented generation graphs, react-style agents, reflection/reflexion agents, human-in-the-loop memory).
• The README title “Understanding Agents” hints that the repo is a sandbox of different agent architectures and pipelines, each isolated in its own folder and PyPI-ready via pyproject.toml.
File structure
• Top-level modules:
• human-in-the-loop-memory – core async and sync memory helpers and orchestration
• rags – RAG-style graph pipeline: ingestion, nodes (retrieve, generate, grade, route), chain definitions, tests
• react-agent – React-style agent implementation (nodes.py, state.py, orchestration in main.py)
• reflection-agent – Single-chain reflection agent (chains.py, main.py)
• reflexion-agent – Enhanced reflection (“reflexion”) agent with tool execution, schemas, chains
• Each subproject has its own pyproject.toml, so they’re intended as standalone packages.
• Common patterns:
• main.py entrypoints
• graph/chain/node abstractions in rags
• schemas/tool_executor in reflexion-agent
• state management in react-agent
README for additional insights
• Minimal content, so rely on folder names, code files, and consistent naming conventions (“chains”, “nodes”, “main”).
a. Main Components
1. CLI/API Layer – main.py scripts in each module
2. Agent Orchestrator – selects which agent to invoke (could be a wrapper or separate process for each submodule)
3. Core Memory Service – human-in-the-loop-memory/core (stateful store, async API for human feedback)
4. RAG Engine – rags/graph (ingestion → retrieval → generation → grading → routing)
5. Agent Variants – react, reflection, reflexion (each with its own chain/node logic)
6. External Services – LLM APIs (OpenAI, etc.), Vector DBs (for retrieval), Web search APIs
7. Tools & Executors – reflexion-agent/tool_executor.py
b. Relationships & Data Flow
1. User request → CLI/API Layer
2. CLI calls the chosen Agent Orchestrator
3. If RAG: data ingestion → vector store → graph chains → LLM calls → grader nodes → result
4. If React: state machine cycles through nodes.py actions and LLM calls
5. If Reflection/Reflexion: prompt → chain of self-analysis steps → optionally tool executor → final answer
6. All agents log or persist conversation/memory to the Core Memory Service for human-in-the-loop feedback
7. External services are called from within node implementations (e.g., retrieval nodes, generation nodes)
c. Architectural Patterns & Principles
• Modular, package-per-agent pattern (micro-package style)
• Chain of Responsibility (rags graph)
• State machines (react-agent)
• Reflection loop pattern (reflection/reflexion agents)
• Separation of concerns: ingestion, retrieval, generation, grading, routing, memory
d. Key Technologies & Frameworks
• Python 3.x, AsyncIO (human-in-the-loop-memory)
• Vector DB clients (in ingestion/retrieve nodes)
• HTTP/REST or SDK calls to LLM providers
• Pydantic or similar for schemas (reflexion-agent/schemas.py)
Detailed but not over-complicated
• Of the five subprojects as a separate module block.