Most up-to-date AI & Gen AI coaching for senior IT professionals
Creating Conversational AI Agents for Stand-Up Comedy Using AutoGen

Can AI Agents do standup comedy?
Moreover, can one AI agent create a counter joke on the punchline from the other AI agent?
Namaste and Welcome to Build It Yourself.
In this article, we will learn how to build such a multi-AI agent system using Autogen while having some fun.
Creating Conversational AI Agents for Stand-Up Comedy Using AutoGen
There are 2 AI Agents
- The first AI Agent will start a joke, and
- The second AI Agent will create a counter joke and this system will go on for a few rounds
If you are an entrepreneur or a senior IT professional and looking to learn AI + LLM in a simple language, check out the courses and other details – https://www.aimletc.com/online-instructor-led-ai-llm-coaching-for-it-technical-professionals/
You can find the code notebook here – https://github.com/tayaln/Multi-AI-Agent-Standup-Comedy
To use it, download and then upload it to your Google Drive and open it as a Google Colab file.
Pre-requisite
– An Open Mind to learn new things
– OpenAI account
– OpenAI API Key
Concepts we discussed in this article
- AutoGen framework for conversable agents
- Creating a basic AI agent
- Multi-agent system interaction
- Generating jokes using AI agents
- Setting up conversation flow between AI agents
- Tracking chat history and cost analysis
- Implementing termination conditions for AI conversations
Step 1 – Setting Up the Environment
Before diving into AI-driven humour, we need to set up our environment by installing the necessary dependencies.
Next, import the necessary modules and set up your OpenAI API key
We will be using GPT-3.5 Turbo as our language model, but you can experiment with other models such as GPT-4.

Step 2 – Creating Conversational AI Agents
The goal is to build two AI agents that engage in a stand-up comedy dialogue. One agent will generate jokes, while the other will create new jokes using the punchline from the first agent.
Defining a Simple AI Agent
This simple agent generates jokes when prompted. The human_input_mode is set to “never,” meaning no human intervention is required.

Step 3 – Creating a Multi-Agent System
Now, let’s define two AI agents that interact with each other:

Now, initiate the chat where V2 builds upon J’s joke:

Example AI Conversation
Veeru (to Jai): I’m Veeru. Jai, let’s keep the PJs rolling.
——————————————————————————–
Jai (to Veeru): Hey Veeru! You know, I tried to write a joke about construction, but I’m still working on it.
——————————————————————————–
Veeru (to Jai): Well, looks like you’re building up to something big!
——————————————————————————–
Jai (to Veeru): Haha, exactly! I’m laying the foundation for some good laughs.
——————————————————————————–
Veeru (to Jai): You’re really nailing it with those construction puns!
——————————————————————————–
Jai (to Veeru): Thanks, Veeru! I guess you could say I’m built for this kind of humor.
——————————————————————————–
This showcases how two AI agents can engage in an amusing exchange by building on each other’s jokes.
Step 4 – Tracking Chat History and Costs
AutoGen also allows us to track the chat history and costs incurred:

Step 5 – Terminating the Conversation
To set up a termination condition, we can define a stopping message:

Now, the conversation will stop when either agent says “I gotta go.”


Conclusion
This project demonstrates the potential of AutoGen in creating conversable AI agents. While we used stand-up comedy as a playful example, similar methods can be applied to other use cases like customer support, storytelling, or even educational tutoring.
Try experimenting with different joke styles, languages, or even non-humorous dialogues to see what AI can achieve!
Stay tuned for more AI experiments!
Connect with me on LinkedIn – https://www.linkedin.com/in/nikhileshtayal/
Here is how I learned AI as a non-technical person in 4 months for free.
Let’s learn to build a basic AI/ML model in 4 minutes (Part 1)
Happy learning!