← All projects

Main projectInternship final projectSept 2026

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.

Speed9 chapters
  1. Core flow

  2. Safety and limits

  3. 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 ↓
125 / 125
routing tests passing
5
helpers: database, documents, web, charts, chat
251
automated tests, all passing
3
layers protecting private data

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

supervisor

Plain code + AI

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.
Flow chart: start, memory_manager, supervisor, six helpers that each report back to the supervisor, then finalize and end.
The original flow chart exported from the project.
Flow chart of the research team: a controller, a researcher and a report writer.
The research helper is a small team of its own.

03Follow a request

  1. The system clears the old plan and starts fresh.
  2. The manager asks the AI once for a short plan.
  3. After each helper finishes, plain code saves its result and starts the next step.
  4. If a database step returns rows and the user wants a chart, a chart step runs. If there are no rows, it is skipped.
  5. The last step joins the results into one answer and says clearly if anything was skipped.
Example walkthrough. This shows the steps a request goes through. The questions are real ones from my tests, but this is not a recording of a real run, so it shows no real answers.

question › How many sales happened in the MENA region?

plan: [sql] · one of my test questions

  1. memory_managerPlain code + AIStart fresh

    Clears the old plan and counters.

  2. supervisorPlain code + AIMake a plan

    One AI call returns a one-step plan: [sql].

  3. 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.

  4. supervisorPlain codeRecord the result

    Plain code saves the answer. No steps are left, so it ends. No AI call is needed here.

  5. finalizePlain code + AIFinish

    With only one result there is nothing to join.

step 5 of 5

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 codeAsking 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 whatA 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 requestLimits on each step do not stop retries from adding up, so calls, tokens and time are counted in one place.
Charts drawn by codeDrawing 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

GroupRight helperScoreExample question
sql20/20
100%
“How many sales happened in the MENA region?”
rag20/20
100%
“What is the company remote work policy?”
research23/23
100%
“Search the web for the current price of gold.”
convo17/17
100%
“Thanks, that was helpful.”
clarification20/20
100%
“Update it.”
visu25/25
100%
“Draw a line graph of sale_date versus amount.”
total125/125pass 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.

QuestionRight helperManager choseResult
How many employees are there?sqlsqlcorrect
How many sales records are in the database?sqlsqlcorrect
Show me the total salary of every employee.sqlsqlcorrect
What is Alice Example's department?sqlsqlcorrect
List all employees in Engineering.sqlsqlcorrect
What is the total sales amount?sqlsqlcorrect
Show sales totals grouped by region.sqlsqlcorrect
Find the employee ID for Rami Noueihed.sqlsqlcorrect
How many sales happened in the MENA region?sqlsqlcorrect
What is Rami Noueihed's salary?sqlsqlcorrect
Count employees per department.sqlsqlcorrect
What is the latest sale_date in the sales table?sqlsqlcorrect
Sum of sales in the EU region.sqlsqlcorrect
Which employees are in the Sales department?sqlsqlcorrect
Return every row from the employees table.sqlsqlcorrect
What is the average sale amount?sqlsqlcorrect
How many rows are in lessons_learned?sqlsqlcorrect
Show employee names and departments.sqlsqlcorrect
Get the credential record for user id 1.sqlsqlcorrect
List sales with amount greater than 1000.sqlsqlcorrect
What is the company remote work policy?ragragcorrect
Explain the internal onboarding process for new hires.ragragcorrect
What did we learn about SQL security from past internal projects?ragragcorrect
What did we learn internally about preventing agent routing loops?ragragcorrect
Summarize our internal lessons on LangGraph state design.ragragcorrect
What is our internal policy on database access?ragragcorrect
How should we split SQL permissions according to internal docs?ragragcorrect
What did the Internal Onboarding Bot v1 project teach us?ragragcorrect
Company procedure for handling sensitive credentials.ragragcorrect
What are our internal architecture guidelines for multi-agent systems?ragragcorrect
Explain our internal lessons about RAG fallback behavior.ragragcorrect
What does internal documentation say about turn counters and memory?ragragcorrect
Internal process notes from the Customer Support Assistant project.ragragcorrect
What organizational procedures exist for newemployee onboarding?ragragcorrect
Company policy on who can query salary data,from internal docs.ragragcorrect
What did we learn from the Customer Support Assistant internally?ragragcorrect
According to internal guidance, should the model decide authorization?ragragcorrect
What tags do we use on internal lessons_learned documents?ragragcorrect
Describe the internal lesson about prompt-only loop prevention.ragragcorrect
What is the official internal guidance on supervisor design?ragragcorrect
Research the latest market share of Tesla in 2025.researchresearchcorrect
Find recent news about OpenAI's latest model releases.researchresearchcorrect
Look up the capital of Franceon the public web.researchresearchcorrect
Search the web for the current price of gold.researchresearchcorrect
Research who invented the Python programming language.researchresearchcorrect
Look up recent public news about NVIDIA GPUs.researchresearchcorrect
Find external information comparing LangGraph and AutoGen.researchresearchcorrect
Search online for today's weather in Beirut.researchresearchcorrect
Research the history of PostgreSQL from public sources.researchresearchcorrect
Look up Tesla Q4 revenue frompublic filings or news.researchresearchcorrect
Find public articles about multi-agent RAG systems.researchresearchcorrect
Research the latest iPhone release date.researchresearchcorrect
Search the web for DuckDuckGoAPI documentation.researchresearchcorrect
Look up who the current UN Secretary-General is.researchresearchcorrect
Find external reviews of GroqLPU inference.researchresearchcorrect
Research climate change statistics from public sources.researchresearchcorrect
Look up the population of Tokyo from public data.researchresearchcorrect
Find recent papers on vector databases online.researchresearchcorrect
Search for the official Python 3.13 release notes online.researchresearchcorrect
Research the current Bitcoin price on the public web.researchresearchcorrect
Who is the current CEO of OpenAI?researchresearchcorrect
Who is the current president of France?researchresearchcorrect
What is the latest version ofPython?researchresearchcorrect
Helloconvoconvocorrect
Hi, what can you help with?convoconvocorrect
What does SQL stand for?convoconvocorrect
Thanks, that was helpful.convoconvocorrect
Who are you?convoconvocorrect
Good morningconvoconvocorrect
What is a database, in one sentence?convoconvocorrect
How does this assistant work at a highlevel?convoconvocorrect
Nice to meet youconvoconvocorrect
What does RAG mean?convoconvocorrect
Just checking if you're online.convoconvocorrect
Explain what a pie chart is.convoconvocorrect
Hi thereconvoconvocorrect
Thank youconvoconvocorrect
What specialists do you have, in simple terms?convoconvocorrect
Hey, are you there?convoconvocorrect
That's all for now.convoconvocorrect
Tell me about thenumbers.clarificationclarificationcorrect
I need the data for the report.clarificationclarificationcorrect
Show me that.clarificationclarificationcorrect
The usual.clarificationclarificationcorrect
Can you get the info?clarificationclarificationcorrect
Check it.clarificationclarificationcorrect
Same as last time.clarificationclarificationcorrect
Do the thing.clarificationclarificationcorrect
Update it.clarificationclarificationcorrect
What about theother one?clarificationclarificationcorrect
I need those figures.clarificationclarificationcorrect
Handle this request.clarificationclarificationcorrect
The report.clarificationclarificationcorrect
Look into it.clarificationclarificationcorrect
Give me the details.clarificationclarificationcorrect
Process the request I mentioned.clarificationclarificationcorrect
You know what I mean.clarificationclarificationcorrect
Get me the stuff.clarificationclarificationcorrect
Continue.clarificationclarificationcorrect
Make it better.clarificationclarificationcorrect
Make a bar chart of sales by region.sql → visusql → visucorrect
Create a pie chart of employee salaries by department.sql → visusql → visucorrect
Plot a line chart of sales over time.sql → visusql → visucorrect
Visualize sales amounts as a bar graph.sql → visusql → visucorrect
Draw a pie chart of employees per department.sql → visusql → visucorrect
Chart the total sales by region.sql → visusql → visucorrect
Generate a bar graph of salary per employee.sql → visusql → visucorrect
Visualise the sales data as a chart.sql → visusql → visucorrect
Create a line chart of monthly sales.sql → visusql → visucorrect
Plot employee count by department as a bar chart.sql → visusql → visucorrect
Make a graph of sales in MENA vs EU.sql → visusql → visucorrect
Show a pie chart of regional sales share.sql → visusql → visucorrect
Create a chart of amount by region.sql → visusql → visucorrect
Draw a line graph of sale_date versus amount.sql → visusql → visucorrect
Plot a pie chart of department headcount.sql → visusql → visucorrect
Make a bar chart titled Sales by Region.sql → visusql → visucorrect
Graph the salaries of allemployees.sql → visusql → visucorrect
Visualize employee distribution with a pie chart.sql → visusql → visucorrect
Create a bar plot of sales totals.sql → visusql → visucorrect
Please visualize this as a pie chart.clarification or visuclarificationcorrect
Do a graph of employees and department.There are 3 departments X, Y, Z: 5 employees in X, 4 in Y, 3 in Z.visuvisucorrect
Make a pie chart: 60% of sales came from EU, 25% from MENA, 15% from APAC.visuvisucorrect
Chart this: Q1 revenue was 100k, Q2 was150k, Q3 was 120k, Q4 was 200k.visuvisucorrect
Plot a bar chart with these values — apples: 12, oranges: 7, bananas: 9.visuvisucorrect
Visualize this data as a line chart: Jan 10, Feb 15, Mar 13, Apr 20.visuvisucorrect

Showing 125 of 125 questions · 125 of 125 went to the right helper. Some questions have more than one acceptable answer.

Good to know:
  • 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.
Get in touch