0
0
Agentic AIml~15 mins

What is an AI agent in Agentic AI - Hands-On ML Exercise

Choose your learning style9 modes available
Experiment - What is an AI agent
Problem:You want to understand what an AI agent is and how it works in simple terms.
Current Metrics:Understanding level: beginner, no practical experience with AI agents.
Issue:Lack of clear, simple explanation and hands-on example to grasp the concept of AI agents.
Your Task
Learn what an AI agent is by creating a simple AI agent that can make decisions based on input.
Use simple Python code with no complex libraries.
Focus on clear, easy-to-understand logic.
Explain the agent's behavior in everyday language.
Hint 1
Hint 2
Hint 3
Solution
Agentic AI
class SimpleAIAgent:
    def __init__(self):
        pass

    def decide_action(self, environment_input):
        # The agent decides what to do based on input
        if environment_input == 'hungry':
            return 'eat'
        elif environment_input == 'tired':
            return 'sleep'
        else:
            return 'explore'

# Create the agent
agent = SimpleAIAgent()

# Example environment inputs
inputs = ['hungry', 'tired', 'bored']

# Agent makes decisions
for inp in inputs:
    action = agent.decide_action(inp)
    print(f"When the agent feels {inp}, it decides to {action}.")
Created a SimpleAIAgent class to represent an AI agent.
Added a decide_action method to choose actions based on input.
Used simple if-else rules to simulate decision making.
Printed the agent's decisions to show how it works.
Results Interpretation

Before: No clear idea what an AI agent does.

After: You see a simple program that senses input and chooses actions, just like a smart helper.

An AI agent senses its environment and acts based on rules or learning. Even simple rules can show how agents make decisions.
Bonus Experiment
Modify the agent to remember its last action and avoid repeating it immediately.
💡 Hint
Add a variable to store the last action and check it before deciding a new action.