<< back to Guides

AI Core Concepts (Part 14): AI Agents

AI Agents are autonomous systems that can perceive their environment, make decisions, and take actions toward achieving goals. Unlike simple models, agents often act in a loop, learn from outcomes, and adjust behavior over time.


1. What Is an AI Agent?

An AI Agent typically follows the perception → decision → action cycle.


2. Types of AI Agents

Agent Type Description
Reactive Agent Responds to current input (no memory/learning)
Reflex Agent Uses rules to map inputs to actions
Goal-Based Agent Chooses actions to achieve specific goals
Learning Agent Improves over time using data/experience
Planning Agent Builds plans by simulating outcomes

3. Basic AI Agent Structure (Pseudocode)

while True:
    observation = agent.observe(env)
    action = agent.decide(observation)
    env.update(action)
    agent.learn(observation, action, env.feedback())

4. AI Agents vs Standard Models

Feature Standard ML Model AI Agent
Passive or Active Passive (predict-only) Active (acts in environment)
One-shot inference Yes No, typically multi-step
Learning approach Supervised, Unsupervised Often Reinforcement Learning
Autonomy Low High

5. Example Use Cases


6. Example: Agent with LangChain + OpenAI

from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI
from langchain.tools import DuckDuckGoSearchRun

search = DuckDuckGoSearchRun()
tools = [Tool(name="Search", func=search.run, description="Useful for answering factual questions")]

agent = initialize_agent(
    tools,
    llm=OpenAI(temperature=0),
    agent="zero-shot-react-description",
    verbose=True
)

agent.run("What's the weather in Berlin today?")

7. Memory & Planning (Advanced Agents)

Agents can use memory to store conversation history or past observations.

# Pseudocode for a planning agent
goal = "Book a flight and hotel to Paris"
plan = planner.decompose(goal)
for step in plan:
    agent.execute(step)

8. Frameworks for Building AI Agents


📚 Further Resources


<< back to Guides