, OpenAI released a PDF, and everyone is talking about it. This PDF is a 34-page guide that explains what LLM Agents are and how to use them.
The PDF is fairly short and also very readable (you don’t need to be a Prompt/Software Engineer to understand it), but in a few words, it explains three things:
.1. LLM Agents “are systems that independently accomplish tasks on your behalf.”
So aren’t they simple LLM prompts called through an API? Well, yes and no. You are using the same model(s) of Chat Completion, so they kind of are, but they are meant to create a specific action. What I mean by that is that the output of your agents should translate into an actionable output in your system. For example, if the LLM output says “spaghetti,” then “spaghetti” gets added to your data pipeline and eventually will be seen by someone who will cook spaghetti (spoiler).
2. LLM Agents are particularly well integrated with function (tools)
I am talking about when you ask a question to ChatGPT and it pulls out its image generator/web searcher/code snippets. It is internally using a function called tool, which is triggered by your prompt. Now, the image generator is an in-built function, but they can also call your function (tool), which you can specifically define for your task.
3. Multiple LLM Agents can be integrated back to back.
You can either integrate a single agent and provide him with multiple tools or split the tools into specific agents, which is what we are going to do in this article (second spoiler, lol).
Now, the technical details might be of interest to the software engineers, but why is this Agents thing a big deal for anyone else?
Well, it is because this is a paradigm shift that helps provide usefulness to the Open AI models. Think about it: now the LLMs provide actionable output. So it is not about using LLM prompts in the very last step of a pipeline to beautify your final output; it is about integrating your whole pipeline with LLM Agents to improve the whole pipeline quality.
As much as I try to explain it with words, I think it is just easier to show you. Let’s consider a restaurant, for example.
The standard restaurant has a very obvious natural pipeline: you wait in line, you order your food, you wait for your food, eat, and leave. Now, if we translate this with an “agent” approach, we can identify at least three agents:
- The customer agent is an LLM Agent that orders food or asks the waiter for suggestions
- The waiter agent is an LLM that collects the orders and provides suggestions when necessary
- The entertainment agent is an LLM with the purpose of dealing with the complaints of the customers.
Now, OpenAI tells you very specifically how to build these beasts, but that’s the relatively easy part; there is much more, right?
We need to implement the restaurant, we need to create a queue method, where people get seated based on how busy the restaurant easy, we need to create the menu, simulate the waiting time, make sure everything works, and then and only then we can plug the agents in. As always:
Generative AI is powerful, provided it is in the right context.
So, before we get to the juicy part of the agents, in this article, you will see this:
- The System Design for the LLM Agent restaurant. A codeless idea, pen and paper (more like mouse and PowerPoint) scheme of the project.
- An Agent-free Restaurant implementation. plain and simple, just to create our code skeleton
- The Agent Restaurant implementation. Plus, a simple GUI to display it nicely
- Considerations and final remarks.
Looks like we have a lot of ground to cover. To the lab! 🧪
1. Restaurant System Design
NOTE: If you did some technical rounds, you will find this system design pretty easy. The goal of this design is not to comprehensively show every part of an ML system (like they ask you in a 15-minute-long interview 🙃), but it is just to provide some guidelines on what we are going to do next.
The way we can picture the restaurant process, integrated with LLM, is summarized in this picture:
Let me explain:
- Restaurant() and Menu() are two classes. We declare them, and all the tables, orders, and system information will be defined inside the classes and dynamically updated
- The new customer will have to go through a seating mechanism. If they can sit (enough free tables), that’s fantastic, we can let them sit; otherwise, the customer will wait in line (queued).
- For the seated customer, there will be a waiter who will let them order food. They can “complain” and ask how long the food will take after they order.
- The queued people can’t do much, but they can “complain” too and ask how long they will have to be in line before they can sit.
Now, if you think about it, you don’t need an LLM for this. For example, we can precompute the waiting time and then communicate it with a pre-defined, formatted string. We can also use a simple list to collect the orders (like the McDonald’s automated kiosk) and call it a day. Sure, we can do that, but think about it.
What if the customer wants to ask for information about the menu while they wait? What if they are undecided about the food? What if they want to know the juiciest vegan option on the menu? What if they want a good wine at a decent price? We can either start declaring rule-based methods for every single one of these scenarios, wasting our time and money, or we can start using AI. That is what this article is about. If we use LLM Agents, we have a shot at dealing with all these scenarios in a single pass.
Now, if I did learn something, it is that software engineering needs to be done step by step. It is best to have a skeleton of your model, and then add the bells and whistles. For this reason, we will build an agent-free version of the product above. This simplified version will have a queuing system that computes the waiting time and menu implementation, so everything will run smoothly without any AI. After this step, we can put the agents in the places that we discussed and shown above (customer, entertainer, and waiter).
2. Agent Free Implementation
It’s always a good idea to keep everything as simple as possible in the main script, and let the backend do the dirty work. Our agent free implementation can be run in this code.
As we can see, we can change:
- num_tables; the number of tables in our restaurant
- arrival_prob; is the probability that a customer is coming at every time step
- tick; is the time step of our simulation
- pause; regulates the time.sleep(), and it is used to simulate a real restaurant streamline.
Now, all this implementation is done in naive_models.py, which is here.
So this is long, let me walk you through some steps.
The whole script runs on naive_sim on the command .run() with the following functions:
- arrive, which models the customers arriving and ordering, or arriving and getting queued
- process_cooking, which simulates the cooking of every table,
- process_departures, which simulates the customers leaving,
- seat_from_queue, which simulates the customers getting seated from the queue
- handle_random_query, which gets called randomly, where the customer in the queue or waiting for their food can ask for the waiting time
If we run naive_sim.py we got this from the terminal.

Now, this is a data science product itself. You could run monte carlo chain with this, you can see the probability of creating long queue, Restaurants can use this “digital twin” of their restaurant and see when critical things can happen. Now that we have a product that works, let’s make it prettier and more powerful with AI.
3. Agent Restaurant Implementation
Now, as we see above, customers are already able to ask questions, and we already have the answer as a number. The customer also picks random food in our implementation. Let’s try to add our agents to the scheme.
3.1 Custom Agents Implementation
You will need to have the agents module installed:
pip install openai-agent
The implementation of the customer, entertainment, and complaint handler is this.
So we have the client definition, which is the OpenAI client call, newtools.py, which is pulling the menu, call_agent which is calling the single agent and running it through the runner.
This is exactly what we were talking about in the introduction. We are defining multiple agents that will be connected, and they use tools that are defined by my code.
3.2 Custom Agents Implementation
The Table and Restaurant implementation with agents is integrated in the following code:
3.3 LLM Restaurant GUI implementation
In order to show you the performance of the Restaurant with the LLM implementation, through a simple GUI.

The GUI gives you the information on the person (Emma), the table, the time step, and the LLM output. The .txt log is also automatically generated.
Let me show you one :
[12:31:23] The customer Emma is talking to the waiter, saying this I'd like to start with the Bruschetta for the appetizer.
Then, I'll have the Spaghetti Carbonara for the first course.
For dessert, I'll enjoy the Tiramisu.
Could you also recommend a wine to go with this meal? [12:31:25]
The processed response from our LLM is {'food': ['Bruschetta', 'Spaghetti Carbonara', 'Tiramisu', 'Chianti Classico'], 'status': 'successful'} [12:31:25] [0000m]
❓ Customer 1: How long will the food take me? [12:31:25] [0000m]
➡️ Estimated food wait for customer 1: 15m [12:31:26] Our LLM took care of Emma with this:
Last agent: Agent(name="Entertainer", ...)
Final output (str): Hi Emma! Thank you for your patience.
The wait to get in is about 15 minutes.
Almost there—just enough time to start dreaming about that delicious Bruschetta! 🍽️
So we can show:
- The Customer creates his own menu through the agent, and ask for a recommendation to the Waiter Agent
- The Waiter recommends the Chianti and adds it to the list
- The Complaint handler agent communicates the wait to the customer
Now we can not only simulate the pipeline, like we were doing before, we have a smart pipeline, augmented with the same technology of ChatGPT. Isn’t that cool?
4. Conclusions
Thank you very much for being here with me, this means a lot ❤️.
Let’s go back to see what we have done in this article.
- Restaurnat System Design:
We generated a quick, Powerpoint generated system design of the restaurant with AI agents added. - Agent free baseline:
We first built a deterministic simulation so we could code in the queue logic, cooking times, and table turnover. This is our skeleton before doing any AI. - Agent based restaurant:
In this stage, we used AI Agents to fill in our complaint + action situation with the agents. We also did a GUI to show the results clearly.
Now, at this stage, I want to be very clear. I know this looks a little bit black mirror-ish. Simulating the customer? Simulating the restaurant and the waiter? Yes, it’s weird, but the problem is never the AI tool and always how it is used. I believe that replacing the human waiter with an AI is a losing game.
Being a waiter isn’t simply taking orders and recommending the N-th wine based on the N-1 wines that were ordered before. It’s a matter of being warm enough to make the guest feel welcome but distant enough not to intrude on their conversation, kind enough to make them feel at home but strong enough to make them respect your boundaries. It’s a mixture of qualities that I believe require a human touch, patience, and empathy.
That being said, I believe that the correct usage of this technology could be twofold:
- Helping real people who are being queued. Waiters inside are super busy, restaurants already offera menu to look at while you wait for your table, and it is unrealistic to think that other waiters entertain the people waiting without a table. At that stage, an AI companion to chat with could be helpful.
- Restaurant simulation. The script I wrote simulates the customer behavior as well. This means that, potentially, you could use the simulation to test different scenarios, see when queues are formed, hypothesize different reactions of people, and different waiters’ responses and so on. In other words, this could be your “digital twin” where you do tests.
- [Fill your thoughts here … 🙂] What do you think? Where could this be helpful?
5. About me!
Thank you again for your time. It means a lot ❤️
My name is Piero Paialunga, and I’m this guy here:

I am a Ph.D. candidate at the University of Cincinnati Aerospace Engineering Department. I talk about AI, and Machine Learning in my blog posts and on LinkedIn and here on TDS. If you liked the article and want to know more about machine learning and follow my studies you can:
A. Follow me on Linkedin, where I publish all my stories
B. Follow me on GitHub, where you can see all my code
C. Send me an email: [email protected]
D. Want to work with me? Check my rates and projects on Upwork!
Ciao.
P.S. My PhD is ending and I’m considering my next step for my career! If you like how I work and you want to hire me, don’t hesitate to reach out. 🙂