Agentic AI | Hands-on Practices – Part 1
- 10 minutes read - 1943 wordsIn my previous article, I explored the journey from AI → GenAI → Agentic AI and also emphasized why being hands-on still matters, even when AI can generate code in seconds.
The role of developers is clearly evolving—from pure builders to reviewers, orchestrators, and system designers.
Today, AI Agents are everywhere. We hear about systems that:
- Generate code, review, test and deploy it
- Perform tasks autonomously
- Integrate seamlessly with applications
But there’s a gap.
On the ground, very few people can clearly explain what actually happens behind the scenes.
How does a simple prompt trigger tool execution?
How does “Book me a flight” call real APIs?
This article aims to demystify that.
We won’t just talk—we’ll build agents from scratch and understand how they think, act, and evolve.
🧠 What is an AI Agent?
In an earlier post on moving from AI FOMO to Flow, I discussed techniques like RAG and fine-tuning to provide context to LLMs.
An AI Agent goes a step further.
It is not just a responder—it is a decision-making loop.
An agent:
- Maintains context across interactions
- Decides what to do next
- Uses tools (APIs, scripts, databases)
- Iterates until it reaches a final answer
At its core, an agent operates in a loop:
Thought → Action → Observation → Reasoning → Answer

Instead of just generating text, it acts on your behalf. It’s the brain 🧠!
⚙️ Let’s Build Our First Agent
We’ll start simple and gradually increase complexity.
👤 The “AboutMe” Agent
This agent answers questions about a person (in this case, me) by fetching real data from a source instead of guessing.
Example query:
You: Who is Kuldeep Singh?
🏗️ Project Setup
Prerequisites
- Python
- Any IDE (PyCharm / IntelliJ)
- [OpenAI API Key](OpenAI key )
Install Dependencies
pip install openai langchain python-dotenv beautifulsoup4
- OpenAI Python API Library - openai
- Pre-build agent architecture library - langchain
- Read Environment from
.env- python-dotenv - add the openAI key here. - HTML parser - beautifulsoup4
🧩 Basic Agent Structure
We start with a minimal agent that simply wraps an LLM:
client = OpenAI(api_key=openai_key)
class Agent:
def __init__(self, system=""):
self.system = system
self.messages = []
if system:
self.messages.append({"role": "system", "content": system})
def __call__(self, message):
self.messages.append({"role": "user", "content": message})
result = self.execute()
self.messages.append({"role": "assistant", "content": result})
return result
def execute(self):
response = client.chat.completions.create(
model=llm_name,
temperature=0.0,
messages=self.messages,
)
return response.choices[0].message.content
agent = Agent(system="You are my assistant.")
print(agent("Who is Kuldeep Singh?"))
At this stage, the agent does not know anything specific. It will return generic answers.
Kuldeep Singh is a common name and could refer to various individuals across different fields, including sports, politics, academia, and more. One notable person with that name is Kuldeep Yadav, an Indian cricketer known for his left-arm wrist-spin bowling. If you have a specific Kuldeep Singh in mind or a particular context (like sports, politics, etc.), please provide more details, and I can give you more targeted information.
🧠 Teaching the Agent How to Think
This is where things get interesting.
We define a system prompt that forces structured reasoning:
Thought → Action → PAUSE → Observation → Answer
This turns the LLM into an agentic system instead of a chatbot.
about-me-agent.md
You are an autonomous agent that operates in a loop of:
Thought → Action → PAUSE → Observation → ... → Answer
### Instructions
1. **Thought**
- Describe your reasoning about the user’s question.
- Keep it concise and focused on what you need to do next.
2. **Action**
- Choose one of the available actions.
- Format strictly as: `Action: <action_name>: <input>`
- After the action, output `PAUSE` and stop.
3. **Observation**
- You will receive the result of your action in the next step.
- Use this information to continue reasoning.
4. **Answer**
- When you have enough information, provide the final response.
- Format strictly as: `Answer: <your final answer>`
---
### Available Actions
**about**
- Description: Retrieve information about a person or topic.
- Format: `Action: about: <query>`
- Example: `Action: about: Kuldeep Singh`
---
### Rules
- Always follow the exact format: Thought → Action → PAUSE → Observation → Answer
---
### Example
Question: Who is Kuldeep Singh?
Thought: I should retrieve information about Kuldeep Singh.
Action: about: Kuldeep Singh
PAUSE
Observation: Kuldeep Singh is a technology leader and author...
Thought: I now have enough information to answer.
Answer: Kuldeep Singh is a technology leader and author known for...
with open("about-me-agent.md", "r", encoding="utf-8") as file:
system_prompt = file.read()
🔍 Adding Tools (The Real Power)
We now give the agent a tool:
about_map = {
"Kuldeep Singh": "https://thinkuldeep.com/about/",
"Kuldeep Singh's books": "https://thinkuldeep.com/about/books/",
}
And a function to fetch real data:
def fetch_url_text(url: str) -> str:
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
return " ".join([p.get_text() for p in soup.find_all("p")])
Now the agent can:
- Decide when to call a tool
- Fetch real-world data
- Use it to construct answers
def run_action(action: str):
if action.startswith("about:"):
name = action.split("about:")[1].strip()
if name in about_map:
url = about_map[name]
return fetch_url_text(url)
else:
return f"No URL found for {name}"
return "Unknown action"
🔁 The Agent Loop
This is the heart of the system:
agent = Agent(system=system_prompt)
for step in range(20):
response = agent(message)
parsed = parse_agent_output(response)
if "answer" in parsed:
return parsed["answer"]
if "action" in parsed:
observation = run_action(parsed["action"])
message = f"Observation: {observation}"
This loop enables:
- Iterative reasoning
- Tool usage
- Context building
✅ Result
Instead of hallucinating, the agent now:
- Recognizes it needs data
- Calls the correct tool
- Uses real information
- Produces a grounded answer
$ Question : Who is Kuldeep?
--- Step 1 ---
LLM Output:
Thought: I need to retrieve information about Kuldeep Singh to provide an accurate answer.
Action: about: Kuldeep Singh
PAUSE
🔍 Observation:
Kuldeep has developed innovative solutions that impact effectiveness and efficiency across domains, right fr ...
--- Step 2 ---
LLM Output:
Thought: I have gathered detailed information about Kuldeep Singh, including his professional background, contributions, and current role. I can now formulate a comprehensive answer.
Answer: Kuldeep Singh is a Global Emerging Technology Leader and Principal Consultant at Thoughtworks. He has a strong background in empowering businesses through the Tech@Core approach, focusing on IoT and AR/VR technologies. Kuldeep has led complex data projects and designed scalable architectures, contributing significantly to various industries. He is also an active speaker, mentor, and author, sharing his knowledge through numerous events and articles.
✅ Final Answer:
Kuldeep Singh is a Global Emerging Technology Leader and Principal Consultant at Thoughtworks. He has a strong background in empowering businesses through the Tech@Core approach, focusing on IoT and AR/VR technologies. Kuldeep has led complex data projects and designed scalable architectures, contributing significantly to various industries. He is also an active speaker, mentor, and author, sharing his knowledge through numerous events and articles.
We may even ask "kuldeep's books?" or "tell me about books kuldeep writen", we will be able to get exact response.
$ Question: kuldeep's books
---
✅ Final Answer:
Kuldeep Singh has authored several notable books, including:
1. Jagjeevan: Living Larger Than Life - A tribute to Shri Jagguram, blending personal memories with life lessons on values like humility and resilience.
2. Exploring the Metaverse - A comprehensive guide to the metaverse, discussing its opportunities and challenges.
3. Five Thoughtful Years - A collection of guiding thoughts from 30 thoughtworkers, reflecting on personal and professional journeys.
This shows our demo of first agent.
📚 Level Up: Books Agent
Now we extend the concept. The Books agent will fetch the details of books, and find price listed as per country wise from Exploring The Metaverse and Jagjeevan
We introduce:
- Multiple tools
- Logical reasoning
- Computation
New Capabilities
- Fetch book prices by country
- Perform calculations
- Combine multiple tool outputs
### Available Actions
**book_price**:
- Description: returns the price of book in given country. use default country india.
- Format: `Action: book_price: <book name>, <country>`
- Example: `Action: book_price: Exploring the Metaverse, India`
**calculate**:
- Description: Runs a calculation and returns the number - uses Python so be sure to use floating point syntax if necessary
- Format: `Action: calculate: expression`
- Example: `Action: calculate: 4 * 7 / 3`
---
Example:
> Total price of both books in Australia
def run_action(action: str):
if action.startswith("book_price:"):
name = action.split("book_price:")[1].strip()
if "," in name:
name = name.split(",")[0]
if name in books_map:
url = books_map[name]
return fetch_url_text(url)
else:
return f"No URL found for {name}"
if action.startswith("calculate:"):
exp = action.split("calculate:")[1].strip()
return eval(exp)
return "Unknown action"
Agent flow:
- Fetch price of Book A
- Fetch price of Book B
- Calculate total
- Return answer
Run the Agent
Check price of Book
You: what is price of Exploring the Metaverse in Canada?
--- Step 1 ---
LLM Output:
Thought: I need to retrieve the price of the book "Exploring the Metaverse" specifically for Canada.
Action: book_price: Exploring the Metaverse, Canada
PAUSE
🔍 Observation:
“Exploring the Metaverse” is now available globally!
🇧🇪 Amazon Belgium - 👉 Get it in 32,80€(4% off)🇧🇷 Amazon Brazil - 👉 Get it in R$200,16🇨🇦 Amazon Canada - 👉 Get it in $45.13🇫🇷 Amazon France - 👉 Get it in 32,65€🇩🇪 Amazon Germany - 👉 Get it in €33.12🇮🇳 Amazon India - 👉 Get it in ₹790(10% off)🇮🇹 Amazon Italy - 👉 Get it in 32,19€🇯🇵 Amazon Japan - 👉 Get it in ¥5,556(56pt)(1% off)🇲🇽 Amazon Mexico - 👉 Get it in $670🇳🇱 Amazon Netherlands - 👉 Get it in €37,45🇵🇱 Amazon Poland - 👉 Get it in 139,18zł🇸🇦 Amazon Saudi Arabia - 👉 Get it in ريال 251.94🇸🇬 Amazon Singapore - 👉 Get it in S$48.49🇪🇸 Amazon Spain - 👉 Get it in 32,19€🇸🇪 Amazon Sweden - 👉 Get it in 365kr🇹🇷 Amazon Turkey - 👉 Get it in 1.713,95TL🇦🇪 Amazon UAE - 👉 Get it in AED 69.52(70% off)🇬🇧 Amazon UK - 👉 Get it in £26.45🇺🇸 Amazon US - 👉 Get it in $32.95👉 Rest of the world - 👉 Get it in $32.95
...
--- Step 2 ---
LLM Output:
Thought: I have found the price of "Exploring the Metaverse" in Canada, which is $21.45. I now have enough information to answer the question.
Answer: The price of "Exploring the Metaverse" in Canada is $21.45.
✅ Final Answer:
The price of "Exploring the Metaverse" in Canada is $21.45.
Check Total price of Book Exploring the Metaverse and Jagjeevan in Australia
You: total price of explroing the metaverse and jagjeevan in Australia
--- Step 1 ---
LLM Output:
Thought: I need to retrieve the prices for both "Exploring the Metaverse" and "Jagjeevan" in Australia. I will start by getting the price for "Exploring the Metaverse."
Action: book_price: Exploring the Metaverse, Australia
PAUSE
...
--- Step 2 ---
LLM Output:
Thought: I have the price for "Exploring the Metaverse" in Australia, which is $32.95. Now, I need to retrieve the price for "Jagjeevan" in Australia.
Action: book_price: Jagjeevan, Australia
PAUSE
...
--- Step 3 ---
LLM Output:
Thought: I have now obtained the price for both books. "Exploring the Metaverse" is $32.95 and "Jagjeevan" is $6.99 in Australia. I will calculate the total price of both books.
Action: calculate: 32.95 + 6.99
PAUSE
---
✅ Final Answer:
Total price of both books in Australia is $39.94.
This demo the full capability of agent we built. This is no longer just Q&A—this is task execution.
🧠 Key Takeaways & What’s Next
Agentic AI is about delegation
from writing code → designing intelligent systems.
An AI Agent is simply:
- LLM (Brain)
- Tools (Capabilities)
- Loop (Control System)
The real power lies in orchestration, not just the model.
Frameworks like LangChain and LangGraph abstract this well—but without fundamentals, agents break when tools fail or reasoning goes wrong.
Strong foundations matter more than frameworks.
🚀 What’s Next
- Memory & context
- Multi-agent systems
- Production patterns & failures
🔗 References
https://github.com/aipractices/ai-agents https://www.udemy.com/course/ai-agents/ https://www.youtube.com/watch?v=cZaNf2rA30k
#evolution #ai #genai #technology #prompt #tutorial #learnings #RAG #fine-tuning #development #embeddings #agenticai #future #practice