TL;DR
An AI agent is an LLM running in a loop with access to tools (search, code execution, APIs). It picks a tool, reads the result and decides the next step until the goal is reached. That loop is what separates an agent from a chatbot that only answers messages.
Chatbot vs agent: what's the difference?
A plain LLM call is one request and one response. The model only sees what you put in the prompt, including any conversation history you send along, and it can't act outside that text: no searching, no API calls, no running code.
An agent wraps the model in a loop and gives it tools. The model can decide to call a tool, read the result and keep going for several steps until the task is done. The model does the reasoning; your code runs the tools and enforces the limits.
Example: "Book me a flight to Paris next Friday under 400€." A chatbot can explain how to search for flights. An agent with the right tools can run the search, compare prices and make the booking, ideally with a confirmation step before it pays.
How the loop works
- It receives a goal ("Find the cheapest flight to Paris")
- The model decides which tool to call (search, calculator, browser, an API)
- Your code runs the tool and passes the result back
- The model checks the result: is the goal reached?
- If not, it plans the next step and the loop continues
- Once it's done (or hits a step limit), it returns the final answer
What tools can agents use?
# Common agent tools:
- Web search (Tavily, SerpAPI)
- Code execution (run Python, JS)
- File read/write
- API calls (send email, create calendar event)
- Browser automation (Playwright, Puppeteer)
- Database queries
- Calculator / math
- Memory (vector databases like Pinecone)
A simple agent in Python
# pip install langchain langchain-openai langchain-community ddgs
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from langchain_community.tools import DuckDuckGoSearchRun
# Define tools
tools = [DuckDuckGoSearchRun()]
# Create agent
agent = create_agent(
model=ChatOpenAI(model="gpt-4o-mini"),
tools=tools,
system_prompt="You are a research assistant. Use search when you need fresh data.",
)
# Run it
result = agent.invoke({
"messages": [{"role": "user", "content": "What's the current price of Bitcoin in TND?"}]
})
print(result["messages"][-1].content)
For Tunisian businesses, the realistic use cases are customer service bots, data extraction from documents, legal document analysis and monitoring in agriculture. Most of these are narrow agents with a handful of tools, not general-purpose assistants.
Popular agent frameworks
LangChain and LangGraph are the most widely used in Python. AutoGen, from Microsoft, focuses on systems where several agents talk to each other. CrewAI organizes agents into roles that work as a team. Anthropic's Claude Agent SDK targets production agents. For a first project, one model with two or three well-described tools will teach you more than any framework.
Where this is going
More software will be built this way: instead of hardcoding every path through the logic, you give a model tools and constraints and let it work out the steps. That brings its own problems (cost, latency, reliability, testing), and the developers who understand both the loop and how it fails will be the ones who build these systems well.