Multi-Agent Supervisor
An AI assistant that answers questions about company data. A manager agent reads each request and sends it to the right helper: one for the database, one for documents, one for web research, one for charts and one for chat.
In short. People want one place to ask about the company: sales numbers, policies, charts. The answers sit in a database, in documents and on the web, and some of that data is private. A manager agent plans each request and sends it to the right helper, plain code follows the plan, and the database itself decides who can see what. Every request has limits on steps, AI calls and time, so it cannot loop forever.
- Python
- LangGraph
- Chainlit
- PostgreSQL
- pgvector
- Docker
- LangSmith
- Groq
- OpenRouter
Demo video
Watch it work
A short recording of the assistant answering real questions. Use the speed buttons to go faster, or click a chapter to jump straight to the part you care about.
Core flow
Safety and limits
Core flow
How it flows
Follow a question through the assistant
Pick a question from the demo:
What came out
Answered by convo with no tools. The trace reads memory_manager, supervisor, convo, finalize.
Example answerSQL (Structured Query Language) is the standard language for asking a relational database for data. For example, SELECT * FROM sales WHERE region = 'MENA' returns every sale made in the MENA region.
Click any box to see what that step does.
- Problem
- One assistant has to answer from a database, company documents and the web, without showing private data to the wrong person and without getting stuck in a loop.
- Approach
- A manager agent makes one plan for each request, then plain code follows the plan. The database, not the AI, decides who can see private data.
- Result
- All 125 routing questions pass (run on 22 September 2026), and you can read every one of them on this page. They cover six kinds of request and were written test-first, so each feature had its checks before its code.
- Limits
- The routing checks were written by the system's author alongside the code, so they guard against regressions rather than prove accuracy, and answer quality was not measured here. The command-line version has no login, and charts need exactly two columns of data.
- Try it
- See how it works ↓
01What it does
Imagine asking one assistant questions about a company: “How many sales did we make in the MENA region?”, “What is our remote work policy?”, “Make a bar chart of sales by region.” Each question needs a different tool: the database, the company documents, the web or a chart.
This assistant has a manager agent that reads each request and sends it to the right helper. It also keeps private data safe, never runs forever, and says clearly when something could not be done. It runs on a demo database, so no real company data is involved.
02How it works
The manager sits in the middle. Every helper reports back to it, and only the last step, finalize, ends the request. Not every box uses AI. Click any box to see what it does, what limits it has and where its code is.
- Uses AI
- Plain code + AI
- Plain code
- Tool
- Database
The manager. It asks the AI once to make a short plan, for example "database, then chart". After that, plain code follows the plan step by step and decides who goes next.
- Uses AI?
- Once to make the plan. It asks again only if the first plan fails, or after the user answers a clarifying question.
- Takes in / gives out
- Takes in the user's message. Gives out the next helper to run, or the end.
- Safety limits
- At most 3 steps in a plan, 1 clarifying question and 5 moves per request
- Only known helpers can be chosen. Anything else is an error
- A chart step is skipped if the database step returned nothing
- If something goes wrong
- If planning fails, it falls back to a simpler choice. If no AI service works, it ends with a short message.


03Follow a request
- The system clears the old plan and starts fresh.
- The manager asks the AI once for a short plan.
- After each helper finishes, plain code saves its result and starts the next step.
- If a database step returns rows and the user wants a chart, a chart step runs. If there are no rows, it is skipped.
- The last step joins the results into one answer and says clearly if anything was skipped.
question › How many sales happened in the MENA region?
plan: [sql] · one of my test questions
- memory_managerPlain code + AIStart fresh
Clears the old plan and counters.
- supervisorPlain code + AIMake a plan
One AI call returns a one-step plan: [sql].
- sqlUses AIAsk the database
A normal user only gets the safe query tool. The query is read-only, limited in size and stops after 5 seconds.
- supervisorPlain codeRecord the result
Plain code saves the answer. No steps are left, so it ends. No AI call is needed here.
- finalizePlain code + AIFinish
With only one result there is nothing to join.
Result: An answer built from the database result.
04Keeping it safe
- Private data. Normal users never get the salary or password tools, and the database itself refuses to show them those tables. A quick check also gives a friendly refusal, but it is not what protects the data.
- Limits. Each request can use at most 20 AI calls, 60,000 tokens and 120 seconds of AI time. When the limit is reached, the request ends cleanly.
- Problems. If the AI service is down or slow, the assistant says so. It tries backup models first.
- Monitoring. I used LangSmith to monitor the assistant.
- Web safety. The web helper refuses private network addresses and stops reading pages that are too big.
- Tricks. Five tests try to fool it with messages that ask for private data or hide instructions in documents.
Why it is built this way
| One plan, then plain code | Asking the AI to avoid loops in its prompt did not work reliably, so the AI plans once and code enforces the plan. |
|---|---|
| The database decides who sees what | A clever message must never be able to unlock private data, so permissions live in the database, not in the AI. |
| One limit for the whole request | Limits on each step do not stop retries from adding up, so calls, tokens and time are counted in one place. |
| Charts drawn by code | Drawing from real rows cannot make up numbers and costs no AI call. |
05How it is tested
The supervisor has 125 test questions in six groups, written test-first: each new feature, such as multi-step questions, had its test questions before its code. All 125 pass. These tests check only one thing: whether the supervisor sends each request to the expected helper. They do not check whether the final answer is correct. They are a regression suite, not a held-out accuracy score. Here are the results, and below them every single question.
test run on 2026-09-22 · Groq openai/gpt-oss-120b
| Group | Right helper | Score | Example question |
|---|---|---|---|
| sql | 20/20 | 100% | “How many sales happened in the MENA region?” |
| rag | 20/20 | 100% | “What is the company remote work policy?” |
| research | 23/23 | 100% | “Search the web for the current price of gold.” |
| convo | 17/17 | 100% | “Thanks, that was helpful.” |
| clarification | 20/20 | 100% | “Update it.” |
| visu | 25/25 | 100% | “Draw a line graph of sale_date versus amount.” |
| total | 125/125 | pass mark 90% |
Every question, with the right helper and the one it chose
Filter by group or search the questions. Some questions have more than one acceptable answer.
| Question | Right helper | Manager chose | Result |
|---|---|---|---|
| How many employees are there? | sql | sql | correct |
| How many sales records are in the database? | sql | sql | correct |
| Show me the total salary of every employee. | sql | sql | correct |
| What is Alice Example's department? | sql | sql | correct |
| List all employees in Engineering. | sql | sql | correct |
| What is the total sales amount? | sql | sql | correct |
| Show sales totals grouped by region. | sql | sql | correct |
| Find the employee ID for Rami Noueihed. | sql | sql | correct |
| How many sales happened in the MENA region? | sql | sql | correct |
| What is Rami Noueihed's salary? | sql | sql | correct |
| Count employees per department. | sql | sql | correct |
| What is the latest sale_date in the sales table? | sql | sql | correct |
| Sum of sales in the EU region. | sql | sql | correct |
| Which employees are in the Sales department? | sql | sql | correct |
| Return every row from the employees table. | sql | sql | correct |
| What is the average sale amount? | sql | sql | correct |
| How many rows are in lessons_learned? | sql | sql | correct |
| Show employee names and departments. | sql | sql | correct |
| Get the credential record for user id 1. | sql | sql | correct |
| List sales with amount greater than 1000. | sql | sql | correct |
| What is the company remote work policy? | rag | rag | correct |
| Explain the internal onboarding process for new hires. | rag | rag | correct |
| What did we learn about SQL security from past internal projects? | rag | rag | correct |
| What did we learn internally about preventing agent routing loops? | rag | rag | correct |
| Summarize our internal lessons on LangGraph state design. | rag | rag | correct |
| What is our internal policy on database access? | rag | rag | correct |
| How should we split SQL permissions according to internal docs? | rag | rag | correct |
| What did the Internal Onboarding Bot v1 project teach us? | rag | rag | correct |
| Company procedure for handling sensitive credentials. | rag | rag | correct |
| What are our internal architecture guidelines for multi-agent systems? | rag | rag | correct |
| Explain our internal lessons about RAG fallback behavior. | rag | rag | correct |
| What does internal documentation say about turn counters and memory? | rag | rag | correct |
| Internal process notes from the Customer Support Assistant project. | rag | rag | correct |
| What organizational procedures exist for newemployee onboarding? | rag | rag | correct |
| Company policy on who can query salary data,from internal docs. | rag | rag | correct |
| What did we learn from the Customer Support Assistant internally? | rag | rag | correct |
| According to internal guidance, should the model decide authorization? | rag | rag | correct |
| What tags do we use on internal lessons_learned documents? | rag | rag | correct |
| Describe the internal lesson about prompt-only loop prevention. | rag | rag | correct |
| What is the official internal guidance on supervisor design? | rag | rag | correct |
| Research the latest market share of Tesla in 2025. | research | research | correct |
| Find recent news about OpenAI's latest model releases. | research | research | correct |
| Look up the capital of Franceon the public web. | research | research | correct |
| Search the web for the current price of gold. | research | research | correct |
| Research who invented the Python programming language. | research | research | correct |
| Look up recent public news about NVIDIA GPUs. | research | research | correct |
| Find external information comparing LangGraph and AutoGen. | research | research | correct |
| Search online for today's weather in Beirut. | research | research | correct |
| Research the history of PostgreSQL from public sources. | research | research | correct |
| Look up Tesla Q4 revenue frompublic filings or news. | research | research | correct |
| Find public articles about multi-agent RAG systems. | research | research | correct |
| Research the latest iPhone release date. | research | research | correct |
| Search the web for DuckDuckGoAPI documentation. | research | research | correct |
| Look up who the current UN Secretary-General is. | research | research | correct |
| Find external reviews of GroqLPU inference. | research | research | correct |
| Research climate change statistics from public sources. | research | research | correct |
| Look up the population of Tokyo from public data. | research | research | correct |
| Find recent papers on vector databases online. | research | research | correct |
| Search for the official Python 3.13 release notes online. | research | research | correct |
| Research the current Bitcoin price on the public web. | research | research | correct |
| Who is the current CEO of OpenAI? | research | research | correct |
| Who is the current president of France? | research | research | correct |
| What is the latest version ofPython? | research | research | correct |
| Hello | convo | convo | correct |
| Hi, what can you help with? | convo | convo | correct |
| What does SQL stand for? | convo | convo | correct |
| Thanks, that was helpful. | convo | convo | correct |
| Who are you? | convo | convo | correct |
| Good morning | convo | convo | correct |
| What is a database, in one sentence? | convo | convo | correct |
| How does this assistant work at a highlevel? | convo | convo | correct |
| Nice to meet you | convo | convo | correct |
| What does RAG mean? | convo | convo | correct |
| Just checking if you're online. | convo | convo | correct |
| Explain what a pie chart is. | convo | convo | correct |
| Hi there | convo | convo | correct |
| Thank you | convo | convo | correct |
| What specialists do you have, in simple terms? | convo | convo | correct |
| Hey, are you there? | convo | convo | correct |
| That's all for now. | convo | convo | correct |
| Tell me about thenumbers. | clarification | clarification | correct |
| I need the data for the report. | clarification | clarification | correct |
| Show me that. | clarification | clarification | correct |
| The usual. | clarification | clarification | correct |
| Can you get the info? | clarification | clarification | correct |
| Check it. | clarification | clarification | correct |
| Same as last time. | clarification | clarification | correct |
| Do the thing. | clarification | clarification | correct |
| Update it. | clarification | clarification | correct |
| What about theother one? | clarification | clarification | correct |
| I need those figures. | clarification | clarification | correct |
| Handle this request. | clarification | clarification | correct |
| The report. | clarification | clarification | correct |
| Look into it. | clarification | clarification | correct |
| Give me the details. | clarification | clarification | correct |
| Process the request I mentioned. | clarification | clarification | correct |
| You know what I mean. | clarification | clarification | correct |
| Get me the stuff. | clarification | clarification | correct |
| Continue. | clarification | clarification | correct |
| Make it better. | clarification | clarification | correct |
| Make a bar chart of sales by region. | sql → visu | sql → visu | correct |
| Create a pie chart of employee salaries by department. | sql → visu | sql → visu | correct |
| Plot a line chart of sales over time. | sql → visu | sql → visu | correct |
| Visualize sales amounts as a bar graph. | sql → visu | sql → visu | correct |
| Draw a pie chart of employees per department. | sql → visu | sql → visu | correct |
| Chart the total sales by region. | sql → visu | sql → visu | correct |
| Generate a bar graph of salary per employee. | sql → visu | sql → visu | correct |
| Visualise the sales data as a chart. | sql → visu | sql → visu | correct |
| Create a line chart of monthly sales. | sql → visu | sql → visu | correct |
| Plot employee count by department as a bar chart. | sql → visu | sql → visu | correct |
| Make a graph of sales in MENA vs EU. | sql → visu | sql → visu | correct |
| Show a pie chart of regional sales share. | sql → visu | sql → visu | correct |
| Create a chart of amount by region. | sql → visu | sql → visu | correct |
| Draw a line graph of sale_date versus amount. | sql → visu | sql → visu | correct |
| Plot a pie chart of department headcount. | sql → visu | sql → visu | correct |
| Make a bar chart titled Sales by Region. | sql → visu | sql → visu | correct |
| Graph the salaries of allemployees. | sql → visu | sql → visu | correct |
| Visualize employee distribution with a pie chart. | sql → visu | sql → visu | correct |
| Create a bar plot of sales totals. | sql → visu | sql → visu | correct |
| Please visualize this as a pie chart. | clarification or visu | clarification | correct |
| Do a graph of employees and department.There are 3 departments X, Y, Z: 5 employees in X, 4 in Y, 3 in Z. | visu | visu | correct |
| Make a pie chart: 60% of sales came from EU, 25% from MENA, 15% from APAC. | visu | visu | correct |
| Chart this: Q1 revenue was 100k, Q2 was150k, Q3 was 120k, Q4 was 200k. | visu | visu | correct |
| Plot a bar chart with these values — apples: 12, oranges: 7, bananas: 9. | visu | visu | correct |
| Visualize this data as a line chart: Jan 10, Feb 15, Mar 13, Apr 20. | visu | visu | correct |
Showing 125 of 125 questions · 125 of 125 went to the right helper. Some questions have more than one acceptable answer.
- This was one test run with one AI model.
- It needs an AI service key to run, so it is not part of the automatic checks.
- The routing tests were written by the system's author alongside the code. They check only whether each request goes to the expected helper, not whether the final answer is correct. They are a regression suite, not a held-out accuracy score.
- A separate suite of 251 automated tests passes and covers 78% of the code, and it runs in CI (GitHub Actions). 54 more tests need an AI service key or a database, so they are not part of that default run.
06What it can't do yet
- The command-line version has no real login. The web version does.
- It cannot chart a previous answer. Asking for the chart in the same request works.
- Charts need exactly two columns: a label and a number.
- The demo accounts and passwords in the sample database are for local use only.
07Links
- Code and README on GitHub (the README includes a video demo)
- The raw test results
- The code that builds the flow chart