Lecture 3: Building AI Agents (My Understanding)
From LLM to AI agent
This is how I understand an AI agent at a high level.
First there is an LLM (Large Language Model). But simply calling an LLM through an API does not make an AI agent. An LLM can only generate text. To make it useful in the real world, many extra layers are added on top of it.
Instructions (System Prompt)
First, the LLM is given instructions (a system prompt). These define:
- How the LLM should behave
- Which role it should work in
- What kind of responses it should give
Guardrails
Next, guardrails are added. There are two kinds.
Input guardrails
They validate the user's query, for example by detecting prompt injection, abusive input or a malicious request.
Output guardrails
They check the LLM's response, so that unsafe, harmful or incorrect information does not reach the user.
Tools
After that the LLM is given tools, because by itself an LLM cannot access a database, send an email, post a tweet or execute a payment. All of this happens through tools. For example:
- Database Read
- Database Write
- Send Email
- Tweet/Post
- Calendar
- Payment
- Search API
User approval
Not every tool runs automatically. Some sensitive actions need user approval.
For example, if the agent wants to make a payment or post a tweet on the user's behalf, it can ask the user to confirm first.
Rate limiting
Production systems also have rate limiting, so that no user can send too many requests and overload the system.
Context window management
Every LLM has a token limit. So the agent has to decide which information to keep in the context and which to remove. This process is called context window management.
Once all these layers are added on top of the LLM, you have a practical AI agent.
How OpenAI and Anthropic provide their models
OpenAI, Anthropic and Google do not offer their original models for public download. They only provide a REST API.
Our application
↓ API request
LLM running on their servers
↓ processing
Response sent backSo we do not interact with the model directly. We interact with it through the API.
Inside a REST API many steps happen:
- HTTP Request
- Authentication
- Parameters
- Response Code
- JSON Response
- Processing
An application developer only has to send the request and receive the response.
SDK and Agent SDK
You can use a REST API directly, but writing HTTP requests again and again is not convenient.
SDK
That is why companies provide an SDK. Its job is to make the API easy to use. With an SDK we just give the model an input and receive the output.
Agent SDK
When building an AI agent, a model call alone is not enough. That is where an Agent SDK comes in. It does not only call the model; it has many additional capabilities, such as:
- Prompt Management
- Tool Calling
- Guardrails
- Retry Mechanism
- Looping
- Agent Execution Flow
So an Agent SDK provides a higher-level abstraction for building AI agents.
Where the AI industry is heading
When powerful LLMs such as GPT and Claude arrived, people realised that the problem of basic text generation had largely been solved.
A very large part of the high-quality human-generated data available on the internet has already been used to train models.
The challenge now is not only to build a better LLM. It is to work out how to use LLMs in real-world applications.
That is why companies are focusing more on:
- Agent SDK
- MCP (Model Context Protocol)
- Tool Calling
- Memory
- Orchestration
- AI Applications
Today's competition is not only about building the "best model". It is about how to build the best AI application and the best AI agent.
What is a harness?
Put simply, a harness is about using the power of a technology effectively. In AI it means using an LLM's capabilities in the right way.
Just calling the model is not a harness. Adding prompts, tools, memory, guardrails and workflows around it to get the most out of its power is harnessing.
The role of LangChain
LangChain is not an LLM. It is a utility library that makes building AI applications easier.
It provides common features, so developers do not have to build everything from scratch:
- Prompt management
- Tool calling
- Memory
- Retrieval
- Orchestration
My overall understanding
Building an AI agent is not just about using an LLM. A production-ready AI agent needs multiple layers on top of the LLM:
- Instructions
- Guardrails
- Tools
- Memory
- Context Management
- Approval System
- Rate Limiting
- Retry Logic
- Orchestration
REST APIs and SDKs give us an interface to use a model, while an Agent SDK provides higher-level features for building AI agents.
Today the AI industry is focused not only on creating new models, but on using those models to build intelligent AI applications and AI agents.
Two important clarifications
Training data
It would be misleading to say that companies have stopped creating new models. The accurate version is:
High-quality human-generated training data is becoming limited. So companies are focusing not only on new models, but also on building AI agents, SDKs, MCP and applications.
AI-generated data
"AI cannot be trained on AI-generated data" is not an absolute truth either. The accurate version is:
Training on AI-generated data is possible, but using too much of it without filtering can degrade model quality. That is why companies value curated, high-quality data.