\n\n\n\n Im Starting My AI Agent Journey (Heres How) - Agent 101 \n

Im Starting My AI Agent Journey (Heres How)

📖 4 min read•673 words•Updated May 13, 2026

Hey everyone, Emma here from agent101.net! Can you believe it’s already mid-May 2026? Time flies, especially when you’re knee-deep in the fascinating world of AI agents. And speaking of which, I’ve noticed a lot of you reaching out lately with a similar question: “Emma, I get the idea of AI agents, but how do I actually, you know, start building one without feeling like I need a PhD in computer science?”

I hear you loud and clear. It’s easy to get lost in the hype and the jargon. I remember feeling the exact same way just a couple of years ago. I’d read all these incredible articles about autonomous agents, goal-driven systems, and self-improving AI, and then stare blankly at my screen, wondering where the “Hello World” equivalent was. It felt like everyone else was already fluent in a language I hadn’t even started learning the alphabet for. My first few attempts felt like trying to assemble IKEA furniture without the instructions – a lot of pieces, no clear path, and eventually, a lopsided mess that barely resembled what was on the box.

That’s why today, I want to tackle something really specific and practical: Building Your First Goal-Driven AI Agent with Basic Python: A “Personal Shopper” Example. We’re not going to try to build Skynet here, or even a super complex financial advisor. We’re going to build something simple, understandable, and most importantly, something that clearly demonstrates the core principles of an AI agent: sensing, thinking, acting, and remembering, all in pursuit of a defined goal.

My goal for you today is that by the end of this article, you’ll have a working piece of code and a much clearer understanding of how to translate an abstract agent concept into something concrete. No more hand-wringing, just coding!

What Even IS a “Goal-Driven” Agent, Anyway?

Before we jump into the code, let’s quickly demystify “goal-driven.” Imagine you have a personal assistant. You tell them, “Find me a new pair of running shoes.” That’s the goal. They don’t just randomly start looking at socks. They understand the objective, break it down (what kind of shoes? what size? what budget?), gather information (check websites, read reviews), make decisions (this brand looks good, that one has bad reviews), and then act (present you with options, or even make a purchase). They learn from your feedback, too.

Our AI agent will do something similar, albeit in a much simpler digital environment. Its goal will be to “find a product within a certain budget.”

The Core Components We’ll Implement

For our basic “personal shopper” agent, we’ll need a few key pieces:

  • The Goal: What we want to achieve.
  • The Environment: Where our agent operates (in our case, a simple simulated product catalog).
  • Sensing: How our agent gets information from its environment.
  • Thinking/Decision-Making: How our agent processes information and decides what to do next.
  • Acting: How our agent performs actions in the environment.
  • Memory (Simple): How our agent keeps track of what it’s done or learned.

See? No fancy terms, just common sense steps. Let’s get our hands dirty!

Setting Up Our Simple Environment: The “Product Catalog”

First, our agent needs something to interact with. For this example, we’ll create a very basic “product catalog” as a Python list of dictionaries. Each dictionary will represent a product with a name and a price.


# product_catalog.py (or just put this at the top of your main script)

PRODUCT_CATALOG = [
 {"name": "Wireless Headphones", "price": 120},
 {"name": "Ergonomic Keyboard", "price": 85},
 {"name": "Gaming Mouse", "price": 50},
 {"name": "External Hard Drive (1TB)", "price": 75},
 {"name": "Smartwatch", "price": 200},
 {"name": "Portable Bluetooth Speaker", "price": 60},
 {"name": "Webcam (1080p)", "price": 45},
 {"name": "Monitor (27-inch)", "price": 300},
 {"name": "USB-C Hub", "price": 30},
 {"name": "Noise-Cancelling Earbuds", "price": 95},
]

def get_product_info(product_name):
 """Simulates looking up a product in our catalog."""
 for product in PRODUCT_CATALOG:
 if product["name"].lower() == product_name.lower():
 return product
 return None

def search_products_by_budget(max_price):
 """Simulates searching the catalog for products within a budget."""
 found_products = []
 for product in PRODUCT_CATALOG:
 if product["price"] <= max_price:
 found_products.append(product)
 return found_products

This is our agent's world. It can "look up" specific products or "search" for products within a price range. Simple, right?

Building Our AI Personal Shopper Agent

Now, let's build the agent itself. We'll use a Python class to keep everything neat. This is where the magic happens!


# ai_shopper_agent.py

class AIShopperAgent:
 def __init__(self, name, budget):
 self.name = name
 self.budget = budget
 self.goal = f"Find a product under ${budget}"
 self.memory = {"searched_products": []} # A simple memory to avoid re-evaluating the same things
 self.current_state = "idle"
 print(f"{self.name} Agent initialized with goal: {self.goal}")

 def sense_environment(self):
 """
 Our agent "sees" the product catalog.
 In a real scenario, this would involve API calls, web scraping, etc.
 For us, it's calling our simulated environment functions.
 """
 print(f"[{self.name}] Sensing environment for products under ${self.budget}...")
 available_products = search_products_by_budget(self.budget)
 return available_products

 def decide_action(self, sensed_products):
 """
 Based on what it sensed, the agent decides what to do.
 """
 if not sensed_products:
 print(f"[{self.name}] No products found within budget. Considering increasing budget or changing criteria.")
 self.current_state = "failed_to_find"
 return None # No action possible

 # Filter out products already considered (simple memory use)
 new_products = [
 p for p in sensed_products 
 if p["name"] not in [m["name"] for m in self.memory["searched_products"]]
 ]

 if not new_products:
 print(f"[{self.name}] All found products have already been considered. Goal achieved or no new options.")
 self.current_state = "goal_achieved"
 return None

 # Simple decision: pick the cheapest new product
 best_option = min(new_products, key=lambda x: x["price"])
 print(f"[{self.name}] Decided to recommend: {best_option['name']} for ${best_option['price']}")
 return {"action_type": "recommend", "product": best_option}

 def execute_action(self, action):
 """
 The agent performs the decided action.
 """
 if action is None:
 print(f"[{self.name}] No action to execute.")
 return

 action_type = action["action_type"]
 product = action["product"]

 if action_type == "recommend":
 print(f"[{self.name}] Executing action: Recommending '{product['name']}' for purchase.")
 self.memory["searched_products"].append(product) # Add to memory
 self.current_state = "product_recommended"
 return True
 else:
 print(f"[{self.name}] Unknown action type: {action_type}")
 return False

 def run_cycle(self):
 """
 A single turn of the agent's perceive-decide-act loop.
 """
 print(f"\n--- {self.name} Agent Cycle Start ---")
 if self.current_state in ["goal_achieved", "failed_to_find"]:
 print(f"[{self.name}] Agent is in a terminal state ({self.current_state}). Skipping cycle.")
 return False # Agent is done

 # 1. Sense
 sensed_products = self.sense_environment()

 # 2. Decide
 action_to_take = self.decide_action(sensed_products)

 # 3. Act
 success = self.execute_action(action_to_take)

 print(f"--- {self.name} Agent Cycle End. Current state: {self.current_state} ---")
 return success

 def achieve_goal(self, max_cycles=5):
 """
 Runs the agent until the goal is achieved or max cycles reached.
 """
 print(f"\n>>> {self.name} Agent starting goal achievement process <<<")
 cycle_count = 0
 while self.current_state not in ["goal_achieved", "failed_to_find", "product_recommended"] and cycle_count < max_cycles:
 self.run_cycle()
 cycle_count += 1
 if self.current_state == "product_recommended":
 print(f"\n>>> {self.name} Agent successfully recommended a product! <<<")
 print(f"Recommended Product: {self.memory['searched_products'][-1]['name']} (${self.memory['searched_products'][-1]['price']})")
 return True
 
 if self.current_state == "failed_to_find":
 print(f"\n>>> {self.name} Agent failed to find a suitable product within the budget. <<<")
 return False
 elif cycle_count == max_cycles:
 print(f"\n>>> {self.name} Agent reached maximum cycles without achieving goal. <<<")
 return False
 return True # Should be true if product_recommended

Breaking Down the Agent Code:

  • `__init__(self, name, budget)`: This is where our agent is born! We give it a name, a budget (its primary constraint for the goal), and an initial goal statement. We also give it a `memory` (a simple dictionary for now) and an initial `current_state`.
  • `sense_environment()`: This method is how our agent "perceives" its world. Here, it calls `search_products_by_budget` from our `PRODUCT_CATALOG`. In a real-world agent, this could involve reading data from a sensor, a database, or an API.
  • `decide_action(sensed_products)`: This is the "brain" of our agent. It takes the `sensed_products` and figures out what to do. Our agent has a very simple decision rule: if there are products, recommend the cheapest one that hasn't been recommended before. If no products, it acknowledges failure.
  • `execute_action(action)`: Once an action is decided, this method carries it out. In our case, it "recommends" a product and adds it to its memory. This action changes the agent's state.
  • `run_cycle()`: This orchestrates the perceive-decide-act loop. It's a single "turn" for our agent.
  • `achieve_goal(max_cycles)`: This is the main driver. It repeatedly calls `run_cycle()` until the goal is met, it fails, or it runs out of attempts (`max_cycles`).

Putting It All Together: Running Our Agent!

Now, let's create an instance of our agent and watch it go!


# main_agent_run.py (or just add to the bottom of your ai_shopper_agent.py)

if __name__ == "__main__":
 # Make sure PRODUCT_CATALOG, get_product_info, search_products_by_budget
 # are defined or imported here if they are in a separate file.
 # For simplicity, I'm assuming they are in the same file for this example.

 print("--- Starting AI Shopper Agent Demonstration ---")

 # Scenario 1: Agent with a reasonable budget
 print("\n--- Agent 1: Budget $100 ---")
 shopper_agent_1 = AIShopperAgent(name="Budget_Shopper", budget=100)
 shopper_agent_1.achieve_goal()

 print("\n--------------------------------------------")

 # Scenario 2: Agent with a tighter budget
 print("\n--- Agent 2: Budget $40 ---")
 shopper_agent_2 = AIShopperAgent(name="Tight_Budget_Shopper", budget=40)
 shopper_agent_2.achieve_goal()

 print("\n--------------------------------------------")

 # Scenario 3: Agent with a higher budget, might find multiple options
 print("\n--- Agent 3: Budget $150 ---")
 shopper_agent_3 = AIShopperAgent(name="Generous_Shopper", budget=150)
 shopper_agent_3.achieve_goal(max_cycles=3) # Let it run a few cycles to show decision making

 print("\n--- Demonstration Complete ---")

Run this script, and you'll see a play-by-play of your agent's thought process. It will tell you when it's sensing, what it decides, and what action it takes. This verbose output is super helpful for understanding what's going on under the hood.

What You Should See (Examples):

For Agent 1 (Budget $100), it should find and recommend "Ergonomic Keyboard" ($85), "Gaming Mouse" ($50), "External Hard Drive (1TB)" ($75), "Portable Bluetooth Speaker" ($60), "Webcam (1080p)" ($45), "Noise-Cancelling Earbuds" ($95). It will likely pick the cheapest first, which is the "Webcam (1080p)" if it follows our logic, then potentially others if it runs multiple cycles and isn't satisfied.

For Agent 2 (Budget $40), it should print that it found "USB-C Hub" ($30) and recommend it. Then, if it runs another cycle, it will see no more new products under $40 and transition to "goal_achieved" or "no new options."

For Agent 3 (Budget $150), it will have more options. If you let it run for `max_cycles=3`, it might recommend a few different things (e.g., first the webcam, then the USB-C Hub, then maybe the gaming mouse, depending on how `decide_action` is implemented to avoid duplicates). Our current `decide_action` will recommend *the* cheapest product that hasn't been considered yet until it runs out of options or satisfies the goal.

My Takeaways and What's Next for YOU!

So, there you have it! Your very own goal-driven AI agent, built from scratch with basic Python. I know it's not going to pass the Turing test or manage your entire smart home, but it demonstrates those fundamental concepts that often feel so abstract.

My first time getting a simple agent like this to run, I felt a genuine "aha!" moment. It wasn't about complex algorithms; it was about defining clear steps for sensing, thinking, and acting. It's a stepping stone, a proof of concept that you *can* build these things, and you don't need to be a genius to start.

Here are some actionable takeaways for you:

  1. Play with the Budget: Change the `budget` for your agents. What happens if the budget is very low ($20)? What if it's high ($500)? Observe how the agent's behavior changes.
  2. Refine `decide_action` (Your Agent's Brain): Our decision-making is super simple (cheapest new product). How could you make it smarter?
    • What if it prioritized certain keywords in product names (e.g., "gaming" if it's a "gaming shopper" agent)?
    • What if it tried to find the *most expensive* item within budget?
    • What if it considered user reviews (if we added them to our `PRODUCT_CATALOG`)?
  3. Expand the Environment: Add more products to `PRODUCT_CATALOG`. Add more attributes like `category`, `rating`, `brand`. Then, update your `sense_environment` and `decide_action` to use this new information.
  4. Improve Memory: Our memory is just a list of searched products. What if the agent needed to remember past failures to avoid repeating them? Or remember preferred brands?
  5. Introduce User Feedback: Imagine our `execute_action` didn't just print a recommendation, but asked *you* if you liked it. Based on your "yes" or "no," the agent could adjust its future decisions (this is where things get really interesting with reinforcement learning, but start simple!).
  6. Think About Real-World Goals: Now that you've built a simple one, think about a small, specific goal *you* might want an agent to achieve. Could it remind you to water your plants based on weather data? Could it find the cheapest flight for a specific route?

The beauty of AI agents, especially for beginners, is that they break down complex problems into manageable, iterative steps. Don't be afraid to experiment. Break the code, fix it, learn from it. That's how I learned, and it's how you will too!

Keep those questions coming, and happy agent building!

Cheers,

Emma Walsh

agent101.net

🕒 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