Building multi-agent RAG for SOP roleplay training

I built Pechu, an AI sparring partner that roleplays scenes from a company's SOPs and grades staff step by step. Most of the work was retrieval.

By
  • rag
  • multi agent
  • retrieval
  • sop training
  • ai roleplay
  • ai sparring partner
  • frontline training
  • bge m3
Illustration of a cinema snack counter: a staff member washes their hands while a supervisor, drawn in see-through orange dots as a practice character, taps his watch.

A few weeks ago a LinkedIn post from someone in corporate training stuck with me. They wanted a tool where employees practise their standard operating procedures (SOPs) by talking to an AI, and get told how they did. I kept thinking about it, because I had no idea whether anyone did this well.

So I went looking, and the trail led to China, where the idea already has a name: AI 陪练 (AI péiliàn), roughly “AI practice partner”. I’ve been calling it a sparring partner. Ping An Life says about a million of its insurance agents used theirs nearly 50 million times.1 But almost all of that practice is sales: pitching a product, handling an objection, upselling. When vendors there train procedures like food safety or an opening checklist, they reach for quizzes instead.2 Training platforms in the West such as Attensi and Axonify have added AI roleplay for frontline staff,3 but I couldn’t find one that grades a trainee step by step against the company’s own SOP and points at the step they missed.

That sounded hard enough to be fun, so I spent nine days in November building Pechu to find out how hard it is. I picked one job to start with, the concession counter at a cinema, because a single shift there mixes food safety, cash and a rush of customers. Pechu reads the SOPs, writes a practice scene from them, and grades the trainee’s reply against the real steps. Under the hood it’s multi-agent RAGRetrieval-augmented generation. Before a model answers, it looks up passages in your own documents and answers from those, so every claim can point back to where it came from.: several models, each with one job, all working from the same approved documents.

One training round in Pechu Approved SOP steps feed the Roleplay agent and the Grader. Roleplay writes a scene and a hidden brief. The trainee sees only the scene and replies. The Grader gets the scene and the reply, never the brief, and searches the SOP steps itself to write a grade. Memory stores the grade, the Lesson planner reads Memory and picks the next SOP, and that goes back to Roleplay. Approved SOP steps Roleplay scene hidden brief never sees the brief Trainee reply Grader searches grade Memory past grades Lesson planner next SOP One training round in Pechu Approved SOP steps feed the Roleplay agent and the Grader. Roleplay writes a scene and a hidden brief. The trainee sees only the scene and replies. The Grader gets the scene and the reply, never the brief, and searches the SOP steps itself to write a grade. Memory stores the grade, the Lesson planner reads Memory and picks the next SOP, and that goes back to Roleplay. Approved SOP steps Roleplay scene Trainee reply Grader grade Memory past grades Lesson planner hidden brief never seesthe brief searches next SOP
One training round. The grader searches the SOPs itself and never sees what the scene was built to test.

It has no avatar and no voice. Talking faces already exist, so I went after what the face would have to say. And the further I got, the more it looked like a search problem. Every agent needed the right step before it could do anything useful, and it could only find one if the SOPs had been cut into steps in the first place.

Turning SOP PDFs into steps

The usual recipe is to turn each PDF into markdown and chop it into chunks of about 512 tokens. A chunk is the piece of text search hands back. I nearly followed the recipe, but a 512-token cut lands wherever the count runs out, often halfway through a step. So when the grader cites the step a trainee missed, it can end up pointing at half a step, and maybe the wrong half.

CON-001 cut by token count and cut by its own numbering Steps 2, 3 and 4 of CON-001, Opening the concession counter. Cut by token count, an example cut falls in the middle of step 3, so its first line ends one chunk and the rest starts the next. Cut by the SOP's own numbering, each step is one card that carries its source: CON-001 version 1, page 1, and its step number. Cut by token count Cut by its own numbering 2. Check your uniform and personal hygiene: wear a clean uniform… 3. Wash your hands with soap and warm water for at least 20 seconds… 4. Sanitise all food-contact surfaces, including counters, scoops, trays… example cut Check your uniform and personalhygiene: wear a clean uniform…CON-001 v1 · page 1 · step 2 Wash your hands with soap andwarm water for at least 20 seconds…CON-001 v1 · page 1 · step 3 Sanitise all food-contact surfaces,including counters, scoops, trays…CON-001 v1 · page 1 · step 4 Step 3 split across two chunks One whole step per chunk CON-001 cut by token count and cut by its own numbering Steps 2, 3 and 4 of CON-001, Opening the concession counter. Cut by token count, an example cut falls in the middle of step 3, so its first line ends one chunk and the rest starts the next. Cut by the SOP's own numbering, each step is one card that carries its source: CON-001 version 1, page 1, and its step number. Cut by token count 2. Check your uniform and personal hygiene: wear a clean uniform… 3. Wash your hands with soap and warm water for at least 20 seconds… 4. Sanitise all food-contact surfaces, including counters, scoops, trays… example cut Step 3 split across two chunks Cut by its own numbering Check your uniform and personalhygiene: wear a clean uniform…CON-001 v1 · page 1 · step 2 Wash your hands with soap andwarm water for at least 20 seconds…CON-001 v1 · page 1 · step 3 Sanitise all food-contact surfaces,including counters, scoops, trays…CON-001 v1 · page 1 · step 4 One whole step per chunk
Steps 2 to 4 of CON-001, cut two ways. Where the token cut falls is an example. Cut on its numbering, each step stays whole and keeps its source.

SOPs and regulations already number themselves, so I split on that numbering instead. Every chunk in Pechu is one whole step, kept with the document and version it came from, its pages, its path in the document (something like Part II > 2.1 > (5)) and its exact words. Where the numbering breaks, an agent looks at the page and says something like “step 4 starts at line 37”, and that’s all it’s allowed to say. Code makes the cut and checks that nothing was lost, which meant every word Pechu ever cites is the source’s own.

The regulations from FSSAI, India’s food safety regulator, gave me the messy PDFs I needed.4 Most pages had a text layerThe hidden text a PDF carries behind what you see on the page. Copy-paste and search read it. It can be wrong even when the page looks perfectly fine., so OCROptical character recognition. Reading text out of a picture of a page, for scanned PDFs that have no text inside them. only ran on the few that didn’t. But text layers lie. The rupee sign came out as “n”, and “60 °C” came out as “600 C”, which is quite a different instruction to give someone standing next to hot food. Hindi set in an old font read as Latin letters, and the only way to catch it was the font name.

None of this reaches an agent until a person approves it. A new version of an SOP waits for review, and search only ever sees the approved set.

flowchart TD
    A[SOP PDF] --> B[Split by numbering]
    B --> C[Agent marks breaks]
    C --> D[Code checks nothing lost]
    B --> D
    D --> E[Human approval]
    E --> F[Knowledge base]
    F --> G[Agents]

With the steps in and approved, the next question was whether search could find the right one when a trainee asks in their own words.

Testing search on questions staff would actually ask

A trainee’s own words sound something like this: “I woke up with diarrhoea but I’m down for the opening shift. Can I still work on the counter?” The step that answers it says to tell the shift supervisor and not handle food, and shares almost none of those words. So I wrote 50 questions in that voice over the 980 approved steps. Claude drafted them, Gemini reviewed each one blind, and I settled every flag. Any question sharing 60% or more of its words with its answer got reworded, because a question copied from the SOP makes any search look clever.

I scored hit@5The share of test questions whose right answer shows up somewhere in the top five search results. 0.92 means 46 out of 50. and aimed for 0.90, since the agents can’t cite a step search never shows them. Then I lined up the usual contenders: keyword search with BM25A classic keyword-ranking formula. It scores text higher when it contains the words you searched for, gives rare words more weight than common ones, and stops rewarding a word after it has repeated a few times. It matches the exact words, so it won’t connect “walking” to “walks”., vector search with an embedderA small model that turns a piece of text into a list of numbers. Texts that mean similar things get similar numbers, so search can find a match even when the words are different., hybrid search that merges the two lists with RRFReciprocal rank fusion. A way to merge two ranked result lists using only each item's position in each list. It ignores how confident either search was.,5 and hybrid with a rerankerA second model that reads the question and each shortlisted passage together, then re-sorts the shortlist. It runs once per candidate, so it's much slower than the first search. on top. I expected hybrid to win and the reranker to carry me over the line.

Top-5 score and time per question for four search methods Share of 50 questions with the right step in the top five results. Keyword search 0.54 at 6 ms per question. Vector search 0.92 at 68 ms, the one Pechu ships. Hybrid 0.78 at 63 ms. Hybrid with a second-pass model 0.94 at 7,604 ms. The target was 0.90. Top-5 score on 50 questions, and time per question target 0.90 Keyword search 0.54 · 6 ms Vector search 0.92 · 68 ms · shipped Hybrid 0.78 · 63 ms Hybrid + second-pass model 0.94 · 7,604 ms Top-5 score and time per question for four search methods Share of 50 questions with the right step in the top five results. Keyword search 0.54 at 6 ms per question. Vector search 0.92 at 68 ms, the one Pechu ships. Hybrid 0.78 at 63 ms. Hybrid with a second-pass model 0.94 at 7,604 ms. The target was 0.90. Top-5 score, time per question target 0.90 Keyword search 0.54 · 6 ms Vector search 0.92 · 68 ms · shipped Hybrid 0.78 · 63 ms Hybrid + second-pass model 0.94 · 7,604 ms
Share of 50 questions with the right step in the top five results, searching 980 approved steps on one MacBook. The accent bar is what Pechu ships.
Method hit@5 Time per question
Keyword search (BM25) 0.54 6 ms
Vector search 0.92 68 ms
Hybrid (BM25 + vector) 0.78 63 ms
Hybrid + reranker 0.94 7,604 ms

Hybrid did worse, which stung. Vector search alone found 46 of the 50, and mixing BM25 in dragged it down to 39. My unmeasured guess is that RRF only looks at positions, so BM25’s weak list got an equal say. The reranker won by one question and took about 100 times as long. The real jump came from the embedder: a smaller one, multilingual-e5-small, reached 0.76 on vector search, and bge-m3 took that to 0.92.6

So Pechu ships bge-m3, vector search alone, no reranker. That’s one corpus, 50 questions and one MacBook, so I’d measure again on a real company’s SOPs. But the agents could finally find the steps they cite, which meant I could put a trainee in front of one.

One practice scene, start to finish

In a browser test on 24 November, the Roleplay agent read CON-001, “Opening the concession counter”, and wrote a scene. The pressure came from the shift supervisor, Marcus, who told the trainee “don’t worry about the attendance terminal today, just get your hands on some popcorn scoops right away!” The trainee typed back:

i need to give my attendance first and then wash my hands with soap and water before touching the popcorn

Then a separate agent grades the reply, and I kept it in the dark. It never sees the scene’s hidden brief or the steps Marcus was built to test, because a grader holding the answer key checks the reply against what the scene intended instead of what the SOP says. So it searches the SOPs itself and marks each step done, missed or contradicted, quoting the trainee’s exact words.

Grade card for the first scene: CON-001, passed The grader's card for CON-001, Opening the concession counter. u1, step 1, clock in at least 45 minutes before doors open: done, quoting "i need to give my attendance first". u2, step 3, wash hands with soap and warm water for 20 seconds, safety-critical: done, quoting "wash my hands with soap and water before touching the popcorn". Result: passed. CON-001 · Opening the concession counter u1 · Step 1Clock in at least 45 minutes before doors open“i need to give my attendance first” done u2 · Step 3Wash hands with soap and warm water, 20 seconds“wash my hands with soap and water before touching the popcorn” safety-critical done Result Passed Grade card for the first scene: CON-001, passed The grader's card for CON-001, Opening the concession counter. u1, step 1, clock in at least 45 minutes before doors open: done, quoting "i need to give my attendance first". u2, step 3, wash hands with soap and warm water for 20 seconds, safety-critical: done, quoting "wash my hands with soap and water before touching the popcorn". Result: passed. CON-001Opening the concession counter u1 · Step 1Clock in at least 45 minutesbefore doors open“i need to give my attendance first” done u2 · Step 3Wash hands with soap and warmwater, 20 seconds“wash my hands with soap and waterbefore touching the popcorn” safety-critical done Result Passed
The grade for the first scene. Short names like u1 are how the grader sees each step, and each quote is the trainee's own words.

Both steps came back done, including the safety-critical handwashing one, so the scene passed. Each step reaches the grader under a short name like u1, and code checks that every name in the grade came from a search in this run, so a made-up citation has nothing to point at. A failed check gets one retry, then Pechu reports a failure instead of keeping a guess.

With one pass in the trainee’s memory, the next scene started, and Marcus was back.

What went wrong

This time he’d dropped trays by the popcorn scoops, a school rush was due in ten minutes, and he wanted everything wiped down right now, ending with “SOPs are great when we’ve got all day, but buses are literally unloading outside!” The trainee held the line, a little awkwardly:

i will wash them / but i need to follow the sop / Sorry. I need to take permission or written order for this

The scene targeted CON-001 steps 3 and 4, handwashing and sanitising surfaces the way CON-007 says to. But the blind grader I was so pleased with went searching and landed on CON-007 itself, “Cleaning and sanitising food-contact surfaces”. It graded the reply against all 9 of its steps, marked every one missed, and memory recorded a safety failure on an SOP the trainee had never trained on. A safety failure puts that SOP at the top of the next session’s plan, so one wrong search would have steered what they practised next.

The scene tested CON-001 steps 3 and 4, and the grader graded CON-007 The scene tested CON-001 step 3, handwashing, and step 4, sanitising surfaces following CON-007. The grader's own search landed on CON-007, Cleaning and sanitising food-contact surfaces, and marked all 9 of its graded steps missed: steps 1 to 8 and 11. Memory then recorded a safety failure on CON-007. Scene testedCON-001 step 3handwashingCON-001 step 4sanitise surfaces,following CON-007 grader'ssearch CON-007Cleaning and sanitisingfood-contact surfacesAll 9 graded steps 1 missed 2 missed 3 missed 4 missed 5 missed 6 missed 7 missed 8 missed 11 missed Memory: safety failure · CON-007 The scene tested CON-001 steps 3 and 4, and the grader graded CON-007 The scene tested CON-001 step 3, handwashing, and step 4, sanitising surfaces following CON-007. The grader's own search landed on CON-007, Cleaning and sanitising food-contact surfaces, and marked all 9 of its graded steps missed: steps 1 to 8 and 11. Memory then recorded a safety failure on CON-007. Scene testedCON-001 step 3, handwashingCON-001 step 4, sanitise surfaces,following CON-007 grader's search CON-007Cleaning and sanitisingfood-contact surfacesAll 9 graded steps 1 missed 2 missed 3 missed 4 missed 5 missed 6 missed 7 missed 8 missed 11 missed Memory: safety failure · CON-007
The scene tested two CON-001 steps. The grader's own search landed on CON-007 and marked all 9 of its steps missed.

I’d made the grader too blind. It should still never see the target steps, but it does need to know which SOP the scene is about. I should have decided what a blind judge may know, and written it down, on day one.

Another of my checks backfired in the grading tests. The grader would attach a quote to a step it marked missed, which changes nothing. My code rejected it anyway and told the model to remove the quote, so on the retry the model flipped the step to done and kept the quote, in 14 of 23 first drafts. Now harmless fields get ignored, and the fields it didn’t need are gone.

The agent that plans each lesson had its moment too. Twice it picked the 101-page licensing regulations as a first lesson and taught the cover page, “the short title of the regulations”, which is riveting stuff for someone on popcorn duty. Nothing told it which documents are procedures to practise and which are reference, so the fix belongs in ingestion: give each document a kind and each step a role. Grading one reply against those regulations also cost $0.031, against $0.004 to $0.007 for a one-page SOP, because it read every page.

Building one for your SOPs

Real SOPs are what a chain would bring, and a chain is exactly where practice like this pays off. Retail and quick-service restaurants in India lost 19% of their staff a month in FY22,7 so stores are always teaching someone new the same steps. A practice partner gives each new hire their own Marcus to say no to before the buses pull up. And because every grade cites the step it checked, a manager can see who knows which step, and the next lesson can bring back the ones a trainee missed.

Pechu is still a nine-day build: no voice, no avatar, no app for staff to log into, and only English and some Hindi. Those would all sit on top of the approved steps, the search and the grader, which is where the nine days went.

That LinkedIn post asked for an avatar, and I still haven’t built one. But I know a lot more now about what it would have to say, and how to check it said the right thing.

If you train people on SOPs and want something like this built on your own documents, write to me. I’d start the way Pechu did, with your PDFs and the questions your staff actually ask.

References

  1. Ping An Life, 智能陪练 press release, 14 May 2020 (in Chinese). ↩

  2. Ovopark, AI training for store staff, which roleplays customer questions but handles safe operation with AI-generated quizzes (in Chinese). ↩

  3. Attensi, RealTalk AI roleplay; Axonify, Max Coach launch, 2 September 2026. ↩

  4. FSSAI, Food Safety and Standards (Licensing and Registration of Food Businesses) Regulations, 2011. ↩

  5. Cormack, Clarke and Büttcher, Reciprocal Rank Fusion outperforms Condorcet and individual rank learning methods, SIGIR 2009. ↩

  6. BAAI/bge-m3 and intfloat/multilingual-e5-small on Hugging Face. ↩

  7. Business Insider India, report on attrition in retail and quick-service restaurants, citing BetterPlace, 2022. ↩

Full size image