You Probably Don’t Need an Agent Framework
Many developers rush to adopt complex agent frameworks, but often a simple loop with an LLM suffices. This article explains when to skip the overhead and how to build lightweight, effective AI agents.
Tags
Quick summary
Many developers rush to adopt complex agent frameworks, but often a simple loop with an LLM suffices. This article explains when to skip the overhead and how to build lightweight, effective AI agents.
You Probably Don’t Need an Agent Framework
The AI landscape is currently flooded with agent frameworks promising to simplify the development of autonomous systems. From LangChain to AutoGPT and Microsoft’s Semantic Kernel, these tools offer abstractions for planning, tool use, and memory. However, a growing number of practitioners argue that for most real-world use cases, you don’t need a heavy framework at all. This article explores why a minimal, direct approach often outperforms complex orchestration layers, and provides a concrete guide to building a simple agent using nothing more than the OpenAI API and standard Python.
Why Frameworks Can Be Overkill
Frameworks introduce dependencies, learning curves, and hidden behaviors. According to a recent analysis published on **Towards Data Science** (source 1), many agent frameworks abstract away critical decision-making logic, making debugging difficult and increasing latency. The core insight is that an “agent” is fundamentally a loop: a model that receives a prompt, decides on an action, executes it, and observes the result. You can implement this loop in under 100 lines of Python.
OpenAI’s own news (source 2) emphasizes function calling and structured outputs as the primary building blocks for agents. Microsoft’s AI Blog (source 3) similarly highlights that the most reliable autonomous systems use simple tool-calling patterns rather than monolithic orchestrators. Anthropic’s news (source 4) reinforces that effective agents are often just well-prompted models with a few external tools.
Requirements
Before we begin, ensure you have the following:
- Python 3.10 or higher installed on your system
- An OpenAI API key (with access to `gpt-4o` or `gpt-4-turbo`)
- Basic familiarity with the command line
- A code editor (VS Code recommended)
Step-by-Step Installation
We will create a minimal agent that can answer questions by performing web searches or calculations. No framework, no heavy dependencies.
Step 1: Set Up a Virtual Environment
Isolate your project dependencies to avoid conflicts.
python -m venv agent-env
source agent-env/bin/activate # On Windows: agent-env\Scripts\activateStep 2: Install Required Packages
We need only the OpenAI Python client and `requests` for optional HTTP calls.
pip install openai requestsStep 3: Set Your API Key
Store your key securely as an environment variable. Replace `your-key-here` with your actual key.
export OPENAI_API_KEY="your-key-here" # On Windows: set OPENAI_API_KEY=your-key-hereStep 4: Create the Agent Script
Create a file named `minimal_agent.py` and open it in your editor.
# minimal_agent.py
import json
import os
from openai import OpenAI
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
# Define available tools (functions the model can call)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"}
},
"required": ["city"]
}
}
},
{
"type": "function",
"function": {
"name": "calculate",
"description": "Perform a mathematical calculation",
"parameters": {
"type": "object",
"properties": {
"expression": {"type": "string", "description": "Math expression like '2+2'"}
},
"required": ["expression"]
}
}
}
]
# Simple tool implementations
def get_weather(city: str) -> str:
# In production, call a real weather API
return f"The weather in {city} is sunny, 22°C."
def calculate(expression: str) -> str:
try:
result = eval(expression) # Use with caution in production
return f"Result: {result}"
except Exception as e:
return f"Error: {str(e)}"
# Agent loop
def agent_loop(user_input: str, max_turns: int = 5):
messages = [{"role": "user", "content": user_input}]
for turn in range(max_turns):
response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tools,
tool_choice="auto"
)
assistant_message = response.choices[0].message
# If the model wants to call a tool
if assistant_message.tool_calls:
messages.append(assistant_message)
for tool_call in assistant_message.tool_calls:
function_name = tool_call.function.name
arguments = json.loads(tool_call.function.arguments)
if function_name == "get_weather":
result = get_weather(**arguments)
elif function_name == "calculate":
result = calculate(**arguments)
else:
result = f"Unknown function: {function_name}"
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": result
})
else:
# Model responded directly
return assistant_message.content
return "Max turns reached."
if __name__ == "__main__":
query = input("Enter your question: ")
print(agent_loop(query))**Explanation**: This script defines two tools (weather and calculator), implements the agent loop that calls the OpenAI API with function definitions, and processes tool calls automatically. The model decides when to use a tool versus when to answer directly.
Usage Examples
Example 1: Basic Question
Run the agent and ask a simple question.
python minimal_agent.pyWhen prompted, enter:
What is the capital of France?**Expected output**: The model will answer directly without calling any tools, returning something like "The capital of France is Paris."
Example 2: Tool-Assisted Question
Ask a question that requires a tool call.
python minimal_agent.pyEnter:
What is the weather in Tokyo?**Expected output**: The model identifies it needs the `get_weather` tool, calls it with `city="Tokyo"`, receives the result, and returns: "The weather in Tokyo is sunny, 22°C."
Example 3: Multi-Step Reasoning
Ask a question requiring calculation.
python minimal_agent.pyEnter:
What is 15 percent of 200?**Expected output**: The model calls the `calculate` tool with `expression="15/100*200"`, gets `Result: 30.0`, and responds: "15 percent of 200 is 30."
When a Framework Might Help
Despite the simplicity above, frameworks can be beneficial in specific scenarios:
- **Complex multi-agent systems** where agents need to communicate and delegate tasks to each other
- **Production-grade memory management** with vector databases and long-term context retention
- **Built-in observability** for tracing, logging, and debugging complex chains
- **Pre-built integrations** with dozens of external services and APIs
However, as the **Towards Data Science** article (source 1) notes, most projects never reach this complexity. Start without a framework; add complexity only when you have a proven need.
Conclusion
The hype around agent frameworks often obscures a simple truth: a basic loop with function calling handles the vast majority of autonomous tasks. By implementing your own minimal agent with the OpenAI API, you gain full control, reduced latency, and easier debugging. You avoid vendor lock-in and framework-specific bugs. The step-by-step guide above demonstrates that a working agent can be built in minutes with just the official client library.
Before adopting a framework, ask yourself: Does my use case truly require complex orchestration, or can I solve it with a direct API call and a few lines of Python? For most applications, the answer will be the latter. Start simple, iterate, and only reach for a framework when your specific needs demand it.
Sources
FAQ
What is this article about?
This article covers “You Probably Don’t Need an Agent Framework” in the AI agents category. Many developers rush to adopt complex agent frameworks, but often a simple loop with an LLM suffices. This article explains when to skip the overhead and how to build lightweight, effective AI agents.
Who is this useful for?
It is useful for readers who want a practical understanding of AI tools, models, and workflows.
What should I do next?
Read the article, review the listed sources, and test the most relevant ideas in your own workflow.



