Overview

Have you ever tried to ask an LLM for a joke, and they either always tell the same one or give you a response that doesn’t make any sense?

In this example, we will use the Agent’s capability to think like a human using Chain Of Thought reasoning to generate a joke. The Agent will first think about the joke, then tell it to you.

Prompt

---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.

<assistant>
  Okay! Let's work together on this. How should we start?
</assistant>

Step-by-step guide

Related documentation:

Agent configuration

To build an autonomous Chain Of Thought reasoning structure, we want the AI to think as many times as they want to, and finally return a final answer. To do so, we just need to enable the agentic mode by setting the type to agent in the prompt configuration.

---
provider: openai
model: gpt-4o
type: agent
---

Read about Agentic behaviour for more information.

Prompt

Now, let’s first define the prompt. We want to add a simple description of the task, and an input topic given by the user.

---
provider: openai
model: gpt-4o
type: agent
---
You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

Improvin the chain of thought process

Finally, we’ll add a few instructions to help the agent think.

In this case, I will make the AI think it is made of a team of agents, even though it is just a single prompt. This works because each step the AI will generate a new message based on the whole previous conversation. While they normally expect that all assistant messages are from the same agent, we can just tell them that they’re collaborating with more AI assistants and make them rate each other’s jokes.

---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.

And just for giving the AI a little push, we can fake the first message of this conversation, so it can start thinking right away.

---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.

<assistant>
  Okay! Let's work together on this. How should we start?
</assistant>