Skip to content

AI Agents — Autonomous Systems Explained

DodaTech Updated 2026-06-20 10 min read

In this tutorial, you'll learn about AI Agents. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

An AI agent is an autonomous software system that perceives its environment, makes decisions, and takes actions to achieve specific goals — moving beyond passive prediction to active, goal-oriented behavior.

What You'll Learn

You'll understand what AI agents are, how they differ from traditional AI models, the key components of agent architecture (tools, memory, planning), and how to build your own autonomous agent using Python and LangChain.

Why It Matters

AI agents represent the next evolution of artificial intelligence. Instead of just answering questions, agents can book flights, analyze security incidents, write and execute code, and orchestrate complex workflows autonomously. Major companies are investing billions in agentic AI.

Real-World Use

A security analyst receives 500 alerts per day. An AI agent autonomously investigates each alert — checking IP reputation databases, correlating with past incidents, scanning logs, and escalating only confirmed threats to the human analyst. This turns hours of manual work into minutes of review.

What Makes an AI Agent?

flowchart TD
  A[Environment] --> B[Perception]
  B --> C[Agent Core]
  C --> D[Memory]
  C --> E[Planning]
  C --> F[Tools]
  F --> G[Act]
  G --> A
  D --> H[Short-term Memory]
  D --> I[Long-term Memory]
  E --> J[Goal Decomposition]
  E --> K[Re-evaluation]

An AI agent has four key components:

Component What It Does Example
Perception Gathers info from the environment Reads an email, queries an API
Reasoning/Planning Decides what to do next "I need to check the sender's reputation"
Tools Actions the agent can take Send email, query database, execute code
Memory Stores past interactions and knowledge "This IP was flagged yesterday"

Types of AI Agents

Simple Reflex Agents

React to current input only — no memory, no state.

# A simple reflex agent for email classification
class SimpleReflexAgent:
    def act(self, email):
        if "malware" in email["subject"].lower():
            return "BLOCK"
        if "phishing" in email["body"].lower():
            return "QUARANTINE"
        return "PASS"

agent = SimpleReflexAgent()
emails = [
    {"subject": "Important: malware detected", "body": "Please review"},
    {"subject": "Team lunch", "body": "Let's meet at 1pm"},
    {"subject": "Your account", "body": "Phishing attempt detected"},
]

for email in emails:
    action = agent.act(email)
    print(f"Subject: '{email['subject']}' → {action}")

Expected output:

Subject: 'Important: malware detected' → BLOCK
Subject: 'Team lunch' → PASS
Subject: 'Your account' → QUARANTINE

Model-Based Agents

Maintain internal state about the world — they remember past observations.

# A model-based agent with memory of past threats
class ModelBasedAgent:
    def __init__(self):
        self.blocked_ips = set()
        self.known_patterns = []

    def analyze_request(self, ip_address, payload):
        # Check known threats
        if ip_address in self.blocked_ips:
            return "BLOCK"

        # Check payload against known attack patterns
        for pattern in self.known_patterns:
            if pattern in payload:
                self.blocked_ips.add(ip_address)
                return "BLOCK"

        # Learn new patterns from suspicious but not confirmed requests
        if "DROP TABLE" in payload or "/etc/passwd" in payload:
            self.known_patterns.append(payload[:50])
            self.blocked_ips.add(ip_address)
            return "BLOCK_AND_LEARN"

        return "ALLOW"

agent = ModelBasedAgent()

requests = [
    ("192.168.1.1", "GET /index.html"),
    ("10.0.0.5", "SELECT * FROM users; DROP TABLE accounts; --"),
    ("10.0.0.5", "GET /admin"),
    ("192.168.1.1", "GET /etc/passwd"),
]

for ip, payload in requests:
    action = agent.analyze_request(ip, payload)
    print(f"  {ip:15s}{action}")
    print(f"    Payload: {payload[:50]}{'...' if len(payload) > 50 else ''}")

print(f"\nBlocked IPs after session: {agent.blocked_ips}")

Expected output:

  192.168.1.1    → ALLOW
  10.0.0.5       → BLOCK_AND_LEARN
    Payload: SELECT * FROM users; DROP TABLE accounts; --
  10.0.0.5       → BLOCK
    Payload: GET /admin
  192.168.1.1    → BLOCK_AND_LEARN
    Payload: GET /etc/passwd

Blocked IPs after session: {'10.0.0.5', '192.168.1.1'}

The agent learns over time — once it blocks an IP, every subsequent request from that IP is automatically denied. This is how modern intrusion prevention systems work.

Building an AI Agent with LangChain

Let's build a security investigation agent using LangChain that can query tools and reason about threats.

# A simple tool-using agent (conceptual)
import json
from datetime import datetime

class SecurityAgent:
    def __init__(self):
        self.tools = {
            "check_ip_reputation": self.check_ip_reputation,
            "search_logs": self.search_logs,
            "scan_file": self.scan_file,
        }
        self.memory = []

    def check_ip_reputation(self, ip):
        # Simulates querying a threat intelligence feed
        known_malicious = {"45.33.32.156", "185.220.101.1", "91.121.87.34"}
        result = {
            "ip": ip,
            "malicious": ip in known_malicious,
            "reports": 12 if ip in known_malicious else 0,
            "last_seen": "2026-06-15" if ip in known_malicious else None,
        }
        return result

    def search_logs(self, query):
        # Simulates log search
        return {
            "matches": 3,
            "sample": f"Multiple {query} attempts from external IP",
            "timeframe": "last 24 hours",
        }

    def scan_file(self, filename):
        # Simulates file scanning
        suspicious_files = {"document.exe", "invoice.pdf.scr"}
        result = {
            "filename": filename,
            "malicious": filename in suspicious_files,
            "risk_score": 85 if filename in suspicious_files else 5,
        }
        return result

    def investigate_alert(self, alert):
        print(f"🔍 Investigating alert: {alert['title']}\n")

        steps = []
        self.memory.append({"alert_id": alert["id"], "timestamp": datetime.now()})

        # Step 1: Check IP reputation
        if "ip" in alert:
            ip_result = self.tools["check_ip_reputation"](alert["ip"])
            steps.append(f"IP reputation check: {'MALICIOUS' if ip_result['malicious'] else 'CLEAN'}")
            if ip_result["malicious"]:
                steps.append(f"  → {ip_result['reports']} threat reports found")

        # Step 2: Search logs
        log_result = self.tools["search_logs"](alert.get("indicator", ""))
        steps.append(f"Log search: {log_result['matches']} matches in {log_result['timeframe']}")
        steps.append(f"  Sample: {log_result['sample']}")

        # Step 3: Scan related files
        if "file" in alert:
            file_result = self.tools["scan_file"](alert["file"])
            status = "MALICIOUS" if file_result["malicious"] else "CLEAN"
            steps.append(f"File scan ({alert['file']}): {status}")
            if file_result["malicious"]:
                steps.append(f"  Risk score: {file_result['risk_score']}/100")

        # Decision
        malicious_count = sum(1 for s in steps if "MALICIOUS" in s)
        if malicious_count >= 2:
            decision = "ESCALATE TO HUMAN"
        elif malicious_count == 1:
            decision = "QUARANTINE AND MONITOR"
        else:
            decision = "CLOSE - FALSE POSITIVE"

        for step in steps:
            print(f"  {step}")

        print(f"\n  Decision: {decision}")
        self.memory[-1]["decision"] = decision

        return decision

# Simulate alerts
agent = SecurityAgent()

alert1 = {
    "id": "ALERT-001",
    "title": "Multiple failed login attempts",
    "ip": "45.33.32.156",
    "indicator": "brute force",
    "file": "document.exe",
}
agent.investigate_alert(alert1)

Expected output:

🔍 Investigating alert: Multiple failed login attempts

  IP reputation check: MALICIOUS
    → 12 threat reports found
  Log search: 3 matches in last 24 hours
    Sample: Multiple brute force attempts from external IP
  File scan (document.exe): MALICIOUS
    Risk score: 85/100

  Decision: ESCALATE TO HUMAN

Agent Memory and Planning

Two capabilities separate simple agents from sophisticated ones:

Memory Types

Type Duration Purpose Example
Short-term Current session Context for this task Steps taken so far
Long-term Persistent Knowledge across sessions Known malicious IPs
Episodic Past sessions Learning from experience "Last time this pattern meant X"

Planning

Advanced agents don't just react — they plan. Given a goal, they break it into sub-tasks, execute them, and adapt when things go wrong.

# A simple planning agent
class PlanningAgent:
    def __init__(self):
        self.tools = {
            "search_web": self.search_web,
            "analyze_code": self.analyze_code,
            "write_report": self.write_report,
        }

    def search_web(self, query):
        return f"Results for: {query}"

    def analyze_code(self, code):
        return {"vulnerabilities": 2, "lines": 150}

    def write_report(self, content):
        return f"Report written: {len(content)} chars"

    def plan_and_execute(self, goal):
        print(f"Goal: {goal}\n")

        # Decompose into sub-tasks
        plan = [
            "1. Search for known vulnerabilities",
            "2. Analyze the codebase",
            "3. Cross-reference findings",
            "4. Write security report",
        ]

        print("Plan:")
        for step in plan:
            print(f"  {step}")

        print("\nExecuting...")
        results = []
        results.append(self.search_web("known vulnerabilities in dependency"))
        results.append(f"Found {self.analyze_code({'code': 'sample.py'})['vulnerabilities']} vulnerabilities")
        results.append("Cross-reference complete: 2 CVEs match")
        results.append(self.write_report("Security audit results"))

        for r in results:
            print(f"  → {r}")

        return "✅ Report generated: security_audit_2026_06_20.pdf"

agent = PlanningAgent()
result = agent.plan_and_execute("Audit codebase for security vulnerabilities")
print(f"\nFinal: {result}")

Expected output:

Goal: Audit codebase for security vulnerabilities

Plan:
  1. Search for known vulnerabilities
  2. Analyze the codebase
  3. Cross-reference findings
  4. Write security report

Executing...
  → Results for: known vulnerabilities in dependency
  → Found 2 vulnerabilities
  → Cross-reference complete: 2 CVEs match
  → Report written: 27 chars

Final: ✅ Report generated: security_audit_2026_06_20.pdf

Learning Path: Where AI Agents Fit

flowchart LR
  A[AI Overview] --> B[Machine Learning]
  B --> C[Deep Learning]
  C --> D[NLP]
  D --> E[Large Language Models]
  E --> F[AI Agents]
  F --> G[Tool Use]
  F --> H[Memory Systems]
  F --> I[Autonomous Planning]
  G --> J["RPA / Automation"]
  I --> K[Multi-Agent Systems]

Security Implications of AI Agents

AI agents create a new attack surface. Understanding these risks is critical:

Risk Description Mitigation
Tool misuse Agent executes dangerous commands Sandbox all tool executions
Prompt Injection Malicious input hijacks agent behavior Input sanitization, Least Privilege
Data leakage Agent shares sensitive info with external tools Data loss prevention, audit logs
Goal misalignment Agent optimizes for wrong objective Human-in-the-loop validation
Over-reliance Humans trust agent decisions blindly Confidence scoring, forced review

DodaTech's approach: Security agents built on DodaTech platforms follow the principle of Least Privilege — agents can only access the minimum tools and data needed for their task. All agent actions are logged and auditable. No agent can make destructive changes without human approval.

Common Errors Beginners Make

1. Giving Agents Too Much Autonomy

Agents should escalate to humans for high-stakes decisions. Always define a "human-in-the-loop" threshold for critical actions.

2. Not Validating Tool Outputs

An agent's reasoning is only as good as the information it receives. If a tool returns bad data, the agent makes bad decisions. Always validate tool outputs before acting on them.

3. Ignoring Security Boundaries

Agents that can access the file system, execute code, or call APIs without restrictions are dangerous. Apply the principle of Least Privilege rigidly.

4. Lack of Observability

If you can't see what your agent is doing, you can't debug or audit it. Log every action, every decision, and every tool call with timestamps.

5. No Failsafe Mechanism

Agents can enter infinite loops, consume excessive resources, or make escalating bad decisions. Implement timeouts, max-iteration limits, and circuit breakers.

6. Ambiguous Goal Specification

"Investigate this alert" is too vague. The agent might query 20 different tools. Define clear success criteria and escalation paths.

7. Over-Engineering

Not every problem needs a complex agent. Sometimes a simple if-else chain or a reflex agent is perfectly adequate. Start simple, add complexity only when needed.

Practice Questions

  1. What are the four key components of an AI agent? Perception, reasoning/planning, tools, and memory.

  2. How does a model-based agent differ from a simple reflex agent? A model-based agent maintains internal state about the world, allowing it to remember past observations and adapt behavior accordingly.

  3. What is the difference between short-term and long-term memory in agents? Short-term memory lasts for the current session (conversation context, current task steps). Long-term memory persists across sessions (user preferences, learned knowledge).

  4. Why are AI agents considered the next evolution beyond LLMs? LLMs generate text; agents take actions. Agents combine language understanding with tool use, planning, and memory — enabling autonomous task completion rather than just answering questions.

  5. What are the main security risks associated with AI agents? Tool misuse, Prompt Injection, data leakage, goal misalignment, and over-reliance by human operators.

Challenge

Build an agent that can analyze a system log file and autonomously determine if a security incident occurred. The agent should have tools to: parse logs, check IP reputation (simulated), search for known attack patterns, and write a summary report. Test it on a sample log containing at least one actual incident.

Real-World Task

Design an agent architecture for a SOC (Security Operations Center) triage system. The agent should receive raw alerts, enrich them with context (CVE databases, IP reputation, past incidents), prioritize them, and either close false positives or escalate real threats. Diagram the architecture and list the tools the agent would need.

FAQ

How are AI agents different from chatbots?

Chatbots respond to user queries with text. AI agents take actions in the world — they can send emails, query databases, execute code, and control systems. An agent acts; a chatbot responds.

Can AI agents work autonomously without human oversight?

For well-defined, low-risk tasks, yes. For security-critical tasks (like blocking network traffic or deleting data), agents should have human oversight. The appropriate autonomy level depends on the risk and impact of mistakes.

How does DodaTech use AI agents in its products?

DodaTech uses AI agents in Durga Antivirus Pro for automated threat investigation — when the antivirus detects a suspicious file, an agent autonomously checks reputation databases, analyzes behavior patterns, and either clears the file or escalates to the security team with a detailed report.

What's Next

You've completed the AI Agents guide. Continue learning:

AI Ethics Guide
Deep Learning Basics
NLP Guide

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro