\n\n\n\n My First AI Agent: A Beginners Journey - Agent 101 \n

My First AI Agent: A Beginners Journey

📖 6 min read•1,048 words•Updated Apr 11, 2026

Hey there, fellow curious minds! Emma here, back at agent101.net, and today we’re diving into something that’s been buzzing around my brain (and my laptop) for the past few weeks: how to actually get started with building a simple AI agent, especially when you feel like you’re staring at a wall of code and concepts.

I remember when I first started looking into AI agents, it felt like everyone was talking about these super complex systems, deep learning, and neural networks. My eyes would glaze over. I’d think, “Okay, but how do I just make something that does a thing?” I wasn’t looking to build Skynet; I just wanted to understand the basics. And that, my friends, is exactly what we’re going to tackle today: building your very first, incredibly simple, but surprisingly satisfying AI agent using a tool that’s probably already on your computer: Python.

Specifically, we’re going to focus on building a basic “smart assistant” agent that helps you manage your to-do list. Why a to-do list? Because it’s relatable, it has clear inputs and outputs, and it allows us to explore fundamental agent concepts like sensing, deciding, and acting without getting lost in a labyrinth of advanced AI algorithms. Think of it as your gentle introduction to the world of AI agents, without any of the intimidating jargon.

From Zero to “Hello, World” (of Agents)

So, what exactly is an AI agent in the simplest terms? For our purposes, an AI agent is just something that perceives its environment through sensors and acts upon that environment through effectors. It has goals and tries to achieve them. In our to-do list example:

  • Sensors: Reading your current to-do list, understanding your commands.
  • Effectors: Adding a task, removing a task, marking a task complete, displaying the list.
  • Goals: Keeping your to-do list organized and up-to-date.

Sounds pretty straightforward, right? It is! The magic happens when we start to give it a little bit of “intelligence” – even if that intelligence is just a set of “if-then” rules. That’s how we’re going to start.

What You’ll Need (Spoiler: Not Much!)

Before we jump into the code, let’s make sure you have the basics:

  • Python: If you don’t have it installed, head over to python.org and grab the latest version. It’s free and relatively easy to install.
  • A text editor: Visual Studio Code, Sublime Text, or even Notepad++ will do.
  • A terminal or command prompt: This is where you’ll run your Python code.
  • Curiosity: The most important tool!

That’s it! No fancy libraries, no complex frameworks for this first step. We’re keeping it pure Python to understand the core concepts.

Building Our To-Do List Agent: The Brain and Brawn

Let’s break down our agent into manageable parts. We’ll need a way to store our tasks, a way to understand what the user wants, and a way to perform the actions.

Part 1: The To-Do List Storage (Our Agent’s Memory)

Our agent needs to remember the tasks. For simplicity, we’ll just use a Python list. Later, you could imagine this being a file, a database, or even a cloud service. But for now, a simple list is perfect.


# todo_agent.py

class ToDoAgent:
 def __init__(self):
 self.tasks = [] # This is our agent's memory for tasks

 def add_task(self, task_description):
 self.tasks.append({"description": task_description, "completed": False})
 return f"Task '{task_description}' added."

 def view_tasks(self):
 if not self.tasks:
 return "Your to-do list is empty!"
 
 output = "Your To-Do List:\n"
 for i, task in enumerate(self.tasks):
 status = "[DONE]" if task["completed"] else "[ ]"
 output += f"{i + 1}. {status} {task['description']}\n"
 return output

 # We'll add more methods here later

In this snippet, we’ve defined a `ToDoAgent` class. The `__init__` method sets up an empty list called `tasks`. This is where all our to-do items will live. We also have `add_task` to put new items in and `view_tasks` to show us what’s currently there. Notice how each task is a dictionary, allowing us to store both the description and its completion status.

Personal Anecdote: I remember the first time I built something like this. It was a simple inventory system for my digital books. Just seeing the data persist and be manipulated felt like magic. It’s those small wins that keep you going when you’re learning!

Part 2: Sensing and Deciding (Understanding User Input)

Now, our agent needs to take user input and figure out what to do. This is where the “intelligence” (even if rule-based) comes in. We’ll use simple string matching for our commands.


# ... (inside the ToDoAgent class) ...

 def process_command(self, command):
 command = command.strip().lower() # Normalize input

 if command.startswith("add "):
 task_description = command[4:].strip()
 if task_description:
 return self.add_task(task_description)
 else:
 return "Please provide a task to add."
 elif command == "view":
 return self.view_tasks()
 elif command.startswith("complete "):
 try:
 task_index = int(command[9:].strip()) - 1 # User sees 1-based index
 return self.complete_task(task_index)
 except ValueError:
 return "Invalid task number. Please use 'complete [number]'."
 except IndexError:
 return "Task number out of range."
 elif command.startswith("remove "):
 try:
 task_index = int(command[7:].strip()) - 1
 return self.remove_task(task_index)
 except ValueError:
 return "Invalid task number. Please use 'remove [number]'."
 except IndexError:
 return "Task number out of range."
 elif command == "help":
 return self._get_help_message()
 elif command == "quit" or command == "exit":
 return "Goodbye!"
 else:
 return "I don't understand that command. Type 'help' for options."

 def _get_help_message(self):
 return """
Available commands:
 add [task description] - Add a new task
 view - View all tasks
 complete [number] - Mark a task as completed
 remove [number] - Remove a task
 help - Show this help message
 quit/exit - Exit the agent
"""

Here, the `process_command` method is our agent’s brain for simple decision-making. It takes a command string, normalizes it (removes extra spaces, makes it lowercase), and then uses `if/elif` statements to figure out what the user wants. This is a classic example of a rule-based agent. The `_get_help_message` is a utility function to make our agent user-friendly.

Part 3: Acting (Performing the Task)

We still need to implement `complete_task` and `remove_task` methods to round out our agent’s abilities.


# ... (inside the ToDoAgent class) ...

 def complete_task(self, task_index):
 if 0 <= task_index < len(self.tasks):
 if not self.tasks[task_index]["completed"]:
 self.tasks[task_index]["completed"] = True
 return f"Task '{self.tasks[task_index]['description']}' marked as complete."
 else:
 return f"Task '{self.tasks[task_index]['description']}' was already complete."
 else:
 return "Invalid task number."

 def remove_task(self, task_index):
 if 0 <= task_index < len(self.tasks):
 removed_task = self.tasks.pop(task_index)
 return f"Task '{removed_task['description']}' removed."
 else:
 return "Invalid task number."

These methods directly manipulate our `tasks` list. They include basic error checking to make sure the task index is valid before trying to do anything. This kind of robust handling is important even for simple agents.

Bringing It All Together: The Agent's Loop

An agent isn't much good if it just runs once and stops. It needs to continuously sense, decide, and act. This is often called the "agent loop" or "perceive-act cycle."


# todo_agent.py (outside the class definition)

def run_agent():
 agent = ToDoAgent()
 print("Welcome to your simple To-Do List Agent! Type 'help' for commands.")

 while True:
 user_input = input("Agent> ").strip()
 
 if not user_input: # Handle empty input
 continue

 response = agent.process_command(user_input)
 print(response)

 if user_input.lower() in ["quit", "exit"]:
 break

if __name__ == "__main__":
 run_agent()

The `run_agent` function creates an instance of our `ToDoAgent`. Then, it enters an infinite `while True` loop. Inside this loop:

  1. It prompts the user for input (`input("Agent> ")`). This is our agent's "sensor" for user commands.
  2. It passes that input to `agent.process_command()`. This is where the agent "decides."
  3. It prints the `response`. This is the agent "acting" by giving feedback.
  4. It checks if the user wants to quit, breaking the loop if so.

This simple loop is the heart of most interactive agents, whether they're chatbots, game AI, or complex robotic systems. The complexity comes in what happens inside `process_command` and how the agent interacts with its environment.

Let's Give It a Spin! (Practical Example)

Save all the code above into a file named `todo_agent.py`. Open your terminal or command prompt, navigate to the directory where you saved the file, and run it:


python todo_agent.py

You should see:


Welcome to your simple To-Do List Agent! Type 'help' for commands.
Agent> 

Now, try these commands:


Agent> add Buy groceries
Task 'Buy groceries' added.
Agent> add Call Mom
Task 'Call Mom' added.
Agent> view
Your To-Do List:
1. [ ] Buy groceries
2. [ ] Call Mom
Agent> complete 1
Task 'Buy groceries' marked as complete.
Agent> view
Your To-Do List:
1. [DONE] Buy groceries
2. [ ] Call Mom
Agent> add Write blog post
Task 'Write blog post' added.
Agent> remove 2
Task 'Call Mom' removed.
Agent> view
Your To-Do List:
1. [DONE] Buy groceries
2. [ ] Write blog post
Agent> help

Available commands:
 add [task description] - Add a new task
 view - View all tasks
 complete [number] - Mark a task as completed
 remove [number] - Remove a task
 help - Show this help message
 quit/exit - Exit the agent

Agent> quit
Goodbye!

How cool is that? You've just built a functional AI agent! It's not learning from data in the traditional machine learning sense, but it *is* perceiving, deciding, and acting based on a set of rules you've given it. This is a foundational step.

What's Next? Your First Actionable Takeaways

So, you've built a simple agent. What did we learn, and where can you go from here?

  1. Agents are about Perceive-Decide-Act: This fundamental loop is everywhere in AI. Our to-do agent clearly demonstrates it. Keep this in mind as you explore more complex systems.
  2. Start Simple: Don't try to build a general AI on day one. Pick a small, focused problem like a to-do list, a simple calculator, or a basic information retriever.
  3. Rule-Based AI is a Great Starting Point: Before diving into neural networks, understand how to build systems that respond to explicit rules. Many complex AI systems still have strong rule-based components.
  4. Your Code is Your Laboratory: Don't just copy-paste. Experiment!
    • Challenge 1: Persistence. Right now, your tasks disappear when you quit. How could you save them to a file (like a simple text file or a JSON file) and load them when the agent starts? (Hint: look into Python's `open()` function and `json` module.)
    • Challenge 2: More Intelligence. What if the user types "finished 1" instead of "complete 1"? Can you make your `process_command` method a bit smarter to understand synonyms? (Hint: you could use a list of keywords for each action.)
    • Challenge 3: Due Dates. Add a due date to each task. Then, add a command to view tasks by due date, or even an agent "alert" if a task is overdue.
  5. Think About the "Environment": Our agent interacts with the user (its environment). As agents get more complex, their environment might be a website, a database, a game world, or even the physical world through robotics.

This little to-do agent is more than just a toy program; it's a stepping stone. It illustrates the core principles of intelligent agents in a way that's accessible and hands-on. The next time you hear someone talk about AI agents, you'll have a concrete example in your head (and hopefully, on your computer!) of how they work at their most basic level.

Happy coding, and keep that curiosity burning! Emma out.

🕒 Published:

🎓
Written by Jake Chen

AI educator passionate about making complex agent technology accessible. Created online courses reaching 10,000+ students.

Learn more →
Browse Topics: Beginner Guides | Explainers | Guides | Opinion | Safety & Ethics
Scroll to Top