langgraph-multi-agent
NewBuild, run, or adapt a multi-agent SOP assistant using LangGraph, LangChain, OpenAI, UV, and a JSON-backed policy knowledge base. Use when Codex needs to implement or maintain a single-file Python SOP assistant with a supervisor agent, intent classifier agent, SOP retrieval agent, answer generator agent, shared graph state, tool-based routing, and HR/Finance/IT policy question answering.
Overview
Multi-Agent SOP Assistant Using LangGraph
Problem Statement
In large organizations, employees frequently have questions about internal procedures, ranging from HR policies and Finance rules to IT protocols. These processes are governed by Standard Operating Procedures or policies, often stored in lengthy documents that are hard to search, navigate, or interpret without guidance.
Build an AI-driven assistant using LangGraph and LangChain to help users interact with SOPs in a natural and modular way. The system uses multiple specialized agents that work together to:
- •Classify the user's query to determine the relevant department, such as HR, Finance, or IT.
- •Retrieve the most relevant SOP section from a static knowledge base.
- •Generate a clear user-facing explanation tailored to the original query using LLM-based reasoning.
The system should simulate a production-grade agentic AI assistant while keeping the implementation simple and easy to understand.
Objectives
- •Design a multi-agent SOP assistant using LangGraph and LangChain.
- •Employ LLM and tool-based agents for classification, retrieval, and summarization tasks.
- •Coordinate agent behavior using a supervisor node with flexible, dynamic routing.
- •Maintain shared conversation state to support coherent multi-step execution.
- •Simulate enterprise workflows with modular, interpretable components.
Agent Architecture
The user initiates a query related to internal SOPs for HR, Finance, or IT.
A central Supervisor Agent orchestrates the workflow by routing the query through a sequence of specialized agents. LangGraph maintains state, memory, and message passing across the graph.
Use this graph flow:
START
-> supervisor
-> intent_classifier
-> supervisor
-> sop_retrieval
-> supervisor
-> answer_generator
-> supervisor
-> ENDThe supervisor should be the only node that decides whether to proceed, route, or terminate. Specialist agents should complete one bounded task and then return control to the supervisor.
Workflow Breakdown
1. Intent Classifier Agent
- •Identify the department relevant to the user query: HR, Finance, or IT.
- •Use the
classify_departmenttool for reasoning and decision making. - •Store the selected department in shared graph state.
2. SOP Retrieval Agent
- •Fetch the most relevant SOP entry based on the user query and department name.
- •Use the
retrieve_soptool. - •Retrieve from a structured JSON dataset in the
policyfolder. - •Store the retrieved SOP entry in shared graph state.
3. Answer Generator Agent
- •Produce a clear, user-facing explanation of the SOP content as a response to the user's query.
- •Use the
summarize_soptool. - •Contextualize the SOP content for the original user query.
- •Store the final answer in shared graph state.
4. Supervisor Agent
- •Govern the control flow by invoking each agent in the appropriate order.
- •Receive state updates and messages from each specialist agent.
- •Decide whether to proceed, route, or terminate the task.
- •End the graph only after the answer generator has produced a final answer.
Tools
Implement exactly these three tools:
- •
classify_department: map queries to responsible departments: HR, Finance, or IT. - •
retrieve_sop: retrieve policy SOP content from structured JSON based on department and user query. - •
summarize_sop: generate a concise, user-friendly explanation of the SOP content in response to the user query.
Tech Stack
- •Python 3.12.
- •UV as the package manager.
- •LangGraph and LangChain.
- •OpenAI as the LLM provider.
Implementation Requirements
- •Keep the entire application code in a single
.pyfile. - •Include 3 tools, 4 agents, 4 agent nodes, graph compilation, and a friendly function that accepts a compiled agent plus a user query.
- •Maintain a
.envfile for the OpenAI API key. - •Store SOP documents as JSON in the
policyfolder. - •Maintain only 2 SOP records per department.
- •Keep the code simple for easy understanding and reduced token usage.
Recommended State Fields
Use a typed shared state with clear field names:
- •
messages: conversation trace or agent messages. - •
query: original user query. - •
department: classified department. - •
sop: retrieved SOP record. - •
answer: final generated response. - •
next: supervisor-selected route. - •
completed: ordered list of completed agent steps.
Expected Public Functions
Expose a compiled graph and a friendly helper:
- •
build_sop_agent(): build and compile the LangGraph workflow. - •
compiled_sop_agent: ready-to-use compiled assistant graph. - •
ask_sop_agent(compiled_agent, user_query): accept a compiled agent and user query, then return the final answer.
SOP Data Rules
Each SOP JSON record should include:
- •
department - •
title - •
content
Departments should be limited to:
- •
HR - •
Finance - •
IT
Keep exactly two records per department unless the user explicitly changes that requirement.
Environment
Use .env for local configuration:
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4o-miniNever hard-code API keys or secrets in the Python source.
Validation
Run a syntax check:
python -m py_compile sop_assistant.pyRun smoke tests with representative HR, Finance, and IT queries:
uv run python sop_assistant.py "Can I work remotely next month?"
uv run python sop_assistant.py "How do I submit an expense claim?"
uv run python sop_assistant.py "My laptop was stolen, what should I do?"The assistant should classify the department, retrieve the relevant SOP record, generate a concise answer, and terminate cleanly through the supervisor.
Install & Usage
mkdir -p .claude/agentsAdd the configuration to .claude/agents/langgraph-multi-agent.md
@langgraph-multi-agentSecurity Audits
Frequently Asked Questions
What is langgraph-multi-agent?
Build, run, or adapt a multi-agent SOP assistant using LangGraph, LangChain, OpenAI, UV, and a JSON-backed policy knowledge base. Use when Codex needs to implement or maintain a single-file Python SOP assistant with a supervisor agent, intent classifier agent, SOP retrieval agent, answer generator agent, shared graph state, tool-based routing, and HR/Finance/IT policy question answering.
How to install langgraph-multi-agent?
To install langgraph-multi-agent: create the agents directory (mkdir -p .claude/agents), then add the config to .claude/agents/langgraph-multi-agent.md. Finally, @langgraph-multi-agent in Claude Code.
What is langgraph-multi-agent best for?
langgraph-multi-agent is a agent categorized under General. It is designed for: agent, python. Created by sunki1986.