The Tools Landscape for LLM Pipelines Orchestration (Part 2)

Autonomous Agentic Frameworks

By Damien Benveniste

Published: 2024-12-23

URL: https://newsletter.theaiedge.io/p/the-tools-landscape-for-llm-pipelines-ee3



The Autonomous Agentic frameworks provide a seductive abstraction to build LLM-based agentic software. At their core, they automated a lot of the complexity around the implementation of agents and the way they interact. They can actually be considered as wrappers around event-based stateful graph orchestrators (I tend to call that “macro-orchestration“) to handle the complexity around the application flow and around micro-orchestrators to handle LLM-specific flow of data and API connections.

There are a few Autonomous Agentic frameworks out there, but the biggest ones are Autogen and CrewAI. LangRoid and Genworlds are simpler options that start to have some success as well. We can also note the newer OpenAI Swarm package that focuses on implementing the handoff and routines patterns.

Agents and Tasks

LLM-based agents are simple! They can be described as a combination of:

The core idea behind those agentic frameworks is to restructure the pipeline orchestration by abstracting the application flow as multiple agents collaborating by exchanging messages.

To scale the complexity, we introduce more agents exchanging messages in a structured manner. The hierarchical structure is often used and tends to resemble the corporate organization structure.

For example, in CrewAI, we create an agent as follows:


from crewai import Agent
from crewai_tools import SerperDevTool
role = '{topic} Senior Data Researcher'
goal = 'Uncover cutting-edge developments in {topic}'
backstory = (
"You're a seasoned researcher with a knack for uncovering the latest "
"developments in {topic}. Known for your ability to find the most relevant "
"information and present it in a clear and concise manner."
)
agent = Agent(
llm='gpt-4o-mini',
tools=[SerperDevTool()],
role=role,
goal=goal,
backstory=backstory
)

The role, goal, and backstory are just a way to deconstruct the system prompt in a user-friendly manner:


agent.agent_executor.prompt['system']
> You are {topic} Senior Data Researcher. You're a seasoned researcher with a knack for uncovering the latest developments in {topic}. Known for your ability to find the most relevant information and present it in a clear and concise manner.
Your personal goal is: Uncover cutting-edge developments in {topic}
You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:
{tools}
Use the following format:
Thought: you should always think about what to do
Action: the action to take, only one name of [{tool_names}], just the name, exactly as it's written.
Action Input: the input to the action, just a simple python dictionary, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action
Once all necessary information is gathered:
Thought: I now know the final answer
Final Answer: the final answer to the original input question

This is a typical ReAct prompt where we present the available tools to the LLM, and we push it to iterate through Though, Action and Observation. The specific task is passed as a user message:


agent.agent_executor.prompt['user']
> Current Task: {input}
Begin! This is VERY important to you, use the tools available and give your best Final Answer, your job depends on it!
Thought:

And we can pass a task to the agent:


from crewai import Task
research_task = Task(
description="""
Conduct a thorough research about AI Agents.
Make sure you find any interesting and relevant information given
the current year is 2024.
""",
expected_output="""
A list with 10 bullet points of the most relevant information about AI Agents
"""
)
agent.execute_task(research_task)
> 1. \*\*Market Growth\*\*: The AI agents market is projected to grow from USD 5.1 billion in 2024 to USD 47.1 billion by 2030, with a compound annual growth rate (CAGR) of 44.8% during this period. (Source: GlobeNewswire)
2. \*\*Rise of Frameworks\*\*: In 2024, there has been significant growth in AI agent building frameworks such as AutoGen, CrewAI, LangGraph, and LlamaIndex, which simplify the process of creating AI agents. (Source: Analytics Vidhya)
3. \*\*Generative AI Expansion\*\*: Key innovations in generative AI continue to shape AI agents, with milestones marking advancements in their functionalities throughout 2024. (Source: Channel Insider)
4. \*\*Hyperautomation\*\*: There is a noticeable shift towards hyperautomated processes in enterprises, combining AI, machine learning, and automation for broader AI adoption, which heavily involves AI agents. (Source: Activepieces)
5. \*\*Composite Systems\*\*: The evolution of AI systems is moving towards modular and composite systems, allowing AI agents to solve complex tasks more efficiently. (Source: PCG)
6. \*\*Revenue Impact\*\*: AI agents are predicted to generate $280 billion in new software sales revenue by 2032, indicating significant financial impact and relevance in the tech landscape. (Source: GetOdin)
7. \*\*Sustainability Goals\*\*: Approximately 66% of organizations deploying AI agents report that these systems help in achieving their sustainability objectives, showcasing an important application for AI technologies. (Source: GetOdin)
8. \*\*GenAI Platform Integration\*\*: DigitalOcean's new GenAI Platform enables developers to easily incorporate AI agent capabilities into their applications, indicating a trend towards democratizing access to AI technologies. (Source: DigitalOcean)
9. \*\*Agent-First Applications\*\*: There is a growing trend towards "agent-first" applications that prioritize integrating AI functionalities from the onset, which is redefining development approaches in AI. (Source: Medium)
10. \*\*Framework Comparisons\*\*: A variety of AI agent frameworks have emerged, and their pros and cons are being thoroughly analyzed, helping developers choose the best tools for their needs in 2024. (Source: Chatbase)

Note that the agent works as a typical ReAct:

In Autogen, the way we define “agents“ and how they interact is a bit different. The decision engine and the tool executor are separated into different agents, and instead of iterating on the same agent, we have two agents having a “conversation“:

So, because agentic conversations arise by binding agents together in Autogen, there is no explicit concept of “tasks“. By default, Autogen agents can execute code, and there is no tool available other than the custom user-defined tools.

Autogen might put a stronger emphasis on the human-in-loop concept by designing agents that are meant to interact with humans:


import autogen
config_list = [{
"model": "gpt-4o-mini", "api_key": os.environ['OPENAI_API_KEY']
}]
llm_config = {
"timeout": 600,
"cache_seed": 42,
"config_list": config_list,
"temperature": 0,
}
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="TERMINATE",
max_consecutive_auto_reply=10,
is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
llm_config=llm_config,
system_message="""
Reply TERMINATE if the task has been solved at full satisfaction.
Otherwise, reply CONTINUE, or the reason why the task is not solved yet.
"""
)

This agent will take the user’s message and send it to another agent. As the agents exchange messages, the user proxy will stop the iterative process either because of an upper bound on the number of iterations or because it determined that the user query has been answered.


assistant = autogen.AssistantAgent(
name="assistant",
llm_config=llm_config,
)
user_proxy.initiate_chat(
assistant,
message="""
Conduct a thorough research about AI Agents.
Make sure you find any interesting and relevant information given
the current year is 2024.
"""
)

First, the user proxy passes the user query to the assistant:

user_proxy (to assistant):

Conduct a thorough research about AI Agents. Make sure you find any interesting and relevant information given the current year is 2024.

Then, the assistant replies by providing a code that should lead to getting more information:

assistant (to user_proxy):

To conduct thorough research on AI Agents, I will gather information from various sources, including recent articles, papers, and news related to AI Agents in 2024. This will include their applications, advancements, and any notable trends or developments.

I will start by searching for relevant information online.

Let’s proceed with the search.

```

```python import requests from bs4 import BeautifulSoup

Function to search for articles about AI Agents in 2024

def search_ai_agents(): query = “AI Agents 2024” url = f”https://www.google.com/search?q={query}” headers = {‘User-Agent’: ‘Mozilla/5.0’} response = requests.get(url, headers=headers) soup = BeautifulSoup(response.text, ‘html.parser’)

Extracting titles and links of the articles

articles = [] for g in soup.find_all(‘div’, class_=’BVG0Nb’): title = g.find(‘h3’).text link = g.find(‘a’)[‘href’] articles.append((title, link)) return articles

Execute the search

ai_agents_articles = search_ai_agents() for title, link in ai_agents_articles: print(f”Title: {title}\nLink: {link}\n”) ```

```

This code will search for articles about AI Agents in 2024 and print the titles and links of the articles found. I will execute this code to gather the information.

The user proxy executes the code but gets an error, so it provides the information to the assistant:

>>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)…

Pulling image python:3-slim

user_proxy (to assistant):

```

exitcode: 1 (execution failed) Code output: Traceback (most recent call last): File “”, line 1, in import requests ModuleNotFoundError: No module named ‘requests’ ```

After a few back-and-forths, the assistant addressed all the errors and provided a script that led to useful information:

assistant (to user_proxy):

It appears that the chardet module is also not available in the execution environment. Given the limitations, I will simplify the approach and provide a script that does not rely on external libraries. Instead, I will use a basic method to read the response without attempting to decode it. This will allow us to see the raw HTML content, which may still contain useful information.

Here’s the revised Python code:

```

```python

filename: search_ai_agents.py

import http.client import urllib.parse

Function to search for articles about AI Agents in 2024

def search_ai_agents(): query = “AI Agents 2024” params = urllib.parse.urlencode({‘q’: query}) conn = http.client.HTTPSConnection(“www.google.com”) conn.request(“GET”, f”/search?{params}”) response = conn.getresponse()

Read the response

data = response.read()

Print the raw HTML content

print(data)

Execute the search

search_ai_agents() ```

```

Please save this code in a file named search\_ai\_agents.py and execute it. This version will print the raw HTML content of the search results. Let me know if you were able to retrieve the information successfully.

Now, the user proxy provides the result of the code execution to the assistant:

>>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)…

user_proxy (to assistant):

```

exitcode: 0 (execution succeeded) Code output: b’<!doctype html>AI Agents 2024 - Google Search