Back to Data Science Notes
Topic #85

Introduction to Agentic AI

Understand how Agentic AI systems extend Large Language Models (LLMs) by enabling them to plan, use external tools, and execute multi-step tasks autonomously.

What it is

Agentic AI refers to systems where an LLM acts as the central reasoning engine ("brain") that can perceive its environment, make decisions, and take actions. Unlike standard chatbots that only generate text, agents can interact with APIs, databases, or code interpreters. The core mental model involves a loop: Thought (reasoning about what to do), Action (calling a tool), Observation (reading the result), and repeating until the goal is met. Related terms include "ReAct" (Reasoning + Acting), "Tool Use," and "Function Calling."

Why it matters

  • Real-world execution: Agents can book flights, query live data, or fix code bugs, moving beyond static knowledge.
  • Complex problem solving: They break down large tasks into manageable steps, handling dependencies between actions.
  • Reduced hallucination: By fetching factual data from tools rather than relying solely on training memory, accuracy improves.
  • Automation of workflows: They enable end-to-end automation for tasks like customer support ticket resolution or financial reporting.

Syntax or steps

The basic pattern for an agent involves defining available tools and prompting the LLM to select one. A typical flow includes: 1. Define a set of functions (tools) the agent can call. 2. Provide the user's goal to the LLM along with tool descriptions. 3. The LLM outputs a structured request to call a specific tool with arguments. 4. Your code executes the tool and returns the result to the LLM. 5. The LLM synthesizes the final answer based on the observation.

Example

This Python example uses a simplified conceptual structure to show how an agent might decide to use a calculator tool. Note that real implementations often use libraries like LangChain or AutoGen.
import json

# 1. Define a simple tool
def calculate(expression):
    try:
        # In production, use a safe eval library or AST parser
        return str(eval(expression))
    except Exception as e:
        return f"Error: {e}"

# 2. Simulate the Agent Loop
user_goal = "What is 10% of 500?"
available_tools = {"calculate": calculate}

# 3. LLM Decision Step (Simulated output from an LLM)
# An actual LLM would return JSON like this based on the prompt:
llm_response = {
    "thought": "I need to compute 10 percent of 500.",
    "action": "calculate",
    "action_input": "500 * 0.10"
}

print(f"Agent Thought: {llm_response['thought']}")
print(f"Action Taken: {llm_response['action']}({llm_response['action_input']})")

# 4. Execute Tool
tool_func = available_tools[llm_response["action"]]
observation = tool_func(llm_response["action_input"])

print(f"Observation: {observation}")

# 5. Final Answer Generation (Simulated)
final_answer = f"The result is {observation}."
print(f"Final Answer: {final_answer}")
Explanation: The code defines a `calculate` function. It simulates an LLM deciding to use this tool by returning a JSON object containing the thought process, the action name, and the input parameters. The script then looks up the function in `available_tools`, executes it, captures the `observation`, and constructs a final response.

Common mistakes

  • Infinite loops: If the agent keeps calling the same tool without making progress, implement a maximum step limit or timeout.
  • Poor tool descriptions: Vague instructions lead to incorrect tool selection. Clearly define what each tool does and its expected input format.
  • Ignoring errors: Tools often fail. Ensure your agent handles exceptions gracefully and can retry or ask for clarification instead of crashing.
  • Over-reliance on LLM math: Do not ask the LLM to perform complex calculations directly; always delegate arithmetic to a dedicated tool.

When to use it

Compare Agentic AI with standard RAG (Retrieval-Augmented Generation).
FeatureStandard RAGAgentic AI
Primary GoalAnswer questions using retrieved context.Execute multi-step tasks and modify state.
ComplexityLow (Retrieve -> Generate).High (Plan -> Act -> Observe -> Repeat).
Best ForFactual Q&A, document summarization.Data analysis, coding assistants, workflow automation.
LatencyFaster (single pass).Slower (multiple iterations).
Use Agentic AI when the task requires interaction with external systems or multiple dependent steps. Use RAG when you simply need to ground answers in existing documents.

Practice

Guided Exercise: Modify the example above to add a second tool called `get_weather(city)` that returns a hardcoded string like "Sunny". Prompt the simulated LLM to choose between `calculate` and `get_weather` based on the input "Is it raining in London?". Challenge: Implement a simple retry mechanism. If the `calculate` tool returns an error, have the agent adjust the expression (e.g., remove invalid characters) and try again once before giving up.

Quick check

Question: What is the primary difference between a standard LLM chatbot and an Agentic AI system? Answer: A standard chatbot generates text responses based on prompts, while an Agentic AI can reason through steps, select and execute external tools, and observe results to complete complex tasks.

Summary

Agentic AI transforms LLMs from passive text generators into active problem solvers by integrating planning and tool usage. Mastering the Thought-Action-Observation loop allows developers to build robust applications that can interact with the digital world reliably.

Want to go beyond the notes?

Join Coding Now Tech Institute's Data Science course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Introduction to Agentic AI – FAQs

Quick answers about learning Introduction to Agentic AI in Data Science.

This free note from Coding Now Tech Institute explains Introduction to Agentic AI in Data Science — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Data Science topic on Coding Now Tech Institute, including Introduction to Agentic AI, is 100% free with no signup required.
With focused practice, most students grasp Introduction to Agentic AI in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now