0
0
Agentic AIml~5 mins

What is an AI agent in Agentic AI

Choose your learning style9 modes available
Introduction

An AI agent is a computer program that can sense its environment and take actions to reach a goal. It helps machines act smartly and solve problems on their own.

When you want a robot to navigate a room by itself.
When you need a virtual assistant to answer questions and help users.
When creating a game character that reacts to player moves.
When automating tasks like sorting emails or scheduling.
When building smart systems that learn and adapt over time.
Syntax
Agentic AI
class AIAgent:
    def __init__(self, environment):
        self.environment = environment

    def perceive(self):
        # Get information from environment
        pass

    def act(self):
        # Take action based on perception
        pass

    def run(self):
        while True:
            self.perceive()
            self.act()

This is a simple structure showing how an AI agent senses and acts.

Real AI agents have more complex perception and action methods.

Examples
A very basic agent that just prints what it does.
Agentic AI
class SimpleAgent:
    def perceive(self):
        print('Looking around')

    def act(self):
        print('Moving forward')
An agent that responds to messages it receives.
Agentic AI
class ChatAgent:
    def perceive(self, message):
        self.message = message

    def act(self):
        print(f'Replying to: {self.message}')
Sample Model

This program shows an AI agent moving through a simple environment step by step, sensing and acting until it reaches the goal.

Agentic AI
class AIAgent:
    def __init__(self, environment):
        self.environment = environment
        self.position = 0

    def perceive(self):
        # Sense current position
        return self.environment[self.position]

    def act(self):
        # Move forward if possible
        if self.position < len(self.environment) - 1:
            self.position += 1
            print(f'Moved to position {self.position}')
        else:
            print('Reached the end')

    def run(self):
        while self.position < len(self.environment) - 1:
            current = self.perceive()
            print(f'At position {self.position}, environment says: {current}')
            self.act()

# Environment is a list of places
env = ['Start', 'Path', 'Path', 'Goal']
agent = AIAgent(env)
agent.run()
OutputSuccess
Important Notes

An AI agent always has a loop of sensing and acting.

Agents can be simple or very complex depending on the task.

Understanding AI agents helps you build smart programs that can work on their own.

Summary

An AI agent senses its environment and acts to reach goals.

It is useful for robots, virtual assistants, games, and automation.

Agents follow a cycle: perceive, decide, and act.