Courses / AI Engineering: LLMs, RAG and Agentic System Design / Chapter 11
Module 6 · Case studies: recommenders and reward design · Chapter 11 of 24
Case study: a multi-agent conversational recommender
Builds on AI agents and multi-agent systems, Agent design fundamentals and Building LLM applications: chains, tools and memory. Next up: Case study: an agent that writes reward functions.
Part 1 · The problem and requirements
Conversational recommendation
A shop assistant who asks a question, suggests something and chats until you say yes is doing conversational recommendation. This chapter builds a small version out of several model calls, in the shape of a published research system, and measures it against one call that does everything.
A conversational recommender system helps a person find an item through a dialogue instead of a search box or a ranked list. Each turn the system performs a dialogue act. The three that matter here are asking (a question that uncovers a preference), recommending (proposing one item) and chit-chat (a remark that keeps the person talking and may reveal tastes indirectly). The person's replies are feedback: explicit when they say what they want, implicit when a rejection hints at why. The dialogue ends when the person accepts an item or the system gives up.
The system this chapter follows is MACRS, a multi-agent conversational recommender described in a 2024 paper. It uses four model-based agents: three responder agents, one each for asking, recommending and chit-chat, and a planner agent that reads the three drafts and decides which one to send. After each turn a reflection step updates what the system knows. The paper evaluates it with a simulated user on 100 samples from the MovieLens dataset. Its table reports a success rate of 0.61 for the version built on ChatGPT, against 0.39 for ChatGPT used as a single agent with the same prompt, and 0.48 for the version built on Llama 2 against 0.42 for Llama 2 alone. We build a runnable version of the same structure on a catalogue of made-up films and report our own numbers, which differ from the paper's, for reasons the fourth lesson discusses.
Requirements
Functional requirements first. The system holds a multi-turn dialogue. It asks about preferences, and it recommends only films that exist in the catalogue, never a title the model invented. It remembers what the person said and what they rejected, and does not offer a rejected film again. It stops when the person accepts a film or after a fixed number of turns.
The non-functional requirements shape the design more. Latency: each turn makes several model calls, and a person waiting in a chat expects an answer in seconds, so the number of calls on the critical path matters. Cost: every call spends tokens, so calls per conversation is a budget. Grounding: a recommendation must name a real item, so output is checked against the catalogue in code. Robustness: model output can be empty, malformed or off-script, and the system must carry on. Testability: a system that talks to people cannot be tuned with people, so it needs a simulated user, which is the subject of the fourth lesson.
Three metrics decide whether it works. The success rate is the share of conversations in which the person accepts a film within the turn limit, and we set the limit at five turns, the limit the paper's evaluation also uses. The average turns counts the turns taken by the successful conversations, and fewer is better. (The paper averages over all conversations, so its figures are not comparable with ours.) The cost is model calls and tokens per conversation. A system that succeeds more often but spends ten times the calls is a trade, not a win, and the metrics should show it.
Entities and the catalogue
| Entity | Fields | Relationship |
|---|---|---|
| Item | id, title, genre, tone, era, language | 30 in the catalogue; one is the hidden target |
| Profile | attribute and value pairs the person has stated | Grows during one conversation |
| Turn | who spoke, the text, the act used | Many per conversation |
| Conversation | turns, profile, rejected item ids, tips | Ends on acceptance or the turn limit |
The catalogue holds 30 films with invented titles, so that no real film or brand appears. Each has four attributes a person can speak about: a genre, a tone, a decade and a language. Attributes are fixed lists, and a Pydantic model enforces them, so an item with a genre that is not on the list cannot be created. The generator below assigns attributes with a fixed random seed and refuses combinations that would make two films nearly identical, so that a few stated preferences can single one film out.
Genre = Literal["comedy", "thriller", "drama", "sci-fi", "romance", "action"] Tone = Literal["light", "dark", "tense", "warm", "quirky"] Era = Literal["1990s", "2000s", "2010s", "2020s"] Language = Literal["Hindi", "Telugu", "Tamil", "English"] class Item(BaseModel): id: str title: str genre: Genre tone: Tone era: Era language: Language def line(self): return (f"{self.id}: {self.title} | {self.genre} | {self.tone}" f" | {self.era} | {self.language}")
Allowed values and the item model.
A tiny run prints the number of items, the first three as JSON, and the spread of genres. The data is committed to a file so that every later script reads the same catalogue.
30 items {"id": "f01", "title": "Paper Boats at Noon", "genre": "drama", "tone": "dark", "era": "2020s", "language": "Hindi"} {"id": "f02", "title": "The Last Tiffin", "genre": "comedy", "tone": "quirky", "era": "1990s", "language": "Tamil"} {"id": "f03", "title": "Monsoon Ledger", "genre": "romance", "tone": "light", "era": "2000s", "language": "Hindi"} {'drama': 5, 'comedy': 8, 'romance': 5, 'thriller': 2, 'sci-fi': 5, 'action': 5}
Output from one run; yours will differ. Long lines are wrapped here.
Part 2 · Planning the next act with several agents
The components
Each turn runs the same sequence. Three responder agents each write a draft reply for one dialogue act. A planner agent reads the drafts, the conversation and the profile, and chooses which act to send. The chosen reply goes to the person. Their answer is read by a reflection step that updates the profile, and a rejection also triggers a strategy-level reflection that leaves advice for the next turn.
| Component | Reads | Writes |
|---|---|---|
| Asking responder | History, profile, tips | One short question |
| Recommending responder | History, profile, tips, films not yet rejected | An item id and a short reply |
| Chit-chat responder | History, profile, tips | One friendly remark |
| Planner | Three drafts, profile, acts used, past advice | The act to send |
| Reflection | The person's reply, the rejected film | Profile updates, advice for responders and planner |
The paper gives each responder a memory of the dialogue, the user profile and strategy suggestions, and the planner a memory of the acts used and the corrective experience from past failures. Our state object holds the same four things: the history, the profile (attribute and value pairs), the rejected ids with the advice written for the responders, and the notes for the planner. Everything else is a prompt.
The flow of a turn
Watch for three drafts being written before any reply is sent
Read it as steps
One turn: three drafts, one choice, one reply, one update.
Writing the agents
Each responder is a single model call with a short role instruction and the shared context. The asking and chit-chat responders return plain text. The recommending responder returns structured output with an item id and a reply, and its result is checked before anyone uses it.
def respond_ask_chat(st, act): msg = [{"role": "system", "content": "You are one part of a film recommender. " + ROLE[act] + " Reply with at most 25 words."}, {"role": "user", "content": shared(st)}] text = call(f"resp_{act}", msg, max_tokens=70).strip() return text or DEFAULT[act] # guard: empty model output def respond_recommend(st): left = "\n".join(i.line() for i in ITEMS if i.id not in st.rejected) msg = [{"role": "system", "content": "You are one part of a film recommender. Pick the single " "catalogue film that best fits the known preferences and " "write a reply of at most 25 words recommending it. Answer " "as JSON with item_id and reply."}, {"role": "user", "content": shared(st) + "Catalogue:\n" + left}] pick, fail = call_json("resp_recommend", msg, Pick) if pick is None or pick.item_id not in BY_ID \ or pick.item_id in st.rejected: return None # guard: not a real, unrejected film return pick
Responders: an empty reply falls back; a bad item id is dropped.
The check in respond_recommend is the grounding rule in code. If the parse failed, or the id is not in the catalogue, or the film was already rejected, it returns nothing and the turn simply goes on with two drafts. The planner is another structured call. It sees the drafts and returns one of three acts with a reason. If its reply cannot be parsed, or names an act that has no draft this turn, the code falls back to asking. MIN_KNOWN is the number of known preferences the planner wants before it recommends, written as a word and set to two here. The last lesson changes it.
def plan(st, cands): text = "\n".join(f"{a}: {c if isinstance(c, str) else c.reply}" for a, c in cands.items()) msg = [{"role": "system", "content": "You choose which reply a film recommender sends next. " "Rules: do not repeat the same act three turns in a row; " "recommend only when at least " + MIN_KNOWN + " preferences are known; " "otherwise prefer the reply that learns the most. " "Answer as JSON with act (ask, recommend or chat) and " "a one-line reason."}, {"role": "user", "content": shared(st) + f"Acts used so far: {st.acts}\n" f"Planner notes: {st.planner_notes or 'none'}\n" f"Candidates:\n{text}"}] p, fail = call_json("planner", msg, Plan) st.last_plan = p.model_dump() if p else fail if p is None or p.act not in cands: return "ask" if "ask" in cands else next(iter(cands)) return p.act
The planner, with a safe fallback act.
What the guards do
# 1. the recommender names a film that is not in the catalogue macrs.call_json = fake_json([(Pick(item_id="f99", reply="Try"), None)]) print("unknown id ->", respond_recommend(st)) # 2. it names a film the user already rejected st.rejected = ["f05"] macrs.call_json = fake_json([(Pick(item_id="f05", reply="Again"), None)]) print("rejected id ->", respond_recommend(st)) # 3. malformed model output: the parse failed twice macrs.call_json = fake_json([(None, "invalid")]) print("parse failure ->", respond_recommend(st)) # 4. the planner's reply cannot be parsed, or picks an act with no draft cands = {"ask": "What genre?", "chat": "Nice weather for a film."} macrs.call_json = fake_json([(None, "truncated")]) print("planner failure ->", plan(st, cands)) macrs.call_json = fake_json([(Plan(act="recommend", reason="sure"), None)]) print("planner picks missing act ->", plan(st, cands)) # 5. an empty reply from the asking responder macrs.call = lambda *a, **k: " " print("empty text ->", repr(macrs.respond_ask_chat(State(), "ask")))
Five bad inputs; the model call is replaced by staged results.
# 6. budget exhaustion: every conversation turn is charged 30 calls user = SimUser("f05") macrs.macrs_turn = lambda st, u: ("ask", None, False) used = {"n": 0} def meter_calls(): used["n"] += 30 return used["n"] print("budget ->", run_macrs(user, calls_used=meter_calls))
The sixth case: the call budget.
unknown id -> None rejected id -> None parse failure -> None planner failure -> ask planner picks missing act -> ask empty text -> 'What kind of film are you in the mood for?' budget -> {'success': False, 'turns': 1, 'acts': [], 'stop': 'call_budget'}
Output from one run; yours will differ. Long lines are wrapped here.
An unknown id, a repeated id and a failed parse all yield no recommendation. A failed or impossible planner choice yields ask. An empty text from a responder is replaced by a default question. The sixth case checks the call budget: a conversation stops with a named reason when its model calls reach 60, and the output shows call_budget rather than an ordinary failure, so a run that was cut off cannot be mistaken for one that finished.
This is the guard idea from the agent design chapter, applied to model output instead of tool calls: nothing a model returns is used until code has checked it. The turn limit of five and the budget of 60 calls are the step budget of this loop.
A first turn in the log
A real turn shows what the pieces do together. The next lesson uses one logged conversation. Its hidden target is the film printed first, which the system must find without being told.
hidden target: f07: Midnight Bus to Nowhere | thriller | light | 2000s | Tamil
Output from one run; yours will differ. Long lines are wrapped here.
Turn 1 of that conversation follows. The three responders each wrote a draft, and the planner chose one act and gave its reason.
-- turn 1 [ask] Do you prefer watching something fast-paced and exciting, or something slow and atmospheric? [chat] I'd love to help you find the perfect movie! Tell me a bit about what usually captures your imagination when you sit down to watch. [recommend] Since I don't know your favorites yet, why not start with Silver Lane? It is a warm and uplifting modern Hindi comedy. planner: {'act': 'chat', 'reason': "I need to establish at least two preferences before making a recommendation, and 'chat' allows for broader discovery of the user's tastes."} bot: I'd love to help you find the perfect movie! Tell me a bit about what usually captures your imagination when you sit down to watch. user: I'm looking for something with a light atmosphere. profile: {'genre': 'comedy', 'tone': 'light'} | rejected: []
Output from one run; yours will differ. Long lines are wrapped here.
Two things are visible already. The recommending responder drafted a film with no preference to go on, and the planner chose not to send it. And the planner's reason is a plain sentence, which is useful in a log and unreliable as evidence: it states what the model said, not a computed fact.
Which agents' output is parsed as structured data, and why only those?
- The recommender and the planner, because code must read an item id and an act from them.
- The asking and chit-chat drafts are only shown to the person, so plain text is enough.
What does the planner fall back to when its reply cannot be parsed, and why that act?
- It falls back to asking, which is always available and never names an item.
- A wrong question costs a turn, while a wrong recommendation could name an invalid or rejected film.
Part 3 · Reflection on user feedback
Two levels of reflection
A conversational system that does not learn from the replies it gets repeats itself. The paper describes a reflection mechanism on two levels, and our build mirrors both.
Information-level reflection updates what the system knows about the person. After each reply, a model call reads the reply and extracts any preference it states, as attribute and value pairs, into the profile. Later drafts read the profile, so they stop asking for what is known. In our code the extractor returns a Pydantic model whose fields are the four attributes, each limited to the allowed values or null, so it cannot invent a new attribute.
Strategy-level reflection runs when a recommendation is rejected. A model call reviews the conversation, writes a one-line summary of the error, and produces two pieces of advice: one for the responders and one for the planner. The responder advice is stored as the tips that every responder reads on the next turn. The planner advice is appended to the planner's notes. The rejected id is recorded in code, not left to the model, so the same film cannot come back.
def reflect_info(st, user_text): asked = st.history[-2][1] if len(st.history) >= 2 else "" msg = [{"role": "system", "content": "Read the user's message and extract any film " "preference it states about the film they want. " "Leave a field null when " "the message does not state it. Answer as JSON."}, {"role": "user", "content": f"Assistant said: {asked}\nUser said: {user_text}"}] upd, fail = call_json("reflect_info", msg, ProfileUpdate) if upd: EXTRACT.append((user_text, {k: v for k, v in upd.model_dump().items() if v})) for k, v in upd.model_dump().items(): if v: st.profile[k] = v
Information-level reflection: the profile.
def reflect_strategy(st, item_id, reason): item = BY_ID[item_id] msg = [{"role": "system", "content": "A film recommender's suggestion was rejected. Review the " "conversation. Answer as JSON: error_summary (one " "sentence), responder_tip (one sentence of advice for the " "responders) and planner_tip (one sentence of advice for " "the planner)."}, {"role": "user", "content": shared(st) + f"Rejected: {item.title} ({item.genre}, " f"{item.tone}, {item.era}, {item.language}). " f"User said: {reason}"}] les, fail = call_json("reflect_strategy", msg, Lesson) if les: st.tips = les.responder_tip st.planner_notes.append(les.planner_tip)
Strategy-level reflection: advice after a rejection.
One turn with a rejection
Watch for the rejection changing what the next turn knows
Read it as steps
A rejection updates the profile and leaves advice for both sides.
What it did in a real conversation
The demo script, used in the second lesson, prints for each turn the three drafts, the planner's choice and reason, the reply, and the profile afterwards. Turn 3 of the conversation is the one with a rejection. The planner sent a recommendation, and the simulated person answered that it was wrong.
-- turn 3 [ask] Would you prefer a witty romantic comedy or a lighthearted ensemble comedy filled with humor and heart? [chat] That era produced some truly iconic gems! Tell me about a specific movie from that time that you still love to revisit. [recommend] Since you're looking for a light 2000s comedy, I highly recommend 'Fifth Gear Aunty' for its delightful and quirky humor. planner: {'act': 'recommend', 'reason': "Two preferences (tone: light, era: 2000s) are known, and the genre is implicitly established as comedy based on the 'light' request."} bot: Since you're looking for a light 2000s comedy, I highly recommend 'Fifth Gear Aunty' for its delightful and quirky humor. user: That one isn't right because it isn't a thriller. profile: {'genre': 'thriller', 'tone': 'light', 'era': '2000s'} | rejected: ['f30'] tip: Always cross-reference the 'Known preferences' fields, specifically genre, before making a recommendation to ensure it aligns with all user constraints.
Output from one run; yours will differ. Long lines are wrapped here.
Follow the profile line. The person rejected a comedy because it was not a thriller. The information-level reflection moved the genre in the profile from comedy to thriller, and the film's id entered the rejected list. The strategy-level reflection wrote a tip for the responders to check the suggested film against the known preferences. Both are what the design says should happen.
Two failures in the log
The profile after turn 1, in the second lesson, held a genre of comedy that the person had never stated. They had said only that they wanted something light. The extractor model saw the assistant's question as well as the reply, and it seems to have filled a field from the question. That error shaped the recommending responder's drafts in turns 2 and 3, and the film sent in turn 3 was the one that was rejected. It is a failure of the extraction step, not of the design, and it is why the profile is a place to log and audit.
The logs let us count it. In the one comparison run that kept every extraction, 22 of the 62 extracted values differed from the target film's attributes. That is a measured error rate for this extractor on these users, and a good reason to treat the profile as evidence to check, not as fact. The same demo, run again later for the same hidden film, gave a different conversation with the same fault: after the person asked only for something light, the profile read a genre of romance, a later reply moved the tone from light to tense, and the planner called the preferences contradictory. That conversation was accepted on turn 5. Now turn 4 of the first one.
-- turn 4 [ask] Since you're looking for a light thriller from the 2000s, do you prefer a fast-paced action-packed ride or a slow-burn mystery? [chat] My apologies for the mix-up! Let's find that perfect blend of suspense and lightheartedness from the 2000s. Tell me about your favorite themes. [recommend] I highly recommend 'Midnight Bus to Nowhere'. It is a lighthearted thriller from the 2000s that perfectly matches your specific preferences. planner: {'act': 'ask', 'reason': "Since multiple preferences (light, thriller, 2000s) are known but the user's specific style of thriller is undefined, this helps narrow down the choice before recommending again."} bot: Since you're looking for a light thriller from the 2000s, do you prefer a fast-paced action-packed ride or a slow-burn mystery? user: It is a thriller. profile: {'genre': 'thriller', 'tone': 'light', 'era': '2000s'} | rejected: ['f30'] tip: Always cross-reference the 'Known preferences' fields, specifically genre, before making a recommendation to ensure it aligns with all user constraints.
Output from one run; yours will differ. Long lines are wrapped here.
In turn 4 the recommending responder drafted the hidden target, Midnight Bus to Nowhere, and the planner chose to ask instead. It did so again in turn 5, and the five turns ran out. The profile held three preferences, more than the planner's rule asked for, and the planner still wanted more detail. It had the right film in front of it twice and did not send it.
Part 4 · Evaluating with simulated users
A simulated user
A conversational system cannot be tuned by asking people every time a prompt changes. The usual substitute is a user simulator, a model that plays the person. The paper's simulator is given a browsing history and a target film, and speaks in keywords so that its preferences are vague, as a real person's are. Ours is simpler and deliberately constrained.
Each simulated user has a hidden target film. The model that plays the user is told the target's four attributes and to reveal at most one fact a reply, vaguely, never naming the title. It never decides whether a recommendation is right. Code does that: an item is accepted if and only if its id equals the target's id. When a recommendation is rejected, code computes which attributes differ from the target and passes only those to the model, which phrases a one-line reason. The result is a user that sounds natural but whose verdicts are exact.
def judge(self, item_id): """Code, not the model, decides whether a film is right.""" return item_id == self.target.id def feedback(self, item_id): s, t = BY_ID[item_id], self.target diffs = [n for n in ("genre", "tone", "era", "language") if getattr(s, n) != getattr(t, n)] sys = self.persona() + ( f" The assistant suggested '{s.title}', which is not your " f"film. It differs from your film in: {', '.join(diffs)}. " "Say in one short sentence that it is not right and give " "one reason that mentions one of those differences " "without naming the title or all facts.") return call("sim", [{"role": "system", "content": sys}, {"role": "user", "content": "How about it?"}], max_tokens=60).strip()
Acceptance is decided by code; the model only phrases the reason.
The simulator is still a model, and its replies can be off. A user that says something misleading would hurt either system equally, which is why both systems are run against the same set of users.
The protocol
We compare two systems. The multi-agent system is the one built in this chapter. The single-call baseline is one structured model call per turn that sees the full catalogue and the conversation and either asks a question or recommends a film. It has no profile, no planner and no reflection.
def run_single(user): hist = [("user", user.opening())] for turn in range(1, MAX_TURNS + 1): convo = "\n".join(f"{w}: {t}" for w, t in hist) msg = [{"role": "system", "content": "You are a film recommender. Either ask one short " "question to learn preferences, or recommend one film " "from the catalogue. Never recommend a film the user " "already rejected. Answer as JSON with act (ask or " "recommend), item_id (empty string when asking) and " "reply (at most 25 words)."}, {"role": "user", "content": f"Conversation:\n{convo}\n\nCatalogue:\n{CATALOGUE}"}]
The baseline prompt: one call decides everything.
The same ten target films are used for both systems and for every run. They are drawn once from the catalogue with a fixed random seed, so the two arms face the same users. A conversation ends when the film is accepted or after five turns. We record success, the turns used, and for each conversation the number of model calls and tokens. The whole comparison is repeated several times, because the model's sampling is random and a single run says little.
rnd = random.Random(11) targets = rnd.sample([i.id for i in ITEMS], 10) # same ten every run out = open(f"eval_run{run_id}.jsonl", "w") for tid in targets: for arm, fn in (("macrs", run_macrs), ("single", run_single)): meter.reset() macrs.EXTRACT.clear() t0 = time.time() user = SimUser(tid) if arm == "macrs": res = fn(user, lambda: len(meter.LOG)) else: res = fn(user) rec = {"run": run_id, "target": tid, "arm": arm, **res, "calls": len(meter.LOG), "prompt": sum(c["prompt"] for c in meter.LOG), "completion": sum(c["completion"] for c in meter.LOG), "failed_calls": sum(1 for c in meter.LOG if not c["ok"]), "seconds": round(time.time() - t0, 1), "labels": [c["label"] for c in meter.LOG], "extract": list(macrs.EXTRACT)} out.write(json.dumps(rec) + "\n"); out.flush()
Ten fixed targets; both arms; every call counted.
A word on honesty. Ten users is a small set. A difference of one or two users is inside the noise, and the table below should be read for patterns that repeat across runs, not for single numbers.
Results
The comparison ran 3 times on this machine, each time with the same ten targets. The table is printed by a script that reads the logs of every conversation. The rows marked eager belong to the next lesson. It reports one model, these runs, and nothing more.
run system successes mean turns on success 1 multi 5 of 10 4.2 1 single 7 of 10 2.6 2 multi 6 of 10 4.2 2 single 7 of 10 3.0 3 multi 8 of 10 4.0 3 single 8 of 10 3.0 1 eager 6 of 10 3.5 multi-agent conversations: 30; stop reasons {'turn_limit': 11, 'accepted': 19} acts the planner chose: {'chat': 11, 'ask': 94, 'recommend': 28} profile values logged: 62, differing from the target: 22
Output from one run; yours will differ. Long lines are wrapped here.
In these runs the multi-agent system succeeded for 5, 6 and 8 of 10 users across the 3 runs, and the single-call baseline for 7, 7 and 8. The baseline did better in 2 of the 3 runs and tied in 1. Not counting the simulator's calls, the multi-agent system made 21.8 model calls per conversation against 3.4 for the baseline, about 6.4 times as many (26 against 6, about 4 times, when the simulator's calls are counted too).
Why our result differs from the paper's
That is the opposite of the paper's finding, in which the multi-agent system beats a single-model baseline. Our setup differs from the paper's in ways that could explain it, and we did not test most of them: our catalogue has 30 films, not a movie dataset, so a single guess succeeds one time in thirty and a system that recommends early gains; our planner prompt, which we wrote, asks the planner to learn before it recommends; and the paper's system gives a list of items on the sixth turn when the five turns have failed, and reports hit ratios for lists of 5 and 10 items besides the success rate, which we do not. A later repeat of the comparison, while the shared server was busy, finished only the first three of the ten users before it had to be stopped: the multi-agent system succeeded for 2 and the baseline for 3, the same direction as before and far too few to count.
One observation from the logs is direct, not a guess. Over the 30 multi-agent conversations the planner made 133 choices: 94 asks, 28 recommendations and 11 chit-chat turns. Of the 30 conversations, 11 ended at the five-turn limit without an accepted film. A planner that protects the person from early guesses costs turns, and with a limit of five that cost shows up as failures. The next lesson tries the simplest change that follows from this.
Why are both systems run against the same ten targets?
- The same users make the arms comparable; different targets would add a source of difference.
- It also lets a conversation be compared by target when a result is surprising.
Did the multi-agent system beat the single call in these runs? What can and cannot be concluded?
- No: the single call succeeded for more users in 2 of 3 runs and tied in 1, with fewer calls.
- This is one model, one small catalogue and ten users per run; it does not show the paper's result is wrong.
Why does the simulator's acceptance test live in code and not in the model?
- A model could accept a wrong film or reject the right one, making results unreliable.
Part 5 · Design review and extensions
Calls, tokens and time
A design review looks at cost before cleverness. The logs give the mean model calls per conversation by role, and the tokens. Calls that belong to the simulator are shown but are not part of the cost of the product.
mean model calls per multi-agent conversation, by role: planner 4.4 reflect_info 3.8 reflect_strategy 0.3 resp_ask 4.4 resp_chat 4.4 resp_recommend 4.4 sim 3.8 tokens per conversation, multi: 7493 prompt, 831 completion tokens per conversation, single: 3161 prompt, 195 completion (both include the simulator's calls) failed calls: multi 0 of 769, single 0 of 184 median seconds per conversation: multi 37.1, single 9.4
Output from one run; yours will differ.
Per turn, the multi-agent system makes three responder calls, one planner call and one reflection call after the reply, plus a strategy reflection after a rejection. That is about five calls where the baseline makes one; a turn that ends in acceptance has no reflection, so the mean per conversation is slightly below five times the turns. The calls do not all sit on the person's waiting path. The reflection that reads their reply can run while they read the answer, and the three responders do not depend on each other, so they can run side by side. The script below times the three responders one after another and then in threads on this server. Times vary on this machine, and the server is shared.
sequential, 5 trials, seconds: [9.8, 12.4, 12.7, 12.2, 9.1] threaded, 5 trials, seconds: [4.1, 4.1, 6.1, 4.2, 5.5] medians: 12.2 vs 4.2
Output from one run; yours will differ.
On this machine the threaded version took about a third of the time. A later repeat, while other jobs were queued on the same server, gave medians of 69.9 and 7.2 seconds: the absolute times depend on the server's load, and the gap between the two was in the same direction. The waiting path then holds two calls in sequence, a responder and the planner, instead of four. That helps the person's wait. It does not reduce the tokens or the calls.
Trade-offs and extensions
The simplest design change follows from the results: let the planner recommend after one stated preference instead of two, the row marked eager in the table of the previous lesson. It is one word in the planner prompt. We ran it once on the same ten users, and the multi-agent system succeeded for 6 of 10, inside the range of 5 to 8 that the original planner produced over its 3 runs. So the change did not clearly help, and one run of ten users cannot say more. Treat it as exploration on the same small set, not as a tuned result.
- Cold start. With no history the profile is empty. The system asks first, which costs turns. A common remedy is a first recommendation from popular items, which trades personalisation for speed.
- Cost. Drop the chit-chat responder, or replace the planner with a code rule, and measure what is lost. Call counts fall with each agent removed, and the logged success rate tells you whether it was needed.
- Latency. Run the responders in parallel and the reflection after the reply is sent. The waiting path becomes a responder and the planner.
- Safety and privacy. The profile holds a person's tastes, so it should be kept for the conversation only unless the person agrees otherwise. Recommendations stay inside the catalogue by construction.
- A fallback list. The paper falls back to a list of items on the sixth turn and counts a hit when the target is in the top 5 or top 10. Adding that fallback would change both systems' numbers and is worth reporting separately.
Whether several agents are worth their cost is a property of the task and the model, not of the design. The agent design chapter made the point that a fixed workflow is the better design when the steps are known. Here the steps are known, so the multi-agent structure has to earn its extra calls in measured success. In our runs it did not, and the structure of the experiment is what makes that visible.
Questions to think through
These prompts are for working through on paper. There are no model answers here.
- The catalogue grows from 30 films to 30,000. Which agent sees the catalogue, and how does the recommending responder choose from it?
- The person lies, or changes their mind. What in the profile design makes that worse, and what would you add?
- You must halve the cost per conversation and keep the success rate. Which two changes would you try first, and what would you measure?
Where does the cost of the multi-agent design come from, and which calls can leave the waiting path?
- Three responders, a planner and a reflection run each turn, about five calls where the baseline makes one.
- The responders can run in parallel and the reflection can run after the reply is sent.
What did letting the planner recommend after one preference change, and what does the result show?
- It changed one word in the planner prompt and was run once on the same ten users.
- The result fell inside the range of the original planner, so it shows no clear improvement.
Why is the profile worth logging and auditing?
- The extractor can record a value the person never stated, and the system then acts on it.
- Logging what was extracted and from which words lets you measure how often it is wrong.