Updated tutorial available: This tutorial uses an older version of the sample code. For the latest implementation featuring Agent Graphs with visual orchestration and per-node monitoring, see Beyond n8n for Workflow Automation: Agent Graphs as Your Universal Agent Harness. The updated code is available on the
tutorial/agent-graphs branch.Overview
Build a working multi-agent system with dynamic configuration in 20 minutes using LangGraph multi-agent workflows, RAG search, and LaunchDarkly AI Configs. Part 1 of 3 of the series: Chaos to Clarity: Defensible AI Systems That Deliver on Your Goals You’ve been there: your AI chatbot works great in testing, then production hits and GPT-4 costs spiral out of control. You switch to Claude, but now European users need different privacy rules. Every change means another deploy, more testing, and crossed fingers that nothing breaks. The teams shipping faster? They control AI behavior dynamically instead of hardcoding everything. This series shows you how to build LangGraph multi-agent workflows that get their intelligence from RAG search through your business documents. These workflows are enhanced with MCP tools for live external data and controlled through LaunchDarkly AI Configs—all without needing to deploy code changes.What This Series Covers
- Part 1 (this post): Build a working multi-agent system with dynamic configuration in 20 minutes
- Part 2: Add advanced features like segment targeting, MCP tool integration, and cost optimization
- Part 3: Run production A/B experiments to prove what actually works
What You’ll Build Today
In the next 20 minutes, you’ll have a LangGraph multi-agent system with:- Supervisor Agent: Orchestrates workflow between specialized agents
- Security Agent: Detects PII and sensitive information
- Support Agent: Answers questions using your business documents
- Dynamic Control: Change models, tools, and behavior through LaunchDarkly without code changes
Prerequisites
You’ll need:- Python 3.9+ with
uvpackage manager (install uv) - LaunchDarkly account (sign up for free)
- OpenAI API key (required for RAG architecture embeddings)
- Anthropic API key (required for Claude models) or OpenAI API key (for GPT models)
Step 1: Clone and Configure (2 minutes)
First, let’s get everything running locally. We’ll explain what each piece does as we build.- Sign up for LaunchDarkly at app.launchdarkly.com (free account).
If you’re a brand new user, after signing up for an account, you’ll need to verify your email address. You can skip through the new user onboarding flow after that.
- Find projects on the side bar:

Projects sidebar in the LaunchDarkly app UI.
- Create a new project called “multi-agent-chatbot”
- Project:
multi-agent-chatbot - AI Configs:
supervisor-agent,security-agent,support-agent - Tools:
search_v2,reranking - Variations:
supervisor-basic,pii-detector,rag-search-enhanced

Creating a new project in LaunchDarkly.
-
Get your SDK key:
⚙️ (bottom of sidebar) → Projects → multi-agent-chatbot → ⚙️ (to the right)
→ Environments → Production → SDK key
this is your
LD_SDK_KEY

Location of the SDK key in LaunchDarkly project settings.
.env with your keys:
.env into your source control. Keep those secrets safe!
Step 2: Add Your Business Knowledge (2 minutes)
The system includes a sample reinforcement learning textbook. Replace it with your own documents for your specific domain.- Legal: Contracts, case law, compliance guidelines
- Healthcare: Protocols, research papers, care guidelines
- SaaS: API docs, user guides, troubleshooting manuals
- E-commerce: Product catalogs, policies, FAQs
Step 3: Initialize Your Knowledge Base (2 minutes)
Turn your documents into searchable RAG knowledge:Step 4: Define Your Tools (3 minutes)
Define the search tools your agents will use. In the LaunchDarkly app sidebar, click Library in the AI section. On the following screen, click the Tools tab, then Create tool.
AI Library section in the LaunchDarkly dashboard sidebar.
Create the RAG vector search tool:
Note: we will be creating a simple search_v1 during part 3 when we learn about experimentation. Create a tool using the following configuration:Key:
Semantic search using vector embeddings
reranking
supervisor-basic
claude-3-7-sonnet-latest
pii-detector
claude-3-7-sonnet-latest
pii-detector variation and save it.
Create the Support Agent
Finally, createsupport-agent
variation:
Click Attach tools. select: ✅ reranking ✅ search_v2 Goal or task:
Terminal 1: Start the backend
uv run uvicorn api.main:app —reload —port 8000Terminal 2: Launch the UI
uv run streamlit run ui/chat_interface.py —server.port 8501- Click Save changes
- In your chat, ask a complex question that would normally trigger multiple searches
- What you’ll notice: The agent now makes at most 2 tool calls, forcing it to be more selective about its searches
Feature 3: Change Agent Behavior
Transform your support agent into a research specialist:- In the
support-agentconfig, locate the Goal or task field - Replace the existing instructions with:
- Click Save changes
- Test with a question like “What are the best practices for feature flags?”
- What you’ll notice: The agent now performs multiple searches, explains its search strategy, and provides more thorough, research-oriented responses
Understanding What You Built
Your LangGraph multi-agent system with RAG includes: **- LangGraph Orchestration** The supervisor agent uses LangGraph state management to route requests intelligently based on content analysis.
- Privacy Protection** The supervisor agent uses LangGraph state management to route requests intelligently. This separation allows you to assign a trusted model to the security and supervisor agents and consider on a less-trusted model for the more expensive support agent at a reduced risk of PII exposure.
- RAG Knowledge System** The support agent combines LangGraph tool chaining with your RAG system for semantic document search and reranking.
- Runtime Control** LaunchDarkly controls both LangGraph behavior and RAG parameters without code changes.
What’s Next?
Your multi-agent system is running with dynamic control and ready for optimization. In Part 2, we’ll add:- Geographic-based privacy rules (strict for EU, standard for other)
- MCP tools for external data
- Business tier configurations (free, paid)
- Cost optimization strategies
Try This Now
Experiment with:- Different Instructions: Make agents more helpful, more cautious, or more thorough
- Tool Combinations: Add/remove tools to see impact on quality
- Model Comparisons: Try different models for different agents
- Cost Limits: Find the sweet spot between quality and cost
Key Takeaways
- Multi-agent systems work best when each agent has a specific role
- Dynamic configuration handles changing requirements better than hardcoding
- LaunchDarkly AI Configs control and change AI behavior without requiring deployments
- Start simple and add complexity as you learn what works
Related Resources
Explore the LaunchDarkly MCP Server - enable AI agents to access feature flag configurations, user segments, and experimentation data directly through the Model Context Protocol.Questions? Issues? Reach out at
aiproduct@launchdarkly.com or open an issue in the GitHub repo.