{"id":1495,"date":"2026-03-28T07:24:56","date_gmt":"2026-03-28T07:24:56","guid":{"rendered":"https:\/\/datatype.co.in\/blog\/?p=1495"},"modified":"2026-04-01T07:25:45","modified_gmt":"2026-04-01T07:25:45","slug":"ai-agent-tutorial","status":"publish","type":"post","link":"https:\/\/datatype.co.in\/blog\/ai-agent-tutorial\/","title":{"rendered":"AI Agent: Tutorial"},"content":{"rendered":"\n<p>An <strong>AI agent<\/strong> is an autonomous digital worker or software system that analyze, plan, and execute tasks independently on behalf of users. You give it a goal, and it figures out the steps, uses tools and works until the job is done.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">AI Agent Vs Agentic AI<\/h3>\n\n\n\n<p>AI agents are individual, focused software components designed to perform specific tasks with limited autonomy, while <strong>Agentic AI<\/strong> is the broader framework of systems using reasoning, planning, and multi-agent coordination to achieve complex, end-to-end goals with minimal supervision. Think of AI agents as specialized assistants (e.g., a chatbot), while agentic AI acts as the proactive, autonomous &#8220;manager&#8221; orchestrating them.<\/p>\n\n\n\n<p>Example: Say the goal is &#8211; &#8220;Book a flight to tokyo for my vacation in June&#8221;.<\/p>\n\n\n\n<p>An AI agent would:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check your calendar for free dates in June<\/li>\n\n\n\n<li>Use a Flight API to find the cheapest options<\/li>\n\n\n\n<li>Compare the options against your known preferences (e.g non-stop only)<\/li>\n\n\n\n<li>Send you an email: &#8220;I found three flights. Click here to authorize me to buy the Rs. 10000 one on 12th June&#8221;<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Components \/ Architecture of AI Agents<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-1024x683.png\" alt=\"\" class=\"wp-image-1498\" srcset=\"https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-1024x683.png 1024w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-300x200.png 300w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-768x512.png 768w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-270x180.png 270w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-710x473.png 710w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To be considered an AI agent, a system generally needs these four components working together-<\/p>\n\n\n\n<p>AI Agent Development Flow<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>LLM (The Brain):<\/strong> This is the core reasoning engine. It decides what to do next based on the instruction. Eg. GTP-5, Claude, Gemini etc.<\/li>\n\n\n\n<li><strong>Planning: <\/strong> The ability to breaks a big task into small sub-tasks or steps like seen in the ticketing booking example above.<\/li>\n\n\n\n<li><strong>Memory:<\/strong> Short-term &#8211; Remembers what happened three steps ago in the current task (i.e. the context). Long-term &#8211; Can pull information from a database or past projects.<\/li>\n\n\n\n<li><strong>Tools (Action): <\/strong>External APIs or execute code that allow the agent to interact with the world. E.g. Searching the web, sending emails, triggering other process, updating data, querying a SQL database etc.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">AI Agent Development Workflow<\/h3>\n\n\n\n<p>You can build an AI agent by combining a capable language model, well-defined tools, clear instructions, and an orchestration pattern that matches your workflow complexity. Start small with a single, well-scoped task, then expand capabilities over time.<\/p>\n\n\n\n<p><strong>1. Define the Persona and Goal<\/strong><\/p>\n\n\n\n<p>Be hyper-specific in defining goal. Instead of &#8220;a research assistant&#8221;, define it as: &#8220;An agent that monitors tech news, filters for semiconductor updates and summarize them into a slack channel daily&#8221;.<\/p>\n\n\n\n<p><strong>2. Choose AI Agent Framework<\/strong> <\/p>\n\n\n\n<p>Leading frameworks for building LLM applications include LangChain for versatile orchestration, LlamaIndex for data-focused RAG, and CrewAI or AutoGen for multi-agent workflows.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Framework<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>LangGraph<\/td><td>Best for complex, stateful agents where you need high control over the flow<\/td><\/tr><tr><td>CrewAI<\/td><td>The &#8220;go-to&#8221; for multi-agent systems where agents collaborate.<\/td><\/tr><tr><td>Microsoft Autogen<\/td><td>Excellent for conversational multi-agent patterns<\/td><\/tr><tr><td>OpenAI \/ Claude SDKs<\/td><td>For simple, single-agent &#8220;GPT-native&#8221; applications <\/td><\/tr><tr><td>LlmaIndex<\/td><td>Specialized in connecting private data sources (RAG) to LLMs.<\/td><\/tr><tr><td>Hugging Face Transformers<\/td><td>The fundamental library for accessing and working with open-source LLMs.<\/td><\/tr><tr><td>Zapier, n8n<\/td><td>No-code tools<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>3. Define Tools and Actions<\/strong><\/p>\n\n\n\n<p>Define &#8220;Functions&#8221; or &#8220;Tools&#8221; the agent can call. E.g. connect your agent to a search_web function and save_to_notion function. Equip the agent with external capabilities, such as web searching, database access, or calculator functions.<\/p>\n\n\n\n<p><strong>4. Add Guardrails and Test<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p>Guardrails for AI agents are&nbsp;essential safety, security, and compliance frameworks that intercept inputs and outputs to prevent PII leakage, block prompt injection, and enforce behavioral constraints. They operate by validating user prompts, agent reasoning, tool calls, and final responses to ensure safe, ethical, and accurate operations in production environments<\/p>\n\n\n\n<p>Implement safety boundaries to prevent improper actions and rigorously test the agent in a controlled &#8220;playground&#8221; environment before deployment. Agents can &#8220;hallucinate&#8221; or loop. User tools like LangSmith or AgentOps to track every steps the agent takes.<\/p>\n\n\n\n<p><strong>5. Deploy and Monitor<\/strong><\/p>\n\n\n\n<p>Deploy the agent as a microservice API or chatbot, continuously tracking performance and refining prompts or tools.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Practical Example: Simple Research and Save AI agent using CrewAI<\/h3>\n\n\n\n<p>This is scenerio we will create a three-agent system:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The Researcher: Crawl the internet for a specific topic<\/li>\n\n\n\n<li>The Writer: Processes the research into a polished summary<\/li>\n\n\n\n<li>Editor: Review the polished summary for any grammatical errors, sentence flow and accuracy<\/li>\n<\/ol>\n\n\n\n<p><strong>Python Implementation<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Prerequisite Setup\npip install crewai crewai&#91;tools]\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># research_and_save_agent.py\nimport os\nfrom crewai import Agent, Task, Crew, Process\n\n# Configuration - replace with your actual OpenAI API key\nos.environ&#91;\"OPENAI_API_KEY\"] = \"\"\n\nMODEL = \"4o-mini\"   # Change to \"gpt-3.5-turbo\" if 4o-mini is unavailable\nTOPIC = \"AI Agents in Healthcare\"\n\n# Agents \nresearcher = Agent(\n    role=\"Senior Tech Researcher\",\n    goal=\"Uncover and analyse the most important developments in {topic}\",\n    backstory=(\n        \"You are a world-class technology researcher with deep expertise across \"\n        \"AI, life sciences, and digital health. You excel at identifying \"\n        \"emerging trends, evaluating their real-world impact, and distilling \"\n        \"dense information into clear, evidence-based insights.\"\n    ),\n    verbose=True,\n    allow_delegation=False,\n    llm=MODEL,\n)\n\nwriter = Agent(\n    role=\"Tech Content Strategist\",\n    goal=\"Transform research findings into a compelling, concise summary about {topic}\",\n    backstory=(\n        \"You are an experienced science communicator who bridges the gap between \"\n        \"complex research and business decision-makers. Your writing is clear, \"\n        \"structured, and always grounded in the facts provided by the researcher.\"\n    ),\n    verbose=False,\n    allow_delegation=False,\n    llm=MODEL,\n)\n\neditor = Agent(\n    role=\"Senior Editor\",\n    goal=\"Polish the summary about {topic} to be publication-ready\",\n    backstory=(\n        \"You are a meticulous editor with a sharp eye for clarity, flow, and \"\n        \"accuracy. You ensure the final output is free of redundancy, well-structured \"\n        \"in clean Markdown, and suitable for a professional newsletter audience.\"\n    ),\n    verbose=False,\n    allow_delegation=False,\n    llm=MODEL,\n)\n\n# Tasks\nresearch_task = Task(\n    description=(\n        \"Conduct a comprehensive analysis of the current state of {topic} in 2026. \"\n        \"Focus on: (1) the most significant recent breakthroughs, (2) leading companies \"\n        \"or research groups, (3) real-world deployments, and (4) key challenges that \"\n        \"remain unsolved.\"\n    ),\n    expected_output=(\n        \"A structured report containing:\\n\"\n        \"- Top 5 breakthroughs (bulleted, one sentence each)\\n\"\n        \"- 3-5 key players (organisations or projects)\\n\"\n        \"- 2-3 unsolved challenges\\n\"\n        \"All written in plain English with no fluff.\"\n    ),\n    agent=researcher,\n)\n\nwriting_task = Task(\n    description=(\n        \"Using ONLY the researcher's findings above, write a 3-paragraph executive \"\n        \"summary about {topic} suitable for a healthcare technology newsletter. \"\n        \"Paragraph 1: current landscape. Paragraph 2: top breakthroughs. \"\n        \"Paragraph 3: outlook and challenges.\"\n    ),\n    expected_output=(\n        \"A 3-paragraph Markdown summary (~250-300 words). \"\n        \"Include a # heading and use **bold** for key terms.\"\n    ),\n    agent=writer,\n    context=&#91;research_task],   # writer receives researcher's output\n)\n\nediting_task = Task(\n    description=(\n        \"Review and polish the writer's summary about {topic}. Fix any grammatical \"\n        \"issues, improve sentence flow, remove redundancy, and ensure the Markdown \"\n        \"formatting is consistent and clean.\"\n    ),\n    expected_output=(\n        \"The final, publication-ready Markdown summary. \"\n        \"Do NOT add new content \u2014 only refine what the writer produced.\"\n    ),\n    agent=editor,\n    context=&#91;writing_task],    # editor receives writer's output\n)\n\n# Crew Definition\ncrew = Crew(\n    agents=&#91;researcher, writer, editor],\n    tasks=&#91;research_task, writing_task, editing_task],\n    process=Process.sequential,\n    verbose=False,\n)\n\n# Run \nprint(f\"\\n Starting research crew for topic: '{TOPIC}'\\n\")\ntry:\n    result = crew.kickoff(inputs={\"topic\": TOPIC})\n    print(\"\\n\" + \"=\" * 60)\n    print(\"FINAL OUTPUT\")\n    print(\"=\" * 60)\n    print(result)\nexcept Exception as e:\n    print(f\"\\n Crew execution failed: {e}\")<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># Execute the Code\npython research_and_save_agent.py<\/code><\/pre>\n\n\n\n<p>Unlike a simple prompt in ChatGPT, this code creates an autonomous loop:<\/p>\n\n\n\n<p><strong>Role Playing:<\/strong> By defining a backstory, the LLM adopts a specific &#8220;mental model&#8221; which improves output quality.<\/p>\n\n\n\n<p><strong>Sequential Reasoning:<\/strong> The writer doesn&#8217;t just guess; it waits for the researcher to provide the data, mimicking a real-world office workflow.<\/p>\n\n\n\n<p><strong>Input Variable: <\/strong>The {topic} allows you to reuse this code for any subject, making it a scalable tool.<\/p>\n\n\n\n<p>That&#8217;s it! We have successfully created our first Agentic AI application. Keep Learning!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Agentic AI System Works<\/h2>\n\n\n\n<p>Following diagram explains the workflow of an Agentic AI system.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"720\" src=\"https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-4.png\" alt=\"Agentic AI Workflow\" class=\"wp-image-1634\" srcset=\"https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-4.png 688w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2026\/03\/image-4-287x300.png 287w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>An AI agent is an autonomous digital worker or software system that analyze, plan, and execute tasks independently on behalf of users. You give it a goal, and it figures&nbsp;[ &hellip; ]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307,288],"tags":[301,295,296,297,299,298,300,302],"class_list":["post-1495","post","type-post","status-publish","format-standard","hentry","category-agentic-ai","category-python","tag-agentic-ai","tag-ai-agent","tag-crewai","tag-langgraph","tag-llm-frameworks","tag-microsoft-autogen","tag-openiai","tag-python-example","list-style-post"],"_links":{"self":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/comments?post=1495"}],"version-history":[{"count":35,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1495\/revisions"}],"predecessor-version":[{"id":1637,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1495\/revisions\/1637"}],"wp:attachment":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/media?parent=1495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/categories?post=1495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/tags?post=1495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}