Back to blog
Articles
Articles
August 28, 2023
·
4 min read

Two LLM Based Autonomous Agents Debate Each Other

August 28, 2023
|
4 min read

Latest content

Customer Stories
4min read

Lightspeed Uses HumanFirst for In-House AI Enablement

Meet Caroline, an analyst-turned-AI-expert who replaced manual QA, saved countless managerial hours, and built new solutions for customer support.
December 10, 2024
Customer Stories
4 min read

How Infobip Generated 220+ Knowledge Articles with Gen AI For Smarter Self-Service and Better NPS

Partnering with HumanFirst, Infobip generated over 220 knowledge articles, unlocked 30% of their agents' time, and improved containment by a projected 15%.
September 16, 2024
Articles
7 min read

Non-Technical AI Adoption: The Value of & Path Towards Workforce-Wide AI

Reviewing the state of employee experimentation and organizational adoption, and exploring the shifts in thinking, tooling, and training required for workforce-wide AI.
September 12, 2024
Articles
6 min read

AI for CIOs: From One-Off Use to Company-Wide Value

A maturity model for three stages of AI adoption, including strategies for company leaders to progress to the next stage.
September 12, 2024
Tutorials
4 min read

Building Prompts for Generators in Dialogflow CX

How to get started with generative features.
August 15, 2024
Announcements
3 min read

HumanFirst and Infobip Announce a Partnership to Equip Enterprise Teams with Data + Generative AI

With a one-click integration to Conversations, Infobip’s contact center solution, HumanFirst helps enterprise teams leverage LLMs to analyze 100% of their customer data.
August 8, 2024
Tutorials
4 min read

Two Field-Tested Prompts for CX Teams

Get deeper insights from unstructured customer data with generative AI.
August 7, 2024
Tutorials
5 min read

Optimizing RAG with Knowledge Base Maintenance

How to find gaps between knowledge base content and real user questions.
April 23, 2024
Customer Stories
4min read

Lightspeed Uses HumanFirst for In-House AI Enablement

Meet Caroline, an analyst-turned-AI-expert who replaced manual QA, saved countless managerial hours, and built new solutions for customer support.
December 10, 2024
Customer Stories
4 min read

How Infobip Generated 220+ Knowledge Articles with Gen AI For Smarter Self-Service and Better NPS

Partnering with HumanFirst, Infobip generated over 220 knowledge articles, unlocked 30% of their agents' time, and improved containment by a projected 15%.
September 16, 2024
Articles
7 min read

Non-Technical AI Adoption: The Value of & Path Towards Workforce-Wide AI

Reviewing the state of employee experimentation and organizational adoption, and exploring the shifts in thinking, tooling, and training required for workforce-wide AI.
September 12, 2024

Let your data drive.

Articles

Two LLM Based Autonomous Agents Debate Each Other

COBUS GREYLING
August 28, 2023
.
4 min read

This working code example using the LangChain framework illustrates how two agents can debate each other after each agent has been assigned a persona and an objective. The agents have access to tools which they can leverage for their response.

As you will see below, after examining the LangSmith trace, that the LLM forms the backbone of the application and the tools provide relevant and up-to-date information.

In this LangChain example we have two Autonomous Agents having a conversation; one is named AI accelerationist and the other AI alarmist.

The two personas are described to the LLM in the following way:

AI accelerationist: A passionate visionary who sees the potential of automation and artificial intelligence as a catalyst for transformative progress. Fueled by an unwavering belief in technological advancement, you advocate for embracing and accelerating AI’s rise, confident that it will reshape industries, lead to an abundance of opportunities, and ultimately improve society.

AI alarmist: A cautious observer of technological advancements. With a mind steeped in apprehension, you perceive the growth of automation and AI as an impending threat. Your anxiety fuels your skepticism, pushing you to question the potential consequences of these technologies on the labor market and job security.

Both agents have access to the following tools to use for information retrieval to support its arguments:

  • Arxiv
  • Duck-Duck-Go Search
  • Wikipedia

The topic for the discussion is:

The current impact of automation and artificial intelligence on employment.

And the brief for each agent:

Your name is {name}.
Your description is as follows: {description}
Your goal is to persuade your conversation partner of your point of view.
DO look up information with your tool to refute your partner’s claims.
DO cite your sources.
DO NOT fabricate fake citations.
DO NOT cite any source that you did not look up.
Do not add anything else.
Stop speaking the moment you finish speaking from your perspective.

And here is the dialog between the two autonomous agents, the dialog are restricted to 6 dialog turns. The input from the moderator is in green:

With the response from the AI Alarmist in red and the AI Accelerationist in blue:

Below the completion of the six dialog turns:

Considering the view of LangChain below, it is clear how the latency increases as the prompt grows with each dialog turn. The tokens used also increase.

Here the trace is visible, with the sequence of events and the tools used are shown.

The complete code is listed here, this can be copied and pasted into any notebook and run. The only requirements are an OpenAI API Key, SerpAPI API Key and LangSmith API Key.

I’m currently the Chief Evangelist @ HumanFirst. I explore & write about all things at the intersection of AI & language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces & more.

Subscribe to HumanFirst Blog

Get the latest posts delivered right to your inbox