{"id":226,"date":"2026-10-20T14:34:37","date_gmt":"2026-10-20T14:34:37","guid":{"rendered":"https:\/\/devdojo.co.in\/?p=226"},"modified":"2026-10-20T14:34:38","modified_gmt":"2026-10-20T14:34:38","slug":"agentic-ai-series-part-1-what-is-agentic-ai","status":"publish","type":"post","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/","title":{"rendered":"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?"},"content":{"rendered":"\n<div class=\"dd-post\">\n<style>\n.single article:has(.dd-hero) .entry-media{display:none}\n.dd-post{--navy:#0b1020;--blue:#3178c6;--violet:#7c5cff;--ink:#1f2433;--muted:#5b6275;--line:#e3e6ef;font-size:17px;line-height:1.75;color:var(--ink)}\n.dd-post h2{margin:2.2em 0 .6em;font-size:1.6em;line-height:1.3;scroll-margin-top:90px}\n.dd-post h3{margin:1.6em 0 .5em;font-size:1.22em;scroll-margin-top:90px}\n.dd-post a{color:var(--blue);text-decoration:underline;text-underline-offset:3px}\n.dd-post pre{background:#0f1430;color:#e6e9f5;padding:18px 20px;border-radius:12px;overflow-x:auto;line-height:1.6;border:1px solid #232a52;margin:1.2em 0;font-size:14.5px !important}\n.dd-post pre code{font-size:1em !important;background:none;color:inherit;padding:0;font-family:\"JetBrains Mono\",\"Fira Code\",Consolas,Menlo,monospace;white-space:pre}\n.dd-post :not(pre)>code{background:#eef1fb;color:#2b3a8f;padding:2px 6px;border-radius:5px;font-size:.9em}\n.dd-post .dd-file{display:inline-block;background:#151b3b;color:#c9d1ff;font:600 13px\/1 \"JetBrains Mono\",Consolas,monospace;padding:7px 12px;border-radius:8px 8px 0 0;margin:1em 0 -1.2em;position:relative}\n.dd-post .dd-hero{margin:0 0 1.6em;border-radius:16px;overflow:hidden;box-shadow:0 10px 30px rgba(11,16,32,.25)}\n.dd-post .dd-hero svg{display:block;width:100%;height:auto}\n.dd-post .dd-hero .node{transition:transform .25s,filter .25s;transform-box:fill-box;transform-origin:center;cursor:pointer}\n.dd-post .dd-hero .node:hover{transform:scale(1.08);filter:drop-shadow(0 0 10px #7c5cff)}\n.dd-post .dd-series{display:inline-flex;align-items:center;gap:8px;background:#151b3b;color:#dfe3ff;border-radius:999px;padding:6px 14px;font-size:.88em;font-weight:600;margin:0 0 .8em}\n.dd-post .dd-series span{background:var(--violet);color:#fff;border-radius:999px;padding:2px 10px}\n.dd-post .dd-prereq{font-size:.96em;color:var(--muted);border-left:3px solid var(--line);padding-left:12px;margin:.6em 0 1.2em}\n.dd-post .dd-summary{background:linear-gradient(135deg,#eef3ff,#f4efff);border:1px solid #d6dcf5;border-left:5px solid var(--violet);border-radius:12px;padding:18px 22px;margin:1.4em 0}\n.dd-post .dd-summary strong.lbl{display:block;font-size:1.05em;margin-bottom:6px;color:#3a2fa0}\n.dd-post .dd-summary ul{margin:.3em 0 0 1.1em}\n.dd-post .dd-toc{background:#f8f9fc;border:1px solid var(--line);border-radius:12px;padding:16px 22px;margin:1.4em 0}\n.dd-post .dd-toc ol{margin:.4em 0 0 1.2em;columns:2;column-gap:28px}\n.dd-post .dd-toc li{break-inside:avoid;margin:.15em 0}\n@media(max-width:640px){.dd-post .dd-toc ol{columns:1}}\n.dd-post .dd-tip,.dd-post .dd-note,.dd-post .dd-warn{border-radius:10px;padding:14px 18px;margin:1.3em 0}\n.dd-post .dd-tip{background:#ecfbf3;border-left:4px solid #1f9d61}\n.dd-post .dd-note{background:#eef4ff;border-left:4px solid var(--blue)}\n.dd-post .dd-warn{background:#fff6e8;border-left:4px solid #e08a00}\n.dd-post .dd-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;margin:1.3em 0}\n.dd-post .dd-card{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fff;box-shadow:0 2px 8px rgba(20,30,70,.05)}\n.dd-post .dd-card b{display:block;color:#3a2fa0;margin-bottom:4px}\n.dd-post table{width:100%;border-collapse:collapse;margin:1.3em 0;font-size:.95em}\n.dd-post th,.dd-post td{border:1px solid var(--line);padding:10px 12px;text-align:left;vertical-align:top}\n.dd-post th{background:#151b3b;color:#fff}\n.dd-post tr:nth-child(even) td{background:#f8f9fc}\n.dd-post .dd-tablewrap{overflow-x:auto}\n.dd-post figure{margin:1.6em 0;text-align:center}\n.dd-post figure svg{width:100%;height:auto;border-radius:12px}\n.dd-post figcaption{font-size:.9em;color:var(--muted);margin-top:8px}\n.dd-post details{border:1px solid var(--line);border-radius:10px;padding:12px 16px;margin:.7em 0;background:#fff}\n.dd-post details summary{cursor:pointer;font-weight:600}\n.dd-post details[open] summary{margin-bottom:8px;color:#3a2fa0}\n.dd-post .dd-roadmap{border:2px solid #d6dcf5;background:#fbfbff}\n.dd-post .dd-roadmap h4{margin:1em 0 .3em;color:#151b3b;font-size:1em;text-transform:uppercase;letter-spacing:.04em}\n.dd-post .dd-roadmap ol{margin:.2em 0 .6em 1.4em;padding:0}\n.dd-post .dd-roadmap li{margin:.2em 0}\n.dd-post .dd-roadmap .here{background:var(--violet);color:#fff;border-radius:999px;padding:1px 9px;font-size:.8em;font-weight:700;margin-left:6px}\n.dd-post .dd-roadmap .soon{color:#8a90a6;font-size:.82em;margin-left:6px}\n.dd-post .dd-tabs{border:1px solid var(--line);border-radius:12px;padding:6px 16px 16px;margin:1.4em 0;background:#fbfbfe}\n.dd-post .dd-tabs>input{position:absolute;opacity:0;pointer-events:none}\n.dd-post .dd-tabs .labels label{display:inline-block;padding:8px 16px;margin:10px 6px 0 0;border-radius:999px;border:1px solid #cfd5ea;cursor:pointer;font-weight:600;font-size:.95em;background:#fff;transition:background .2s}\n.dd-post .dd-tabs .labels label:hover{border-color:var(--violet)}\n.dd-post .dd-tabs .panel{display:none;margin-top:12px}\n.dd-post .dd-tabs #ti1:checked~.labels label[for=ti1],.dd-post .dd-tabs #ti2:checked~.labels label[for=ti2],.dd-post .dd-tabs #ti3:checked~.labels label[for=ti3],.dd-post .dd-tabs #ti4:checked~.labels label[for=ti4]{background:var(--violet);color:#fff;border-color:var(--violet)}\n.dd-post .dd-tabs #ti1:checked~.p1,.dd-post .dd-tabs #ti2:checked~.p2,.dd-post .dd-tabs #ti3:checked~.p3,.dd-post .dd-tabs #ti4:checked~.p4{display:block}\n.dd-post .dd-tabs #ti1:focus-visible~.labels label[for=ti1],.dd-post .dd-tabs #ti2:focus-visible~.labels label[for=ti2],.dd-post .dd-tabs #ti3:focus-visible~.labels label[for=ti3],.dd-post .dd-tabs #ti4:focus-visible~.labels label[for=ti4]{outline:2px solid var(--blue);outline-offset:2px}\n.dd-post .dd-cta{background:linear-gradient(135deg,#0b1020,#151b3b);color:#e8ebff;border-radius:16px;padding:24px 26px;margin:2em 0;text-align:center}\n.dd-post .dd-cta h3{color:#fff;margin-top:0}\n.dd-post .dd-cta a{color:#a99bff}\n.dd-post .dd-vsc{position:relative;margin:1.5em 0;border-radius:12px;overflow:hidden;background:#1e1e1e;border:1px solid #2b2b2b;box-shadow:0 14px 34px rgba(0,0,0,.28);font-family:\"Segoe UI\",system-ui,sans-serif}\n.dd-post .dd-vsc>input{position:absolute;opacity:0;pointer-events:none}\n.dd-post .dd-vsc-bar{display:flex;align-items:center;gap:12px;background:#323233;color:#cccccc;font-size:12.5px;padding:8px 12px}\n.dd-post .dd-dots{display:inline-flex;gap:7px}.dd-post .dd-dots i{width:12px;height:12px;border-radius:50%;background:#ff5f57;display:block}.dd-post .dd-dots i:nth-child(2){background:#febc2e}.dd-post .dd-dots i:nth-child(3){background:#28c840}\n.dd-post .dd-vsc-title{flex:1;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:50px;opacity:.85}\n.dd-post .dd-vsc-tabs{display:flex;align-items:stretch;background:#252526;border-bottom:1px solid #1e1e1e;overflow-x:auto}\n.dd-post .dd-vsc-tabs label{display:flex;align-items:center;gap:7px;padding:9px 16px;color:#969696;font-size:13px;cursor:pointer;background:#2d2d2d;border-right:1px solid #252526;border-top:1px solid transparent;white-space:nowrap;margin:0;transition:color .15s}\n.dd-post .dd-vsc-tabs label:hover{color:#e0e0e0}\n.dd-post .dd-vsc-tabs .ic{font:700 9.5px\/1 Consolas,monospace;padding:3px 4px;border-radius:3px;color:#1e1e1e}\n.dd-post .ic.py{background:#ffd43b}.dd-post .ic.js{background:#f1e05a}.dd-post .ic.sh{background:#89e051}\n.dd-post .dd-vsc-tabs label.run{margin-left:auto;background:transparent;border:0;color:#89d185;font-weight:600;display:none}\n.dd-post .dd-vsc-tabs label.run:hover{color:#b5f0b0;background:#2a2d2e}\n.dd-post .dd-vsc-pane{display:none}\n.dd-post .dd-vsc>.f1:checked~.dd-vsc-tabs .t1,.dd-post .dd-vsc>.f2:checked~.dd-vsc-tabs .t2,.dd-post .dd-vsc>.f3:checked~.dd-vsc-tabs .t3{background:#1e1e1e;color:#ffffff;border-top-color:#3178c6}\n.dd-post .dd-vsc>.f1:checked~.p1,.dd-post .dd-vsc>.f2:checked~.p2,.dd-post .dd-vsc>.f3:checked~.p3{display:block}\n.dd-post .dd-vsc>.f1:checked~.dd-vsc-tabs .run1,.dd-post .dd-vsc>.f2:checked~.dd-vsc-tabs .run2,.dd-post .dd-vsc>.f3:checked~.dd-vsc-tabs .run3{display:flex}\n.dd-post .dd-vsc>.f1:focus-visible~.dd-vsc-tabs .t1,.dd-post .dd-vsc>.f2:focus-visible~.dd-vsc-tabs .t2,.dd-post .dd-vsc>.f3:focus-visible~.dd-vsc-tabs .t3,.dd-post .dd-vsc>input[type=checkbox]:focus-visible~.dd-vsc-tabs .run{outline:2px solid #3178c6;outline-offset:-2px}\n.dd-post .dd-vsc-crumbs{background:#1e1e1e;color:#a9a9a9;font-size:12px;padding:5px 16px 2px}\n.dd-post .dd-vsc pre.dd-vsc-code{background:#1e1e1e;color:#d4d4d4;border:0;border-radius:0;margin:0;padding:8px 0 14px;counter-reset:ln;line-height:1.62;overflow-x:auto}\n.dd-post .dd-vsc pre code{font-family:Consolas,\"JetBrains Mono\",\"Fira Code\",Menlo,monospace;color:inherit;background:none;white-space:pre}\n.dd-post .dd-vsc .l{display:inline-block;min-width:100%;padding-right:18px;box-sizing:border-box}\n.dd-post .dd-vsc .l::before{counter-increment:ln;content:counter(ln);display:inline-block;width:3.2em;padding-right:1.4em;text-align:right;color:#6e7681;user-select:none;-webkit-user-select:none}\n.dd-post .dd-vsc .l:hover{background:#2a2d2e}.dd-post .dd-vsc .l:hover::before{color:#c6c6c6}\n.dd-post .dd-vsc .k,.dd-post .dd-vsc .kn{color:#c586c0}.dd-post .dd-vsc .kc{color:#569cd6}.dd-post .dd-vsc .s{color:#ce9178}.dd-post .dd-vsc .c{color:#6a9955}.dd-post .dd-vsc .m{color:#b5cea8}.dd-post .dd-vsc .nf{color:#dcdcaa}.dd-post .dd-vsc .nc{color:#4ec9b0}.dd-post .dd-vsc .nb{color:#4ec9b0}.dd-post .dd-vsc .nd{color:#dcdcaa}.dd-post .dd-vsc .n{color:#9cdcfe}.dd-post .dd-vsc .o{color:#d4d4d4}.dd-post .dd-vsc .gp{color:#89d185;user-select:none;-webkit-user-select:none}\n.dd-post .dd-vsc-term{display:none;border-top:1px solid #3c3c3c;background:#181818}\n.dd-post .dd-vsc>.r1:checked~.p1 .dd-vsc-term,.dd-post .dd-vsc>.r2:checked~.p2 .dd-vsc-term,.dd-post .dd-vsc>.r3:checked~.p3 .dd-vsc-term{display:block;animation:ddterm .35s ease-out}\n@keyframes ddterm{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}\n.dd-post .dd-term-head{display:flex;gap:18px;align-items:center;font-size:11px;letter-spacing:.06em;color:#8b8b8b;padding:7px 16px 0}\n.dd-post .dd-term-head span:first-child{color:#e7e7e7;border-bottom:1px solid #e7e7e7;padding-bottom:4px}\n.dd-post .dd-term-head .dd-term-note{margin-left:auto;letter-spacing:0;text-transform:none;color:#d7ba7d;border:0;font-size:11.5px}\n.dd-post .dd-vsc-term pre{background:#181818;color:#cccccc;border:0;margin:0;padding:10px 16px 14px;border-radius:0}\n.dd-post .dd-vsc-status{display:flex;flex-wrap:wrap;gap:4px 14px;background:#007acc;color:#fff;font-size:11.5px;padding:4px 12px}\n.dd-post .dd-vsc-status .sp{flex:1}\n.dd-post .dd-vsc-termonly pre.dd-vsc-code{background:#181818;padding:12px 16px}\n@media(max-width:640px){.dd-post .dd-vsc-title{padding-right:0;text-align:left}.dd-post .dd-vsc-status span:nth-child(n+4){display:none}.dd-post .dd-vsc .l::before{width:2.2em;padding-right:1em}}\n.dd-post .dd-vsc-hint{font-size:.93em;color:var(--muted);margin-top:-.6em}\n.dd-post .dd-next{border:1px dashed var(--violet);border-radius:12px;padding:16px 20px;margin:1.6em 0;background:#f7f4ff}\n<\/style>\n\n<div class=\"dd-hero\">\n<svg viewBox=\"0 0 1200 520\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"Agentic AI series Part 1 banner: an AI agent takes a goal and runs a loop of think, act and observe while using tools\">\n<defs>\n<linearGradient id=\"ddbg\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#0b1020\"\/><stop offset=\"1\" stop-color=\"#151b3b\"\/><\/linearGradient>\n<linearGradient id=\"ddac\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stop-color=\"#3178c6\"\/><stop offset=\"1\" stop-color=\"#7c5cff\"\/><\/linearGradient>\n<radialGradient id=\"ddglow\" cx=\".5\" cy=\".5\" r=\".5\"><stop offset=\"0\" stop-color=\"#7c5cff\" stop-opacity=\".45\"\/><stop offset=\"1\" stop-color=\"#7c5cff\" stop-opacity=\"0\"\/><\/radialGradient>\n<\/defs>\n<rect x=\"0\" y=\"-60\" width=\"1200\" height=\"640\" fill=\"url(#ddbg)\"\/>\n<circle cx=\"930\" cy=\"300\" r=\"260\" fill=\"url(#ddglow)\"\/>\n<g opacity=\".12\" stroke=\"#9fb2ff\"><path d=\"M0 100H1200M0 200H1200M0 300H1200M0 400H1200M200 0V520M400 0V520M600 0V520M800 0V520M1000 0V520\"\/><\/g>\n<rect x=\"60\" y=\"46\" width=\"128\" height=\"38\" rx=\"19\" fill=\"url(#ddac)\"\/>\n<text x=\"124\" y=\"71\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"700\" fill=\"#fff\">PART 1<\/text>\n<text x=\"204\" y=\"71\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" fill=\"#aab4e8\">Agentic AI Series \u00b7 DevDojo<\/text>\n<text x=\"60\" y=\"148\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"52\" font-weight=\"800\" fill=\"#ffffff\">What Is Agentic AI?<\/text>\n<text x=\"60\" y=\"206\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"52\" font-weight=\"800\" fill=\"#ffffff\">How AI Agents Work<\/text>\n<text x=\"60\" y=\"250\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"24\" fill=\"#c9d1ff\">Goals, tools, memory and the think \u2192 act \u2192 observe loop<\/text>\n<path id=\"ddloop\" d=\"M930 175 A140 140 0 1 1 929.9 175\" fill=\"none\" stroke=\"url(#ddac)\" stroke-width=\"3\" stroke-dasharray=\"8 8\" opacity=\".8\"\/>\n<path id=\"ddgoal\" d=\"M250 360 C 420 360, 560 300, 790 300\" fill=\"none\" stroke=\"url(#ddac)\" stroke-width=\"3\" stroke-dasharray=\"8 8\" opacity=\".7\"\/>\n<g class=\"node\"><rect x=\"70\" y=\"318\" width=\"180\" height=\"84\" rx=\"16\" fill=\"url(#ddac)\"\/><text x=\"160\" y=\"354\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"22\" font-weight=\"800\" fill=\"#fff\">\ud83c\udfaf Goal<\/text><text x=\"160\" y=\"380\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"14\" fill=\"#eef\">&#8220;Plan my Goa trip&#8221;<\/text><\/g>\n<g class=\"node\"><circle cx=\"930\" cy=\"315\" r=\"62\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"3\"\/><text x=\"930\" y=\"310\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"20\" font-weight=\"800\" fill=\"#fff\">AI Agent<\/text><text x=\"930\" y=\"334\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"14\" fill=\"#aab4e8\">LLM brain<\/text><\/g>\n<g class=\"node\"><rect x=\"865\" y=\"152\" width=\"130\" height=\"46\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"930\" y=\"182\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"700\" fill=\"#fff\">\ud83e\udde0 Think<\/text><\/g>\n<g class=\"node\"><rect x=\"1012\" y=\"365\" width=\"130\" height=\"46\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"1077\" y=\"395\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"700\" fill=\"#fff\">\ud83d\udee0\ufe0f Act<\/text><\/g>\n<g class=\"node\"><rect x=\"718\" y=\"365\" width=\"130\" height=\"46\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"783\" y=\"395\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"700\" fill=\"#fff\">\ud83d\udc40 Observe<\/text><\/g>\n<g class=\"node\"><rect x=\"300\" y=\"430\" width=\"120\" height=\"36\" rx=\"18\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"360\" y=\"454\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" fill=\"#c9d1ff\">\ud83d\udd0d Search<\/text><\/g>\n<g class=\"node\"><rect x=\"432\" y=\"430\" width=\"120\" height=\"36\" rx=\"18\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"492\" y=\"454\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" fill=\"#c9d1ff\">\ud83e\uddee Calculator<\/text><\/g>\n<g class=\"node\"><rect x=\"564\" y=\"430\" width=\"120\" height=\"36\" rx=\"18\" fill=\"#0b1020\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"624\" y=\"454\" text-anchor=\"middle\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"15\" fill=\"#c9d1ff\">\ud83d\uddc4\ufe0f Database<\/text><\/g>\n<circle r=\"8\" fill=\"#7c5cff\"><animateMotion dur=\"5s\" repeatCount=\"indefinite\"><mpath href=\"#ddloop\"\/><\/animateMotion><\/circle>\n<circle r=\"6\" fill=\"#ffffff\"><animateMotion dur=\"5s\" begin=\"2.5s\" repeatCount=\"indefinite\"><mpath href=\"#ddloop\"\/><\/animateMotion><\/circle>\n<circle r=\"6\" fill=\"#3178c6\"><animateMotion dur=\"3.5s\" repeatCount=\"indefinite\"><mpath href=\"#ddgoal\"\/><\/animateMotion><\/circle>\n<text x=\"60\" y=\"505\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"16\" fill=\"#7f89b5\">devdojo.co.in \u00b7 Beginner friendly \u00b7 Python + Node.js examples<\/text>\n<\/svg>\n<\/div>\n\n<div class=\"dd-series\">Series: Agentic AI <span>Part 1 of 30<\/span><\/div>\n<p class=\"dd-prereq\"><strong>What you should know first:<\/strong> this is the first part, so no earlier part is needed. It helps if you know what a large language model is (see <a href=\"https:\/\/devdojo.co.in\/?p=215\">Generative AI Part 1: What Is Generative AI and How Do LLMs Work?<\/a>) and how to call one from code (see <a href=\"https:\/\/devdojo.co.in\/?p=223\">Generative AI Part 3: Your First LLM API Calls<\/a>). Basic Python or JavaScript is enough.<\/p>\n\n<p>Everyone is talking about <strong>agentic AI<\/strong>. Coding assistants that fix bugs on their own, research tools that read fifty web pages and write a report, support bots that actually issue your refund. But what makes these systems different from a normal chatbot? In this first part of the Agentic AI series you will learn, in simple words, what agentic AI is, how an <strong>AI agent<\/strong> works step by step, and the one idea behind every agent: the <strong>think \u2192 act \u2192 observe loop<\/strong>. Then you will build two small agents yourself, one that runs with no API key at all, and one that uses a real LLM with tool calling in Python and Node.js.<\/p>\n\n<div class=\"dd-summary\">\n<strong class=\"lbl\">Quick Summary<\/strong>\n<ul>\n<li><strong>Agentic AI<\/strong> means AI systems that can work towards a <strong>goal<\/strong> on their own: they plan, take actions with <strong>tools<\/strong>, look at the results, and keep going until the job is done.<\/li>\n<li>An <strong>AI agent<\/strong> = an LLM (the brain) + tools (the hands) + instructions (the rules) + memory (the notes), running inside a <strong>loop<\/strong>.<\/li>\n<li>A chatbot answers once. A <strong>workflow<\/strong> follows steps that <em>your code<\/em> decides. An <strong>agent<\/strong> lets <em>the model<\/em> decide the next step.<\/li>\n<li>The agent loop is simple: <strong>think<\/strong> (pick the next action) \u2192 <strong>act<\/strong> (run a tool) \u2192 <strong>observe<\/strong> (read the result) \u2192 repeat, with a step limit as a safety net.<\/li>\n<li>Agents are powerful but slower, costlier and harder to test. Use them when the steps cannot be known in advance.<\/li>\n<\/ul>\n<\/div>\n\n<details class=\"dd-roadmap\">\n<summary>Full Agentic AI roadmap (30 parts)<\/summary>\n<h4>Beginner<\/h4>\n<ol start=\"1\">\n<li>What Is Agentic AI and How Do AI Agents Work? <span class=\"here\">You are here<\/span><\/li>\n<li>Anatomy of an AI Agent: Models, Tools, Instructions and Memory <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Tool Calling for Agents: Letting an LLM Use Your Functions <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Build Your First AI Agent from Scratch in Python (No Framework) <span class=\"soon\">Coming soon<\/span><\/li>\n<li>The ReAct Pattern: Reason, Act, Observe in Practice <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Writing Good Agent Instructions and Tool Descriptions <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Agent Memory: Short-Term, Long-Term and Scratchpads <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Planning Agents: Breaking Big Goals into Steps <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<h4>Intermediate<\/h4>\n<ol start=\"9\">\n<li>Workflow Patterns: Chaining, Routing and Parallel Steps <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Model Context Protocol (MCP): Connecting Agents to Tools and Data <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Agent Frameworks Compared: OpenAI Agents SDK, LangGraph, Claude Agent SDK and More <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Building Stateful Agents with LangGraph <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Agentic RAG: Agents That Search, Read and Cite <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Browser and Computer-Use Agents <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Coding Agents: How AI Writes, Runs and Fixes Code <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Human-in-the-Loop: Approvals, Interrupts and Checkpoints <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Multi-Agent Systems: Handoffs, Supervisors and Teams <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Agent-to-Agent Communication with the A2A Protocol <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Guardrails and Structured Outputs for Agents <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Tracing and Debugging Agents <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<h4>Advanced<\/h4>\n<ol start=\"21\">\n<li>Evaluating Agents: Task Success, Trajectories and Test Suites <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Agent Security: Prompt Injection, Permissions and Sandboxing <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Controlling Agent Cost and Latency <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Long-Running Agents: Queues, Retries and Durable Execution <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Deep Research Agents: Search, Synthesise and Report <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Reflection and Self-Correcting Agents <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Voice and Real-Time Agents <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Deploying Agents to Production: APIs, Serverless and Containers <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Monitoring and Improving Agents in Production <span class=\"soon\">Coming soon<\/span><\/li>\n<li>Final Project: Build a Multi-Agent Developer Assistant <span class=\"soon\">Coming soon<\/span><\/li>\n<\/ol>\n<\/details>\n\n<nav class=\"dd-toc\" aria-label=\"Table of contents\">\n<strong>In this part<\/strong>\n<ol>\n<li><a href=\"#what-is-agentic-ai\">What is agentic AI?<\/a><\/li>\n<li><a href=\"#chatbot-workflow-agent\">Chatbot vs workflow vs agent<\/a><\/li>\n<li><a href=\"#agent-loop\">The agent loop<\/a><\/li>\n<li><a href=\"#building-blocks\">Four building blocks<\/a><\/li>\n<li><a href=\"#toy-agent\">Build a toy agent (no API key)<\/a><\/li>\n<li><a href=\"#real-agent\">A real agent with tool calling<\/a><\/li>\n<li><a href=\"#workflow-vs-agent-code\">Workflow vs agent in code<\/a><\/li>\n<li><a href=\"#levels\">Levels of autonomy<\/a><\/li>\n<li><a href=\"#examples\">Real-world examples<\/a><\/li>\n<li><a href=\"#when-not\">When not to use an agent<\/a><\/li>\n<li><a href=\"#common-errors\">Common errors and fixes<\/a><\/li>\n<li><a href=\"#best-practices\">Best practices<\/a><\/li>\n<li><a href=\"#practice\">Practice task<\/a><\/li>\n<li><a href=\"#faq\">FAQ<\/a><\/li>\n<\/ol>\n<\/nav>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"what-is-agentic-ai\">What is agentic AI?<\/h2>\n<p><strong>Agentic AI<\/strong> is a way of building AI systems that do not just <em>answer<\/em> a question, but <em>work on a goal<\/em>. You give the system a task, like &#8220;find out why this test is failing and fix it&#8221;, and it decides by itself what to do first, which tools to use, what to do with the results, and when the job is finished.<\/p>\n<p>The word &#8220;agentic&#8221; comes from <em>agency<\/em>: the ability to act on your own. A normal chatbot has very little agency. It reads your message and writes one reply. An <strong>AI agent<\/strong> has more agency. It can search the web, run code, read files, call APIs and send messages, and it can do this many times in a row until it reaches the goal.<\/p>\n<p>A simple way to remember it:<\/p>\n<div class=\"dd-cards\">\n<div class=\"dd-card\"><b>Chatbot<\/b>&#8220;Tell me how to book a train ticket.&#8221; \u2192 gives you instructions.<\/div>\n<div class=\"dd-card\"><b>AI agent<\/b>&#8220;Book me a train ticket to Pune on Friday.&#8221; \u2192 checks trains, compares times, picks one, asks you to confirm, books it.<\/div>\n<\/div>\n<p>Under the hood, almost every modern agent is built the same way: a large language model (LLM) runs inside a <strong>loop<\/strong> and is allowed to call <strong>tools<\/strong>. Anthropic describes agents as systems where the LLM <em>dynamically directs its own process and tool usage<\/em>, which is a nice short definition. You can read their excellent guide <a href=\"https:\/\/www.anthropic.com\/engineering\/building-effective-agents\" target=\"_blank\" rel=\"noopener\">Building effective agents<\/a> for more.<\/p>\n\n<h2 id=\"chatbot-workflow-agent\">Chatbot vs workflow vs agent<\/h2>\n<p>Before we build anything, it is important to see the three common shapes of LLM apps. Many apps that are called &#8220;agents&#8221; are really workflows, and that is often a good thing.<\/p>\n\n<figure>\n<svg viewBox=\"0 0 1000 330\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"Comparison diagram: a chatbot answers once, a workflow follows fixed steps decided by code, and an agent loops between the LLM and tools and decides the next step itself\">\n<rect width=\"1000\" height=\"330\" fill=\"#f6f7fc\"\/>\n<defs><marker id=\"ar1\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#3178c6\"\/><\/marker><marker id=\"ar2\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#7c5cff\"\/><\/marker><\/defs>\n<g font-family=\"Segoe UI,Arial,sans-serif\">\n<rect x=\"20\" y=\"20\" width=\"300\" height=\"290\" rx=\"16\" fill=\"#fff\" stroke=\"#d6dcf5\" stroke-width=\"2\"\/>\n<text x=\"170\" y=\"56\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#151b3b\">1. Chatbot<\/text>\n<text x=\"170\" y=\"80\" text-anchor=\"middle\" font-size=\"14\" fill=\"#5b6275\">one question, one answer<\/text>\n<rect x=\"110\" y=\"100\" width=\"120\" height=\"44\" rx=\"10\" fill=\"#eef1fb\"\/><text x=\"170\" y=\"128\" text-anchor=\"middle\" font-size=\"16\" fill=\"#151b3b\">You ask<\/text>\n<line x1=\"170\" y1=\"146\" x2=\"170\" y2=\"172\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar1)\"\/>\n<rect x=\"110\" y=\"176\" width=\"120\" height=\"44\" rx=\"10\" fill=\"#151b3b\"\/><text x=\"170\" y=\"204\" text-anchor=\"middle\" font-size=\"16\" font-weight=\"700\" fill=\"#fff\">LLM<\/text>\n<line x1=\"170\" y1=\"222\" x2=\"170\" y2=\"248\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar1)\"\/>\n<rect x=\"110\" y=\"252\" width=\"120\" height=\"44\" rx=\"10\" fill=\"#eef1fb\"\/><text x=\"170\" y=\"280\" text-anchor=\"middle\" font-size=\"16\" fill=\"#151b3b\">Answer<\/text>\n<rect x=\"350\" y=\"20\" width=\"300\" height=\"290\" rx=\"16\" fill=\"#fff\" stroke=\"#d6dcf5\" stroke-width=\"2\"\/>\n<text x=\"500\" y=\"56\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#151b3b\">2. Workflow<\/text>\n<text x=\"500\" y=\"80\" text-anchor=\"middle\" font-size=\"14\" fill=\"#5b6275\">your code decides the steps<\/text>\n<rect x=\"380\" y=\"110\" width=\"70\" height=\"44\" rx=\"10\" fill=\"#151b3b\"\/><text x=\"415\" y=\"138\" text-anchor=\"middle\" font-size=\"15\" font-weight=\"700\" fill=\"#fff\">Step 1<\/text>\n<line x1=\"452\" y1=\"132\" x2=\"472\" y2=\"132\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar1)\"\/>\n<rect x=\"475\" y=\"110\" width=\"70\" height=\"44\" rx=\"10\" fill=\"#151b3b\"\/><text x=\"510\" y=\"138\" text-anchor=\"middle\" font-size=\"15\" font-weight=\"700\" fill=\"#fff\">Step 2<\/text>\n<line x1=\"547\" y1=\"132\" x2=\"567\" y2=\"132\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar1)\"\/>\n<rect x=\"570\" y=\"110\" width=\"70\" height=\"44\" rx=\"10\" fill=\"#151b3b\"\/><text x=\"605\" y=\"138\" text-anchor=\"middle\" font-size=\"15\" font-weight=\"700\" fill=\"#fff\">Step 3<\/text>\n<text x=\"500\" y=\"200\" text-anchor=\"middle\" font-size=\"15\" fill=\"#5b6275\">Same path every time.<\/text>\n<text x=\"500\" y=\"224\" text-anchor=\"middle\" font-size=\"15\" fill=\"#5b6275\">Predictable, cheap, easy to test.<\/text>\n<rect x=\"400\" y=\"248\" width=\"200\" height=\"40\" rx=\"20\" fill=\"#ecfbf3\"\/><text x=\"500\" y=\"274\" text-anchor=\"middle\" font-size=\"15\" font-weight=\"700\" fill=\"#1f7a4c\">Use when steps are known<\/text>\n<rect x=\"680\" y=\"20\" width=\"300\" height=\"290\" rx=\"16\" fill=\"#fff\" stroke=\"#7c5cff\" stroke-width=\"2.5\"\/>\n<text x=\"830\" y=\"56\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#151b3b\">3. Agent<\/text>\n<text x=\"830\" y=\"80\" text-anchor=\"middle\" font-size=\"14\" fill=\"#5b6275\">the model decides the steps<\/text>\n<defs><linearGradient id=\"ddfig\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stop-color=\"#3178c6\"\/><stop offset=\"1\" stop-color=\"#7c5cff\"\/><\/linearGradient><\/defs>\n<rect x=\"705\" y=\"120\" width=\"100\" height=\"50\" rx=\"12\" fill=\"url(#ddfig)\"\/>\n<text x=\"755\" y=\"151\" text-anchor=\"middle\" font-size=\"16\" font-weight=\"800\" fill=\"#fff\">LLM<\/text>\n<rect x=\"860\" y=\"120\" width=\"100\" height=\"50\" rx=\"12\" fill=\"#151b3b\"\/><text x=\"910\" y=\"151\" text-anchor=\"middle\" font-size=\"16\" font-weight=\"700\" fill=\"#fff\">Tools<\/text>\n<path d=\"M807 133 L856 133\" stroke=\"#7c5cff\" stroke-width=\"3\" marker-end=\"url(#ar2)\"\/>\n<path d=\"M858 158 L809 158\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar1)\"\/>\n<text x=\"832\" y=\"124\" text-anchor=\"middle\" font-size=\"12\" fill=\"#5b6275\">act<\/text>\n<text x=\"832\" y=\"182\" text-anchor=\"middle\" font-size=\"12\" fill=\"#5b6275\">observe<\/text>\n<text x=\"830\" y=\"218\" text-anchor=\"middle\" font-size=\"15\" fill=\"#5b6275\">Loops until the goal is done.<\/text>\n<text x=\"830\" y=\"240\" text-anchor=\"middle\" font-size=\"15\" fill=\"#5b6275\">Flexible, but slower and costlier.<\/text>\n<rect x=\"720\" y=\"252\" width=\"220\" height=\"40\" rx=\"20\" fill=\"#f4efff\"\/><text x=\"830\" y=\"278\" text-anchor=\"middle\" font-size=\"15\" font-weight=\"700\" fill=\"#5b3fd6\">Use when steps are unknown<\/text>\n<\/g>\n<\/svg>\n<figcaption>Figure 1: The three common shapes of LLM apps. Only the last one lets the model choose its own next step.<\/figcaption>\n<\/figure>\n\n<div class=\"dd-tablewrap\"><table>\n<thead><tr><th>Question<\/th><th>Chatbot<\/th><th>Workflow<\/th><th>Agent<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>Who decides the steps?<\/td><td>Nobody, there is one step<\/td><td>Your code<\/td><td>The LLM<\/td><\/tr>\n<tr><td>Can it use tools?<\/td><td>Usually no<\/td><td>Yes, in fixed places<\/td><td>Yes, whenever it wants<\/td><\/tr>\n<tr><td>Number of LLM calls<\/td><td>1<\/td><td>Fixed (e.g. 3)<\/td><td>Unknown (1 to many)<\/td><\/tr>\n<tr><td>Cost and speed<\/td><td>Cheap, fast<\/td><td>Predictable<\/td><td>Varies, often higher<\/td><\/tr>\n<tr><td>Best for<\/td><td>Q&amp;A, writing help<\/td><td>Known processes (summarise \u2192 translate \u2192 format)<\/td><td>Open-ended tasks (debug this, research that)<\/td><\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<h2 id=\"agent-loop\">The agent loop: think, act, observe<\/h2>\n<p>If you remember only one thing from this part, remember this loop. Every AI agent, from a tiny script to a large coding assistant, repeats these three steps:<\/p>\n<ol>\n<li><strong>Think:<\/strong> the LLM looks at the goal and everything that has happened so far, and decides the next action. It can either call a tool or give the final answer.<\/li>\n<li><strong>Act:<\/strong> your program runs the tool the LLM asked for (search, calculator, database query, API call, run a test).<\/li>\n<li><strong>Observe:<\/strong> the result of the tool is added to the conversation history, so the LLM can see it on the next turn.<\/li>\n<\/ol>\n<p>The loop stops when the LLM says &#8220;I am done&#8221; (it gives a final answer instead of a tool call), or when a <strong>step limit<\/strong> is reached. The step limit is very important: without it, a confused agent could loop forever and keep spending money.<\/p>\n\n<figure>\n<svg viewBox=\"0 0 1000 320\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-label=\"Agent loop diagram: a goal goes to Think, Think chooses a tool in Act, the tool result goes to Observe, and Observe feeds back into Think until the final answer is ready\">\n<rect width=\"1000\" height=\"320\" fill=\"#f6f7fc\"\/>\n<defs><marker id=\"ar3\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#3178c6\"\/><\/marker><marker id=\"ar4\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#7c5cff\"\/><\/marker><\/defs>\n<g font-family=\"Segoe UI,Arial,sans-serif\">\n<rect x=\"20\" y=\"130\" width=\"160\" height=\"70\" rx=\"14\" fill=\"#eef1fb\" stroke=\"#d6dcf5\" stroke-width=\"2\"\/><text x=\"100\" y=\"161\" text-anchor=\"middle\" font-size=\"19\" font-weight=\"800\" fill=\"#151b3b\">\ud83c\udfaf Goal<\/text><text x=\"100\" y=\"184\" text-anchor=\"middle\" font-size=\"13\" fill=\"#5b6275\">from the user<\/text>\n<line x1=\"182\" y1=\"165\" x2=\"246\" y2=\"110\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar3)\"\/>\n<rect x=\"250\" y=\"60\" width=\"200\" height=\"90\" rx=\"16\" fill=\"#151b3b\"\/><text x=\"350\" y=\"98\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#fff\">\ud83e\udde0 1. Think<\/text><text x=\"350\" y=\"124\" text-anchor=\"middle\" font-size=\"14\" fill=\"#aab4e8\">LLM picks next action<\/text>\n<line x1=\"452\" y1=\"105\" x2=\"546\" y2=\"105\" stroke=\"#7c5cff\" stroke-width=\"3\" marker-end=\"url(#ar4)\"\/>\n<text x=\"500\" y=\"94\" text-anchor=\"middle\" font-size=\"13\" fill=\"#5b6275\">tool call<\/text>\n<rect x=\"550\" y=\"60\" width=\"200\" height=\"90\" rx=\"16\" fill=\"#151b3b\"\/><text x=\"650\" y=\"98\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#fff\">\ud83d\udee0\ufe0f 2. Act<\/text><text x=\"650\" y=\"124\" text-anchor=\"middle\" font-size=\"14\" fill=\"#aab4e8\">your code runs the tool<\/text>\n<line x1=\"650\" y1=\"152\" x2=\"650\" y2=\"206\" stroke=\"#3178c6\" stroke-width=\"3\" marker-end=\"url(#ar3)\"\/>\n<rect x=\"550\" y=\"210\" width=\"200\" height=\"90\" rx=\"16\" fill=\"#151b3b\"\/><text x=\"650\" y=\"248\" text-anchor=\"middle\" font-size=\"21\" font-weight=\"800\" fill=\"#fff\">\ud83d\udc40 3. Observe<\/text><text x=\"650\" y=\"274\" text-anchor=\"middle\" font-size=\"14\" fill=\"#aab4e8\">result added to history<\/text>\n<path d=\"M548 255 C 420 255, 350 230, 350 154\" fill=\"none\" stroke=\"#7c5cff\" stroke-width=\"3\" marker-end=\"url(#ar4)\"\/>\n<text x=\"420\" y=\"270\" text-anchor=\"middle\" font-size=\"13\" fill=\"#5b6275\">repeat<\/text>\n<path d=\"M350 58 C 350 16, 870 16, 870 126\" fill=\"none\" stroke=\"#1f9d61\" stroke-width=\"3\" marker-end=\"url(#ar3)\"\/>\n<text x=\"610\" y=\"30\" text-anchor=\"middle\" font-size=\"13\" fill=\"#1f7a4c\">goal done \u2192 no tool call<\/text>\n<rect x=\"790\" y=\"130\" width=\"170\" height=\"70\" rx=\"14\" fill=\"#ecfbf3\" stroke=\"#1f9d61\" stroke-width=\"2\"\/><text x=\"875\" y=\"161\" text-anchor=\"middle\" font-size=\"18\" font-weight=\"800\" fill=\"#1f7a4c\">\u2705 Final answer<\/text><text x=\"875\" y=\"184\" text-anchor=\"middle\" font-size=\"13\" fill=\"#5b6275\">or stop at step limit<\/text>\n<\/g>\n<\/svg>\n<figcaption>Figure 2: The agent loop. The model keeps calling tools until it has enough information to answer.<\/figcaption>\n<\/figure>\n\n<div class=\"dd-note\"><strong>Good to know:<\/strong> this loop is often called the <strong>ReAct pattern<\/strong> (Reason + Act), named after a 2022 research paper. We will build a full ReAct agent in Part 5.<\/div>\n\n<h2 id=\"building-blocks\">The four building blocks of an AI agent<\/h2>\n<p>Every agent is made of the same four parts. In Part 2 we look at each one in depth, but here is the short version:<\/p>\n<div class=\"dd-cards\">\n<div class=\"dd-card\"><b>\ud83e\udde0 Model (the brain)<\/b>An LLM such as GPT, Claude or Gemini. It reads the history and decides what to do next.<\/div>\n<div class=\"dd-card\"><b>\ud83d\udee0\ufe0f Tools (the hands)<\/b>Functions the model may call: search, calculator, database, send email, run tests. Each tool has a name, a description and input rules.<\/div>\n<div class=\"dd-card\"><b>\ud83d\udccb Instructions (the rules)<\/b>The system prompt: who the agent is, what it may and may not do, and when to stop.<\/div>\n<div class=\"dd-card\"><b>\ud83d\udcdd Memory (the notes)<\/b>The conversation history inside the loop (short-term), plus saved facts across sessions (long-term).<\/div>\n<\/div>\n<p>Notice what is <em>not<\/em> in the list: the model never runs a tool itself. It only <em>asks<\/em> for a tool call. Your code checks the request, runs the function and sends the result back. That is great news for safety, because your code is always in control.<\/p>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"toy-agent\">Build a toy agent loop (no API key needed)<\/h2>\n<p>Let us see the loop in action without any AI service. In this example a small Python function called <code>fake_brain<\/code> plays the role of the LLM. It looks at its notes and decides the next action. Everything else, the tools, the loop, the memory and the step limit, is exactly how a real agent works.<\/p>\n<p>The goal: <em>&#8220;How much warmer is Delhi than Mumbai today?&#8221;<\/em> To answer, the agent must look up two temperatures and then do a subtraction. That is three tool calls, chosen one at a time.<\/p>\n\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: toy_agent.py, toy-agent.mjs\">\n<input type=\"radio\" name=\"v1\" id=\"v1f1\" class=\"f1\" checked>\n<input type=\"radio\" name=\"v1\" id=\"v1f2\" class=\"f2\">\n<input type=\"checkbox\" id=\"v1r1\" class=\"r1\">\n<input type=\"checkbox\" id=\"v1r2\" class=\"r2\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">2 files \u2014 agentic-ai-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v1f1\" class=\"t1\"><b class=\"ic py\">PY<\/b>toy_agent.py<\/label>\n<label for=\"v1f2\" class=\"t2\"><b class=\"ic js\">JS<\/b>toy-agent.mjs<\/label>\n<label for=\"v1r1\" class=\"run run1\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<label for=\"v1r2\" class=\"run run2\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a toy_agent.py<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># A tiny agent loop with a fake \"brain\" - no API key needed.<\/span><\/span>\n<span class=\"l\"><span class=\"c\"># It shows the shape of every agent: think -&gt; act -&gt; observe -&gt; repeat.<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">WEATHER<\/span> = {<span class=\"s\">\"delhi\"<\/span>: <span class=\"m\">31<\/span>, <span class=\"s\">\"mumbai\"<\/span>: <span class=\"m\">29<\/span>, <span class=\"s\">\"bengaluru\"<\/span>: <span class=\"m\">24<\/span>}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">get_weather<\/span>(<span class=\"n\">city<\/span>):<\/span>\n<span class=\"l\">    <span class=\"s\">\"\"\"Tool 1: look up today's temperature (fake data).\"\"\"<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"n\">WEATHER<\/span>.<span class=\"n\">get<\/span>(<span class=\"n\">city<\/span>.<span class=\"n\">lower<\/span>(), <span class=\"s\">\"unknown\"<\/span>)<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">calculate<\/span>(<span class=\"n\">expression<\/span>):<\/span>\n<span class=\"l\">    <span class=\"s\">\"\"\"Tool 2: do simple maths safely.\"\"\"<\/span><\/span>\n<span class=\"l\">    <span class=\"n\">allowed<\/span> = <span class=\"nb\">set<\/span>(<span class=\"s\">\"0123456789+-*\/(). \"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> <span class=\"k\">not<\/span> <span class=\"nb\">set<\/span>(<span class=\"n\">expression<\/span>) &lt;= <span class=\"n\">allowed<\/span>:<\/span>\n<span class=\"l\">        <span class=\"k\">return<\/span> <span class=\"s\">\"error: only numbers and + - * \/ allowed\"<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"nb\">eval<\/span>(<span class=\"n\">expression<\/span>)<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">TOOLS<\/span> = {<span class=\"s\">\"get_weather\"<\/span>: <span class=\"n\">get_weather<\/span>, <span class=\"s\">\"calculate\"<\/span>: <span class=\"n\">calculate<\/span>}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">fake_brain<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">notes<\/span>):<\/span>\n<span class=\"l\">    <span class=\"s\">\"\"\"Stands in for the LLM: decides the next action from what it knows.\"\"\"<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> <span class=\"s\">\"delhi\"<\/span> <span class=\"k\">not<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>:<\/span>\n<span class=\"l\">        <span class=\"k\">return<\/span> (<span class=\"s\">\"get_weather\"<\/span>, <span class=\"s\">\"Delhi\"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> <span class=\"s\">\"mumbai\"<\/span> <span class=\"k\">not<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>:<\/span>\n<span class=\"l\">        <span class=\"k\">return<\/span> (<span class=\"s\">\"get_weather\"<\/span>, <span class=\"s\">\"Mumbai\"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> <span class=\"s\">\"difference\"<\/span> <span class=\"k\">not<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>:<\/span>\n<span class=\"l\">        <span class=\"k\">return<\/span> (<span class=\"s\">\"calculate\"<\/span>, <span class=\"s\">f\"{<\/span><span class=\"n\">notes<\/span>[<span class=\"s\">'delhi'<\/span>]<span class=\"s\">} - {<\/span><span class=\"n\">notes<\/span>[<span class=\"s\">'mumbai'<\/span>]<span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> (<span class=\"s\">\"finish\"<\/span>, <span class=\"s\">f\"Delhi is {<\/span><span class=\"n\">notes<\/span>[<span class=\"s\">'difference'<\/span>]<span class=\"s\">} degrees warmer than Mumbai today.\"<\/span>)<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">run_agent<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">max_steps<\/span>=<span class=\"m\">5<\/span>):<\/span>\n<span class=\"l\">    <span class=\"n\">notes<\/span> = {}  <span class=\"c\"># the agent's short-term memory<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">for<\/span> <span class=\"n\">step<\/span> <span class=\"k\">in<\/span> <span class=\"nb\">range<\/span>(<span class=\"m\">1<\/span>, <span class=\"n\">max_steps<\/span> + <span class=\"m\">1<\/span>):<\/span>\n<span class=\"l\">        <span class=\"n\">action<\/span>, <span class=\"n\">arg<\/span> = <span class=\"n\">fake_brain<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">notes<\/span>)          <span class=\"c\"># 1. think<\/span><\/span>\n<span class=\"l\">        <span class=\"k\">if<\/span> <span class=\"n\">action<\/span> == <span class=\"s\">\"finish\"<\/span>:<\/span>\n<span class=\"l\">            <span class=\"nb\">print<\/span>(<span class=\"s\">f\"Step {<\/span><span class=\"n\">step<\/span><span class=\"s\">}: FINISH -&gt; {<\/span><span class=\"n\">arg<\/span><span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">            <span class=\"k\">return<\/span> <span class=\"n\">arg<\/span><\/span>\n<span class=\"l\">        <span class=\"n\">result<\/span> = <span class=\"n\">TOOLS<\/span>[<span class=\"n\">action<\/span>](<span class=\"n\">arg<\/span>)                      <span class=\"c\"># 2. act<\/span><\/span>\n<span class=\"l\">        <span class=\"nb\">print<\/span>(<span class=\"s\">f\"Step {<\/span><span class=\"n\">step<\/span><span class=\"s\">}: {<\/span><span class=\"n\">action<\/span><span class=\"s\">}({<\/span><span class=\"n\">arg<\/span><span class=\"s\">!r}) -&gt; {<\/span><span class=\"n\">result<\/span><span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">        <span class=\"n\">key<\/span> = <span class=\"n\">arg<\/span>.<span class=\"n\">lower<\/span>() <span class=\"k\">if<\/span> <span class=\"n\">action<\/span> == <span class=\"s\">\"get_weather\"<\/span> <span class=\"k\">else<\/span> <span class=\"s\">\"difference\"<\/span><\/span>\n<span class=\"l\">        <span class=\"n\">notes<\/span>[<span class=\"n\">key<\/span>] = <span class=\"n\">result<\/span>                              <span class=\"c\"># 3. observe<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"s\">\"Stopped: too many steps\"<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">run_agent<\/span>(<span class=\"s\">\"How much warmer is Delhi than Mumbai today?\"<\/span>)<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output<\/span><\/div><pre><code><span class=\"gp\">$<\/span> python toy_agent.py\nStep 1: get_weather('Delhi') -&gt; 31\nStep 2: get_weather('Mumbai') -&gt; 29\nStep 3: calculate('31 - 29') -&gt; 2\nStep 4: FINISH -&gt; Delhi is 2 degrees warmer than Mumbai today.<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 42, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 4<\/span><span>UTF-8<\/span><span>LF<\/span><span>Python<\/span><\/div>\n<\/div>\n<div class=\"dd-vsc-pane p2\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a toy-agent.mjs<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ A tiny agent loop with a fake \"brain\" - no API key needed.<\/span><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">WEATHER<\/span> = { <span class=\"n\">delhi<\/span>: <span class=\"m\">31<\/span>, <span class=\"n\">mumbai<\/span>: <span class=\"m\">29<\/span>, <span class=\"n\">bengaluru<\/span>: <span class=\"m\">24<\/span> };<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">tools<\/span> = {<\/span>\n<span class=\"l\">  <span class=\"n\">get_weather<\/span>: (<span class=\"n\">city<\/span>) =&gt; <span class=\"n\">WEATHER<\/span>[<span class=\"n\">city<\/span>.<span class=\"n\">toLowerCase<\/span>()] ?? <span class=\"s\">\"unknown\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"n\">calculate<\/span>: (<span class=\"n\">expr<\/span>) =&gt;<\/span>\n<span class=\"l\">    <span class=\"s\">\/^[0-9+\\-*\\\/(). ]+$\/<\/span>.<span class=\"n\">test<\/span>(<span class=\"n\">expr<\/span>) ? <span class=\"nb\">Function<\/span>(<span class=\"s\">`return (${<\/span><span class=\"n\">expr<\/span><span class=\"s\">})`<\/span>)() : <span class=\"s\">\"error\"<\/span>,<\/span>\n<span class=\"l\">};<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">function<\/span> <span class=\"n\">fakeBrain<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">notes<\/span>) {<\/span>\n<span class=\"l\">  <span class=\"k\">if<\/span> (!(<span class=\"s\">\"delhi\"<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>)) <span class=\"k\">return<\/span> [<span class=\"s\">\"get_weather\"<\/span>, <span class=\"s\">\"Delhi\"<\/span>];<\/span>\n<span class=\"l\">  <span class=\"k\">if<\/span> (!(<span class=\"s\">\"mumbai\"<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>)) <span class=\"k\">return<\/span> [<span class=\"s\">\"get_weather\"<\/span>, <span class=\"s\">\"Mumbai\"<\/span>];<\/span>\n<span class=\"l\">  <span class=\"k\">if<\/span> (!(<span class=\"s\">\"difference\"<\/span> <span class=\"k\">in<\/span> <span class=\"n\">notes<\/span>))<\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> [<span class=\"s\">\"calculate\"<\/span>, <span class=\"s\">`${<\/span><span class=\"n\">notes<\/span>.<span class=\"n\">delhi<\/span><span class=\"s\">} - ${<\/span><span class=\"n\">notes<\/span>.<span class=\"n\">mumbai<\/span><span class=\"s\">}`<\/span>];<\/span>\n<span class=\"l\">  <span class=\"k\">return<\/span> [<span class=\"s\">\"finish\"<\/span>, <span class=\"s\">`Delhi is ${<\/span><span class=\"n\">notes<\/span>.<span class=\"n\">difference<\/span><span class=\"s\">} degrees warmer than Mumbai today.`<\/span>];<\/span>\n<span class=\"l\">}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">function<\/span> <span class=\"n\">runAgent<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">maxSteps<\/span> = <span class=\"m\">5<\/span>) {<\/span>\n<span class=\"l\">  <span class=\"k\">const<\/span> <span class=\"n\">notes<\/span> = {};<\/span>\n<span class=\"l\">  <span class=\"k\">for<\/span> (<span class=\"k\">let<\/span> <span class=\"n\">step<\/span> = <span class=\"m\">1<\/span>; <span class=\"n\">step<\/span> &lt;= <span class=\"n\">maxSteps<\/span>; <span class=\"n\">step<\/span>++) {<\/span>\n<span class=\"l\">    <span class=\"k\">const<\/span> [<span class=\"n\">action<\/span>, <span class=\"n\">arg<\/span>] = <span class=\"n\">fakeBrain<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">notes<\/span>);      <span class=\"c\">\/\/ 1. think<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> (<span class=\"n\">action<\/span> === <span class=\"s\">\"finish\"<\/span>) {<\/span>\n<span class=\"l\">      <span class=\"n\">console<\/span>.<span class=\"n\">log<\/span>(<span class=\"s\">`Step ${<\/span><span class=\"n\">step<\/span><span class=\"s\">}: FINISH -&gt; ${<\/span><span class=\"n\">arg<\/span><span class=\"s\">}`<\/span>);<\/span>\n<span class=\"l\">      <span class=\"k\">return<\/span> <span class=\"n\">arg<\/span>;<\/span>\n<span class=\"l\">    }<\/span>\n<span class=\"l\">    <span class=\"k\">const<\/span> <span class=\"n\">result<\/span> = <span class=\"n\">tools<\/span>[<span class=\"n\">action<\/span>](<span class=\"n\">arg<\/span>);                  <span class=\"c\">\/\/ 2. act<\/span><\/span>\n<span class=\"l\">    <span class=\"n\">console<\/span>.<span class=\"n\">log<\/span>(<span class=\"s\">`Step ${<\/span><span class=\"n\">step<\/span><span class=\"s\">}: ${<\/span><span class=\"n\">action<\/span><span class=\"s\">}('${<\/span><span class=\"n\">arg<\/span><span class=\"s\">}') -&gt; ${<\/span><span class=\"n\">result<\/span><span class=\"s\">}`<\/span>);<\/span>\n<span class=\"l\">    <span class=\"k\">const<\/span> <span class=\"n\">key<\/span> = <span class=\"n\">action<\/span> === <span class=\"s\">\"get_weather\"<\/span> ? <span class=\"n\">arg<\/span>.<span class=\"n\">toLowerCase<\/span>() : <span class=\"s\">\"difference\"<\/span>;<\/span>\n<span class=\"l\">    <span class=\"n\">notes<\/span>[<span class=\"n\">key<\/span>] = <span class=\"n\">result<\/span>;                                <span class=\"c\">\/\/ 3. observe<\/span><\/span>\n<span class=\"l\">  }<\/span>\n<span class=\"l\">  <span class=\"k\">return<\/span> <span class=\"s\">\"Stopped: too many steps\"<\/span>;<\/span>\n<span class=\"l\">}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">runAgent<\/span>(<span class=\"s\">\"How much warmer is Delhi than Mumbai today?\"<\/span>);<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Real output<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node toy-agent.mjs\nStep 1: get_weather('Delhi') -&gt; 31\nStep 2: get_weather('Mumbai') -&gt; 29\nStep 3: calculate('31 - 29') -&gt; 2\nStep 4: FINISH -&gt; Delhi is 2 degrees warmer than Mumbai today.<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 34, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Switch between Python and Node.js with the tabs, then press <strong>\u25b6 Run<\/strong> to see the real output.<\/p>\n\n<p>Read the output line by line. In step 1 the agent did not know anything, so it asked for Delhi&#8217;s weather. In step 2 it noticed Mumbai was missing. In step 3 it had both numbers, so it used the calculator. In step 4 it had everything it needed and finished. Nobody wrote &#8220;call get_weather twice and then calculate&#8221;; the brain decided based on its notes. Now imagine replacing <code>fake_brain<\/code> with a real LLM that can reason about <em>any<\/em> goal. That is an AI agent.<\/p>\n<div class=\"dd-tip\"><strong>Try it:<\/strong> change <code>max_steps=5<\/code> to <code>max_steps=2<\/code> and run again. The agent stops early with &#8220;Stopped: too many steps&#8221;. This is your safety net in real agents.<\/div>\n\n<h2 id=\"real-agent\">Your first real AI agent with tool calling<\/h2>\n<p>Now let us give the loop a real brain. Modern LLM APIs support <strong>tool calling<\/strong> (also called function calling): you describe your tools with a name, a description and a JSON schema for the inputs, and the model replies either with normal text or with a request like <code>get_weather({\"city\": \"Delhi\"})<\/code>. We will use the OpenAI Responses API here, but Claude and Gemini work the same way, as you saw in <a href=\"https:\/\/devdojo.co.in\/?p=223\">Generative AI Part 3<\/a>.<\/p>\n\n<h3>Setup<\/h3>\n<div class=\"dd-vsc dd-vsc-termonly\" role=\"group\" aria-label=\"Terminal: agentic-ai-part1 \u2014 bash\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">agentic-ai-part1 \u2014 bash<\/span><\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># 1. Create a project folder<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> mkdir agentic-ai-part1 &amp;&amp; cd agentic-ai-part1<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"c\"># 2. Python: virtual environment + OpenAI SDK<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> python -m venv .venv<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> source .venv\/bin\/activate      # Windows: .venv\\Scripts\\activate<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> pip install openai python-dotenv<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"c\"># 3. Node.js (version 20.6 or newer for --env-file)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> npm init -y &amp;&amp; npm install openai<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"c\"># 4. Save your key in .env (never commit this file)<\/span><\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> echo \"OPENAI_API_KEY=sk-your-key\" &gt; .env<\/span>\n<span class=\"l\"><span class=\"gp\">$<\/span> echo \".env\" &gt;&gt; .gitignore<\/span><\/code><\/pre>\n<\/div>\n\n<h3>The agent code<\/h3>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: agent_openai.py, agent-openai.mjs\">\n<input type=\"radio\" name=\"v2\" id=\"v2f1\" class=\"f1\" checked>\n<input type=\"radio\" name=\"v2\" id=\"v2f2\" class=\"f2\">\n<input type=\"checkbox\" id=\"v2r1\" class=\"r1\">\n<input type=\"checkbox\" id=\"v2r2\" class=\"r2\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">2 files \u2014 agentic-ai-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v2f1\" class=\"t1\"><b class=\"ic py\">PY<\/b>agent_openai.py<\/label>\n<label for=\"v2f2\" class=\"t2\"><b class=\"ic js\">JS<\/b>agent-openai.mjs<\/label>\n<label for=\"v2r1\" class=\"run run1\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<label for=\"v2r2\" class=\"run run2\" title=\"Show the output in the terminal\">\u25b6 Run<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a agent_openai.py<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># pip install openai python-dotenv<\/span><\/span>\n<span class=\"l\"><span class=\"kn\">import<\/span> <span class=\"n\">json<\/span><\/span>\n<span class=\"l\"><span class=\"kn\">import<\/span> <span class=\"n\">os<\/span><\/span>\n<span class=\"l\"><span class=\"kn\">from<\/span> <span class=\"n\">dotenv<\/span> <span class=\"kn\">import<\/span> <span class=\"n\">load_dotenv<\/span><\/span>\n<span class=\"l\"><span class=\"kn\">from<\/span> <span class=\"n\">openai<\/span> <span class=\"kn\">import<\/span> <span class=\"n\">OpenAI<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">load_dotenv<\/span>()<\/span>\n<span class=\"l\"><span class=\"n\">client<\/span> = <span class=\"n\">OpenAI<\/span>()  <span class=\"c\"># reads OPENAI_API_KEY from .env<\/span><\/span>\n<span class=\"l\"><span class=\"n\">MODEL<\/span> = <span class=\"n\">os<\/span>.<span class=\"n\">getenv<\/span>(<span class=\"s\">\"OPENAI_MODEL\"<\/span>, <span class=\"s\">\"gpt-6-luna\"<\/span>)<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">WEATHER<\/span> = {<span class=\"s\">\"delhi\"<\/span>: <span class=\"m\">31<\/span>, <span class=\"s\">\"mumbai\"<\/span>: <span class=\"m\">29<\/span>, <span class=\"s\">\"bengaluru\"<\/span>: <span class=\"m\">24<\/span>}  <span class=\"c\"># fake data<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">get_weather<\/span>(<span class=\"n\">city<\/span>):<\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"n\">json<\/span>.<span class=\"n\">dumps<\/span>({<span class=\"s\">\"city\"<\/span>: <span class=\"n\">city<\/span>, <span class=\"s\">\"temp_c\"<\/span>: <span class=\"n\">WEATHER<\/span>.<span class=\"n\">get<\/span>(<span class=\"n\">city<\/span>.<span class=\"n\">lower<\/span>())})<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">TOOLS<\/span> = [{<\/span>\n<span class=\"l\">    <span class=\"s\">\"type\"<\/span>: <span class=\"s\">\"function\"<\/span>,<\/span>\n<span class=\"l\">    <span class=\"s\">\"name\"<\/span>: <span class=\"s\">\"get_weather\"<\/span>,<\/span>\n<span class=\"l\">    <span class=\"s\">\"description\"<\/span>: <span class=\"s\">\"Get today's temperature in Celsius for an Indian city.\"<\/span>,<\/span>\n<span class=\"l\">    <span class=\"s\">\"parameters\"<\/span>: {<\/span>\n<span class=\"l\">        <span class=\"s\">\"type\"<\/span>: <span class=\"s\">\"object\"<\/span>,<\/span>\n<span class=\"l\">        <span class=\"s\">\"properties\"<\/span>: {<span class=\"s\">\"city\"<\/span>: {<span class=\"s\">\"type\"<\/span>: <span class=\"s\">\"string\"<\/span>, <span class=\"s\">\"description\"<\/span>: <span class=\"s\">\"e.g. Delhi\"<\/span>}},<\/span>\n<span class=\"l\">        <span class=\"s\">\"required\"<\/span>: [<span class=\"s\">\"city\"<\/span>],<\/span>\n<span class=\"l\">        <span class=\"s\">\"additionalProperties\"<\/span>: <span class=\"kc\">False<\/span>,<\/span>\n<span class=\"l\">    },<\/span>\n<span class=\"l\">    <span class=\"s\">\"strict\"<\/span>: <span class=\"kc\">True<\/span>,<\/span>\n<span class=\"l\">}]<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">run_agent<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">max_steps<\/span>=<span class=\"m\">6<\/span>):<\/span>\n<span class=\"l\">    <span class=\"n\">history<\/span> = [{<span class=\"s\">\"role\"<\/span>: <span class=\"s\">\"user\"<\/span>, <span class=\"s\">\"content\"<\/span>: <span class=\"n\">goal<\/span>}]<\/span>\n<span class=\"l\">    <span class=\"k\">for<\/span> <span class=\"n\">step<\/span> <span class=\"k\">in<\/span> <span class=\"nb\">range<\/span>(<span class=\"n\">max_steps<\/span>):<\/span>\n<span class=\"l\">        <span class=\"n\">response<\/span> = <span class=\"n\">client<\/span>.<span class=\"n\">responses<\/span>.<span class=\"n\">create<\/span>(<\/span>\n<span class=\"l\">            <span class=\"n\">model<\/span>=<span class=\"n\">MODEL<\/span>,<\/span>\n<span class=\"l\">            <span class=\"n\">instructions<\/span>=<span class=\"s\">\"You are a weather helper. Always use tools for facts.\"<\/span>,<\/span>\n<span class=\"l\">            <span class=\"nb\">input<\/span>=<span class=\"n\">history<\/span>,<\/span>\n<span class=\"l\">            <span class=\"n\">tools<\/span>=<span class=\"n\">TOOLS<\/span>,<\/span>\n<span class=\"l\">        )<\/span>\n<span class=\"l\">        <span class=\"n\">calls<\/span> = [<span class=\"n\">item<\/span> <span class=\"k\">for<\/span> <span class=\"n\">item<\/span> <span class=\"k\">in<\/span> <span class=\"n\">response<\/span>.<span class=\"n\">output<\/span> <span class=\"k\">if<\/span> <span class=\"n\">item<\/span>.<span class=\"n\">type<\/span> == <span class=\"s\">\"function_call\"<\/span>]<\/span>\n<span class=\"l\">        <span class=\"k\">if<\/span> <span class=\"k\">not<\/span> <span class=\"n\">calls<\/span>:                   <span class=\"c\"># no tool requested = final answer<\/span><\/span>\n<span class=\"l\">            <span class=\"k\">return<\/span> <span class=\"n\">response<\/span>.<span class=\"n\">output_text<\/span><\/span>\n<span class=\"l\">        <span class=\"n\">history<\/span> += <span class=\"n\">response<\/span>.<span class=\"n\">output<\/span>      <span class=\"c\"># remember what the model asked for<\/span><\/span>\n<span class=\"l\">        <span class=\"k\">for<\/span> <span class=\"n\">call<\/span> <span class=\"k\">in<\/span> <span class=\"n\">calls<\/span>:<\/span>\n<span class=\"l\">            <span class=\"n\">args<\/span> = <span class=\"n\">json<\/span>.<span class=\"n\">loads<\/span>(<span class=\"n\">call<\/span>.<span class=\"n\">arguments<\/span>)<\/span>\n<span class=\"l\">            <span class=\"n\">result<\/span> = <span class=\"n\">get_weather<\/span>(**<span class=\"n\">args<\/span>)<\/span>\n<span class=\"l\">            <span class=\"nb\">print<\/span>(<span class=\"s\">f\"  tool: {<\/span><span class=\"n\">call<\/span>.<span class=\"n\">name<\/span><span class=\"s\">}({<\/span><span class=\"n\">args<\/span><span class=\"s\">}) -&gt; {<\/span><span class=\"n\">result<\/span><span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">            <span class=\"n\">history<\/span>.<span class=\"n\">append<\/span>({<\/span>\n<span class=\"l\">                <span class=\"s\">\"type\"<\/span>: <span class=\"s\">\"function_call_output\"<\/span>,<\/span>\n<span class=\"l\">                <span class=\"s\">\"call_id\"<\/span>: <span class=\"n\">call<\/span>.<span class=\"n\">call_id<\/span>,<\/span>\n<span class=\"l\">                <span class=\"s\">\"output\"<\/span>: <span class=\"n\">result<\/span>,<\/span>\n<span class=\"l\">            })<\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"s\">\"Stopped: step limit reached\"<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"nb\">print<\/span>(<span class=\"n\">run_agent<\/span>(<span class=\"s\">\"Is it warmer in Delhi or Mumbai today, and by how much?\"<\/span>))<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Example output \u2013 the wording will differ<\/span><\/div><pre><code><span class=\"gp\">$<\/span> python agent_openai.py\n  tool: get_weather({'city': 'Delhi'}) -&gt; {\"city\": \"Delhi\", \"temp_c\": 31}\n  tool: get_weather({'city': 'Mumbai'}) -&gt; {\"city\": \"Mumbai\", \"temp_c\": 29}\nDelhi is warmer today: 31\u00b0C vs 29\u00b0C in Mumbai, so it is 2\u00b0C warmer.<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 53, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 4<\/span><span>UTF-8<\/span><span>LF<\/span><span>Python<\/span><\/div>\n<\/div>\n<div class=\"dd-vsc-pane p2\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a agent-openai.mjs<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\">\/\/ npm install openai<\/span><\/span>\n<span class=\"l\"><span class=\"c\">\/\/ run with: node --env-file=.env agent-openai.mjs<\/span><\/span>\n<span class=\"l\"><span class=\"k\">import<\/span> <span class=\"n\">OpenAI<\/span> <span class=\"k\">from<\/span> <span class=\"s\">\"openai\"<\/span>;<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">client<\/span> = <span class=\"k\">new<\/span> <span class=\"n\">OpenAI<\/span>(); <span class=\"c\">\/\/ reads OPENAI_API_KEY from the environment<\/span><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">MODEL<\/span> = <span class=\"n\">process<\/span>.<span class=\"n\">env<\/span>.<span class=\"n\">OPENAI_MODEL<\/span> ?? <span class=\"s\">\"gpt-6-luna\"<\/span>;<\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">WEATHER<\/span> = { <span class=\"n\">delhi<\/span>: <span class=\"m\">31<\/span>, <span class=\"n\">mumbai<\/span>: <span class=\"m\">29<\/span>, <span class=\"n\">bengaluru<\/span>: <span class=\"m\">24<\/span> }; <span class=\"c\">\/\/ fake data<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">function<\/span> <span class=\"n\">getWeather<\/span>({ <span class=\"n\">city<\/span> }) {<\/span>\n<span class=\"l\">  <span class=\"k\">return<\/span> <span class=\"nb\">JSON<\/span>.<span class=\"n\">stringify<\/span>({ <span class=\"n\">city<\/span>, <span class=\"n\">temp_c<\/span>: <span class=\"n\">WEATHER<\/span>[<span class=\"n\">city<\/span>.<span class=\"n\">toLowerCase<\/span>()] ?? <span class=\"kc\">null<\/span> });<\/span>\n<span class=\"l\">}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">const<\/span> <span class=\"n\">tools<\/span> = [{<\/span>\n<span class=\"l\">  <span class=\"n\">type<\/span>: <span class=\"s\">\"function\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"n\">name<\/span>: <span class=\"s\">\"get_weather\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"n\">description<\/span>: <span class=\"s\">\"Get today's temperature in Celsius for an Indian city.\"<\/span>,<\/span>\n<span class=\"l\">  <span class=\"n\">parameters<\/span>: {<\/span>\n<span class=\"l\">    <span class=\"n\">type<\/span>: <span class=\"s\">\"object\"<\/span>,<\/span>\n<span class=\"l\">    <span class=\"n\">properties<\/span>: { <span class=\"n\">city<\/span>: { <span class=\"n\">type<\/span>: <span class=\"s\">\"string\"<\/span>, <span class=\"n\">description<\/span>: <span class=\"s\">\"e.g. Delhi\"<\/span> } },<\/span>\n<span class=\"l\">    <span class=\"n\">required<\/span>: [<span class=\"s\">\"city\"<\/span>],<\/span>\n<span class=\"l\">    <span class=\"n\">additionalProperties<\/span>: <span class=\"kc\">false<\/span>,<\/span>\n<span class=\"l\">  },<\/span>\n<span class=\"l\">  <span class=\"n\">strict<\/span>: <span class=\"kc\">true<\/span>,<\/span>\n<span class=\"l\">}];<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">async<\/span> <span class=\"k\">function<\/span> <span class=\"n\">runAgent<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">maxSteps<\/span> = <span class=\"m\">6<\/span>) {<\/span>\n<span class=\"l\">  <span class=\"k\">const<\/span> <span class=\"n\">history<\/span> = [{ <span class=\"n\">role<\/span>: <span class=\"s\">\"user\"<\/span>, <span class=\"n\">content<\/span>: <span class=\"n\">goal<\/span> }];<\/span>\n<span class=\"l\">  <span class=\"k\">for<\/span> (<span class=\"k\">let<\/span> <span class=\"n\">step<\/span> = <span class=\"m\">0<\/span>; <span class=\"n\">step<\/span> &lt; <span class=\"n\">maxSteps<\/span>; <span class=\"n\">step<\/span>++) {<\/span>\n<span class=\"l\">    <span class=\"k\">const<\/span> <span class=\"n\">response<\/span> = <span class=\"k\">await<\/span> <span class=\"n\">client<\/span>.<span class=\"n\">responses<\/span>.<span class=\"n\">create<\/span>({<\/span>\n<span class=\"l\">      <span class=\"n\">model<\/span>: <span class=\"n\">MODEL<\/span>,<\/span>\n<span class=\"l\">      <span class=\"n\">instructions<\/span>: <span class=\"s\">\"You are a weather helper. Always use tools for facts.\"<\/span>,<\/span>\n<span class=\"l\">      <span class=\"n\">input<\/span>: <span class=\"n\">history<\/span>,<\/span>\n<span class=\"l\">      <span class=\"n\">tools<\/span>,<\/span>\n<span class=\"l\">    });<\/span>\n<span class=\"l\">    <span class=\"k\">const<\/span> <span class=\"n\">calls<\/span> = <span class=\"n\">response<\/span>.<span class=\"n\">output<\/span>.<span class=\"n\">filter<\/span>((<span class=\"n\">item<\/span>) =&gt; <span class=\"n\">item<\/span>.<span class=\"n\">type<\/span> === <span class=\"s\">\"function_call\"<\/span>);<\/span>\n<span class=\"l\">    <span class=\"k\">if<\/span> (<span class=\"n\">calls<\/span>.<span class=\"n\">length<\/span> === <span class=\"m\">0<\/span>) <span class=\"k\">return<\/span> <span class=\"n\">response<\/span>.<span class=\"n\">output_text<\/span>; <span class=\"c\">\/\/ final answer<\/span><\/span>\n<span class=\"l\">    <span class=\"n\">history<\/span>.<span class=\"n\">push<\/span>(...<span class=\"n\">response<\/span>.<span class=\"n\">output<\/span>);<\/span>\n<span class=\"l\">    <span class=\"k\">for<\/span> (<span class=\"k\">const<\/span> <span class=\"n\">call<\/span> <span class=\"k\">of<\/span> <span class=\"n\">calls<\/span>) {<\/span>\n<span class=\"l\">      <span class=\"k\">const<\/span> <span class=\"n\">result<\/span> = <span class=\"n\">getWeather<\/span>(<span class=\"nb\">JSON<\/span>.<span class=\"n\">parse<\/span>(<span class=\"n\">call<\/span>.<span class=\"nb\">arguments<\/span>));<\/span>\n<span class=\"l\">      <span class=\"n\">console<\/span>.<span class=\"n\">log<\/span>(<span class=\"s\">`  tool: ${<\/span><span class=\"n\">call<\/span>.<span class=\"n\">name<\/span><span class=\"s\">}(${<\/span><span class=\"n\">call<\/span>.<span class=\"nb\">arguments<\/span><span class=\"s\">}) -&gt; ${<\/span><span class=\"n\">result<\/span><span class=\"s\">}`<\/span>);<\/span>\n<span class=\"l\">      <span class=\"n\">history<\/span>.<span class=\"n\">push<\/span>({ <span class=\"n\">type<\/span>: <span class=\"s\">\"function_call_output\"<\/span>, <span class=\"n\">call_id<\/span>: <span class=\"n\">call<\/span>.<span class=\"n\">call_id<\/span>, <span class=\"n\">output<\/span>: <span class=\"n\">result<\/span> });<\/span>\n<span class=\"l\">    }<\/span>\n<span class=\"l\">  }<\/span>\n<span class=\"l\">  <span class=\"k\">return<\/span> <span class=\"s\">\"Stopped: step limit reached\"<\/span>;<\/span>\n<span class=\"l\">}<\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"n\">console<\/span>.<span class=\"n\">log<\/span>(<span class=\"k\">await<\/span> <span class=\"n\">runAgent<\/span>(<span class=\"s\">\"Is it warmer in Delhi or Mumbai today, and by how much?\"<\/span>));<\/span><\/code><\/pre>\n<div class=\"dd-vsc-term\"><div class=\"dd-term-head\"><span>TERMINAL<\/span><span>OUTPUT<\/span><span>PROBLEMS<\/span><span class=\"dd-term-note\">Example output \u2013 the wording will differ<\/span><\/div><pre><code><span class=\"gp\">$<\/span> node --env-file=.env agent-openai.mjs\n  tool: get_weather({\"city\":\"Delhi\"}) -&gt; {\"city\":\"Delhi\",\"temp_c\":31}\n  tool: get_weather({\"city\":\"Mumbai\"}) -&gt; {\"city\":\"Mumbai\",\"temp_c\":29}\nDelhi is warmer today: 31\u00b0C vs 29\u00b0C in Mumbai, so it is 2\u00b0C warmer.<\/code><\/pre><\/div>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 47, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 2<\/span><span>UTF-8<\/span><span>LF<\/span><span>JavaScript<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Click the tabs to compare Python and Node.js, then press <strong>\u25b6 Run<\/strong>. The output is an example; the model writes its own wording each time.<\/p>\n\n<p>Here is what happens inside <code>run_agent<\/code>:<\/p>\n<ol>\n<li>We send the goal, the instructions and the <code>TOOLS<\/code> list to the model.<\/li>\n<li>If the reply contains <code>function_call<\/code> items, the model wants to use a tool. We run <code>get_weather<\/code> with the arguments it chose, and add a <code>function_call_output<\/code> item with the same <code>call_id<\/code>, so the model knows which result belongs to which request.<\/li>\n<li>We call the model again with the longer history. When it has enough information, it replies with plain text, and <code>response.output_text<\/code> is our final answer.<\/li>\n<li>The <code>max_steps<\/code> limit protects us from endless loops.<\/li>\n<\/ol>\n<p>The model may ask for both cities in the same turn (two tool calls at once), which is why we loop over <code>calls<\/code>. The <code>strict: True<\/code> setting tells the API to make the arguments match your schema exactly. For all the options, see the official <a href=\"https:\/\/developers.openai.com\/api\/docs\/guides\/function-calling\" target=\"_blank\" rel=\"noopener\">OpenAI function calling guide<\/a>.<\/p>\n<div class=\"dd-warn\"><strong>Important:<\/strong> the model chooses <em>which<\/em> tool to call and <em>with what<\/em> arguments, so treat its tool calls like user input. Validate arguments, and never give an agent a tool like &#8220;run any shell command&#8221; or &#8220;delete any row&#8221; without limits and human approval.<\/div>\n\n<h2 id=\"workflow-vs-agent-code\">Workflow vs agent in code<\/h2>\n<p>The difference between a workflow and an agent is easy to see in code. In a workflow, <em>you<\/em> write the steps. In an agent, you write a loop and the model chooses the steps.<\/p>\n<div class=\"dd-vsc\" role=\"group\" aria-label=\"Code editor: workflow.py, agent_skeleton.py\">\n<input type=\"radio\" name=\"v3\" id=\"v3f1\" class=\"f1\" checked>\n<input type=\"radio\" name=\"v3\" id=\"v3f2\" class=\"f2\">\n<div class=\"dd-vsc-bar\"><span class=\"dd-dots\"><i><\/i><i><\/i><i><\/i><\/span><span class=\"dd-vsc-title\">2 files \u2014 agentic-ai-part1 \u2014 Visual Studio Code<\/span><\/div>\n<div class=\"dd-vsc-tabs\">\n<label for=\"v3f1\" class=\"t1\"><b class=\"ic py\">PY<\/b>workflow.py<\/label>\n<label for=\"v3f2\" class=\"t2\"><b class=\"ic py\">PY<\/b>agent_skeleton.py<\/label>\n<\/div>\n<div class=\"dd-vsc-pane p1\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a workflow.py<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># WORKFLOW: your code decides every step, in a fixed order.<\/span><\/span>\n<span class=\"l\"><span class=\"kn\">from<\/span> <span class=\"n\">llm<\/span> <span class=\"kn\">import<\/span> <span class=\"n\">ask<\/span>  <span class=\"c\"># the small ask() helper from GenAI Part 3<\/span><\/span>\n<span class=\"l\"><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">summarise_article<\/span>(<span class=\"n\">article<\/span>):<\/span>\n<span class=\"l\">    <span class=\"n\">points<\/span> = <span class=\"n\">ask<\/span>(<span class=\"s\">f\"List the 3 main points of this article:\\n{<\/span><span class=\"n\">article<\/span><span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"n\">draft<\/span> = <span class=\"n\">ask<\/span>(<span class=\"s\">f\"Write a 60-word summary from these points:\\n{<\/span><span class=\"n\">points<\/span><span class=\"s\">}\"<\/span>)<\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"n\">ask<\/span>(<span class=\"s\">f\"Fix grammar. Keep it under 60 words:\\n{<\/span><span class=\"n\">draft<\/span><span class=\"s\">}\"<\/span>)<\/span><\/code><\/pre>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 7, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 4<\/span><span>UTF-8<\/span><span>LF<\/span><span>Python<\/span><\/div>\n<\/div>\n<div class=\"dd-vsc-pane p2\">\n<div class=\"dd-vsc-crumbs\">agentic-ai-part1 \u203a agent_skeleton.py<\/div>\n<pre class=\"dd-vsc-code\"><code><span class=\"l\"><span class=\"c\"># AGENT: the model decides the next step, your code just runs the loop.<\/span><\/span>\n<span class=\"l\"><span class=\"k\">def<\/span> <span class=\"nf\">agent<\/span>(<span class=\"n\">goal<\/span>, <span class=\"n\">llm<\/span>, <span class=\"n\">tools<\/span>, <span class=\"n\">max_steps<\/span>=<span class=\"m\">10<\/span>):<\/span>\n<span class=\"l\">    <span class=\"n\">history<\/span> = [<span class=\"n\">goal<\/span>]<\/span>\n<span class=\"l\">    <span class=\"k\">for<\/span> <span class=\"n\">_<\/span> <span class=\"k\">in<\/span> <span class=\"nb\">range<\/span>(<span class=\"n\">max_steps<\/span>):<\/span>\n<span class=\"l\">        <span class=\"n\">decision<\/span> = <span class=\"n\">llm<\/span>(<span class=\"n\">history<\/span>, <span class=\"n\">tools<\/span>)        <span class=\"c\"># think: what should I do next?<\/span><\/span>\n<span class=\"l\">        <span class=\"k\">if<\/span> <span class=\"n\">decision<\/span>.<span class=\"n\">is_final_answer<\/span>:<\/span>\n<span class=\"l\">            <span class=\"k\">return<\/span> <span class=\"n\">decision<\/span>.<span class=\"n\">text<\/span>              <span class=\"c\"># done: goal reached<\/span><\/span>\n<span class=\"l\">        <span class=\"n\">tool<\/span> = <span class=\"n\">tools<\/span>[<span class=\"n\">decision<\/span>.<span class=\"n\">tool_name<\/span>]<\/span>\n<span class=\"l\">        <span class=\"n\">result<\/span> = <span class=\"n\">tool<\/span>(**<span class=\"n\">decision<\/span>.<span class=\"n\">arguments<\/span>)   <span class=\"c\"># act: run the chosen tool<\/span><\/span>\n<span class=\"l\">        <span class=\"n\">history<\/span>.<span class=\"n\">append<\/span>(<span class=\"n\">result<\/span>)                <span class=\"c\"># observe: add the result<\/span><\/span>\n<span class=\"l\">    <span class=\"k\">return<\/span> <span class=\"s\">\"Stopped: step limit reached\"<\/span>      <span class=\"c\"># safety net<\/span><\/span><\/code><\/pre>\n<div class=\"dd-vsc-status\"><span>\u2387 main<\/span><span>Ln 11, Col 1<\/span><span class=\"sp\"><\/span><span>Spaces: 4<\/span><span>UTF-8<\/span><span>LF<\/span><span>Python<\/span><\/div>\n<\/div>\n<\/div>\n<p class=\"dd-vsc-hint\">Open both tabs: same LLM, very different control flow.<\/p>\n<p>The workflow always makes exactly three LLM calls in the same order, so it is cheap and easy to test. The agent may make one call or ten, depending on the goal. Start with a workflow when you can; switch to an agent when the path really depends on what the model discovers along the way.<\/p>\n\n<h2 id=\"levels\">Levels of autonomy: from chat to multi-agent<\/h2>\n<p>&#8220;Agentic&#8221; is not yes-or-no; it is a scale. The more decisions you hand to the model, the more agentic the system is. Click the levels below:<\/p>\n<div class=\"dd-tabs\">\n<input type=\"radio\" name=\"lvl\" id=\"ti1\" checked>\n<input type=\"radio\" name=\"lvl\" id=\"ti2\">\n<input type=\"radio\" name=\"lvl\" id=\"ti3\">\n<input type=\"radio\" name=\"lvl\" id=\"ti4\">\n<div class=\"labels\"><label for=\"ti1\">Level 1: Chat<\/label><label for=\"ti2\">Level 2: Workflow<\/label><label for=\"ti3\">Level 3: Agent<\/label><label for=\"ti4\">Level 4: Multi-agent<\/label><\/div>\n<div class=\"panel p1\"><p><strong>The model only writes text.<\/strong> You ask, it answers. No tools, no loop. Example: asking an LLM to explain a regular expression.<\/p><p><em>Control:<\/em> 100% with you. <em>Risk:<\/em> very low.<\/p><\/div>\n<div class=\"panel p2\"><p><strong>The model fills in steps that your code planned.<\/strong> For example: classify a support ticket \u2192 route it to the right prompt \u2192 draft a reply for a human to send.<\/p><p><em>Control:<\/em> your code decides the path. <em>Risk:<\/em> low and easy to test.<\/p><\/div>\n<div class=\"panel p3\"><p><strong>The model decides the next step in a loop and uses tools.<\/strong> For example: a coding agent that reads files, runs tests, edits code and runs the tests again until they pass.<\/p><p><em>Control:<\/em> shared. You decide which tools exist; the model decides when to use them. <em>Risk:<\/em> medium, so add step limits and approvals.<\/p><\/div>\n<div class=\"panel p4\"><p><strong>Several agents work together<\/strong>, each with its own tools and instructions. A &#8220;manager&#8221; agent may hand tasks to a researcher agent and a writer agent.<\/p><p><em>Control:<\/em> mostly with the agents. <em>Risk:<\/em> higher, and harder to debug. We cover this in Part 17.<\/p><\/div>\n<\/div>\n\n<h2 id=\"examples\">Real-world examples of agentic AI<\/h2>\n<ul>\n<li><strong>Coding agents:<\/strong> tools like Claude Code, OpenAI Codex and GitHub Copilot&#8217;s agent mode read your project, edit files and run commands to finish a task. (Our guide on <a href=\"https:\/\/devdojo.co.in\/?p=206\">writing AGENTS.md files<\/a> shows how to give them project rules.)<\/li>\n<li><strong>Research agents:<\/strong> &#8220;deep research&#8221; features search many sources, read them and write a report with citations.<\/li>\n<li><strong>Customer support agents:<\/strong> look up an order, check the refund policy and create a refund request, asking a human for approval above a limit.<\/li>\n<li><strong>DevOps agents:<\/strong> read alerts and logs, find the likely cause and suggest (or apply) a fix.<\/li>\n<li><strong>Data agents:<\/strong> turn a question like &#8220;which city had the most sign-ups last month?&#8221; into SQL, run it and explain the result.<\/li>\n<\/ul>\n<p>Agents also need a standard way to connect to tools. That is what the <strong>Model Context Protocol (MCP)<\/strong> does; see our tutorial on <a href=\"https:\/\/devdojo.co.in\/?p=164\">building an MCP server in TypeScript<\/a>. And if you want a ready-made framework, read the <a href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/08\/openai-agents-sdk-python\/\">OpenAI Agents SDK tutorial<\/a>. In this series, though, we first build agents from scratch so you understand every piece.<\/p>\n\n<h2 id=\"when-not\">When should you not use an agent?<\/h2>\n<p>Agents are exciting, but they are not always the right tool. Skip the agent when:<\/p>\n<ul>\n<li><strong>The steps are always the same.<\/strong> A fixed workflow is cheaper, faster and easier to test.<\/li>\n<li><strong>One LLM call is enough.<\/strong> Summarising one document does not need a loop.<\/li>\n<li><strong>Mistakes are very costly and cannot be undone<\/strong> (payments, deleting data) and you cannot add human approval.<\/li>\n<li><strong>You need an answer in under a second.<\/strong> Every loop step adds another model call.<\/li>\n<\/ul>\n<p>A good rule from experienced teams: start with the simplest thing that works, and add agency only when it clearly improves results.<\/p>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"common-errors\">Common errors and fixes<\/h2>\n<div class=\"dd-tablewrap\"><table>\n<thead><tr><th>Problem<\/th><th>Why it happens<\/th><th>Fix<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>Agent loops forever or repeats the same tool call<\/td><td>No step limit, or the tool result is not added to the history<\/td><td>Always set <code>max_steps<\/code>; append every <code>function_call_output<\/code> to the history<\/td><\/tr>\n<tr><td><code>400<\/code> error: no tool call found for function call output<\/td><td>The <code>call_id<\/code> does not match, or the model&#8217;s <code>function_call<\/code> item was not sent back<\/td><td>Add <code>response.output<\/code> to the history <em>before<\/em> the outputs, and copy <code>call.call_id<\/code> exactly<\/td><\/tr>\n<tr><td>Model answers from memory instead of using the tool<\/td><td>Weak instructions or a vague tool description<\/td><td>Say &#8220;Always use tools for facts&#8221; and describe clearly what each tool returns<\/td><\/tr>\n<tr><td><code>JSONDecodeError<\/code> when reading arguments<\/td><td>Arguments are a JSON <em>string<\/em>, not an object<\/td><td>Use <code>json.loads(call.arguments)<\/code> \/ <code>JSON.parse(call.arguments)<\/code>; turn on <code>strict<\/code> mode<\/td><\/tr>\n<tr><td>Tool crashes and the whole agent stops<\/td><td>Exceptions inside the tool are not caught<\/td><td>Catch errors and return them as text (e.g. <code>\"error: city not found\"<\/code>) so the model can try something else<\/td><\/tr>\n<tr><td>Bill is higher than expected<\/td><td>Each loop step resends the whole history<\/td><td>Lower <code>max_steps<\/code>, keep tool outputs short, and log token usage per run<\/td><\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<h2 id=\"best-practices\">Best practices for your first agents<\/h2>\n<ul>\n<li><strong>Start simple.<\/strong> One model, two or three tools, one clear goal. Add more only when you need it.<\/li>\n<li><strong>Write tool descriptions like documentation.<\/strong> The model reads them to decide what to call. Say what the tool does, what each input means, and what it returns.<\/li>\n<li><strong>Always have a stop condition.<\/strong> A step limit, a time limit and a cost limit.<\/li>\n<li><strong>Keep humans in the loop for risky actions.<\/strong> Ask for approval before sending emails, spending money or changing data.<\/li>\n<li><strong>Log every step.<\/strong> Print or save each tool call and result. When an agent goes wrong, these logs (called a <em>trace<\/em>) show you why.<\/li>\n<li><strong>Give least privilege.<\/strong> A tool that reads one table is safer than a tool that runs any SQL.<\/li>\n<li><strong>Test with real tasks.<\/strong> Collect 10 to 20 example goals and check how often the agent succeeds after every change.<\/li>\n<\/ul>\n\n<h2 id=\"practice\">Practice task<\/h2>\n<p>Extend the toy agent from this part:<\/p>\n<ol>\n<li>Add a third tool, <code>convert_to_fahrenheit(celsius)<\/code>, that returns <code>celsius * 9 \/ 5 + 32<\/code>.<\/li>\n<li>Change <code>fake_brain<\/code> so that, after finding the difference, it also converts Delhi&#8217;s temperature to Fahrenheit before finishing.<\/li>\n<li>Print the full <code>notes<\/code> dictionary at the end so you can see the agent&#8217;s memory.<\/li>\n<li>Bonus: in the real agent (<code>agent_openai.py<\/code>), add the same tool to <code>TOOLS<\/code> and ask: &#8220;What is the temperature in Bengaluru in Fahrenheit?&#8221; Watch the model chain two tools by itself.<\/li>\n<\/ol>\n<div class=\"dd-tip\"><strong>Hint:<\/strong> the loop logic itself does not change when you add a tool. Add the function and its description to <code>TOOLS<\/code>, then pick which function to run by <code>call.name<\/code>, for example with a small dictionary like <code>{\"get_weather\": get_weather, \"convert_to_fahrenheit\": convert_to_fahrenheit}<\/code>. The model decides when to use each one. That is the power of agents.<\/div>\n\n<h2 id=\"faq\">FAQ: agentic AI and AI agents<\/h2>\n<details><summary>What is the difference between generative AI and agentic AI?<\/summary><p>Generative AI creates content such as text, images or code from a prompt. Agentic AI <em>uses<\/em> generative models as a brain inside a loop, so the system can take actions with tools and work towards a goal over many steps.<\/p><\/details>\n<details><summary>Is ChatGPT an AI agent?<\/summary><p>A plain chat is not an agent. But when ChatGPT, Claude or Gemini search the web, run code or use connected apps on their own to finish a task, they are acting as agents.<\/p><\/details>\n<details><summary>Do I need a framework like LangChain or LangGraph to build agents?<\/summary><p>No. As you saw, an agent is a loop plus tool calling, about 40 lines of code. Frameworks help later with memory, tracing and multi-agent setups. We compare them in Part 11.<\/p><\/details>\n<details><summary>Which programming language is best for AI agents?<\/summary><p>Python has the most libraries and examples, and TypeScript\/Node.js is very popular for web apps. Both are fully supported by all major LLM SDKs, which is why this series shows both.<\/p><\/details>\n<details><summary>Are AI agents safe to use in production?<\/summary><p>They can be, with care: limited tools, input validation, step and cost limits, logging, and human approval for risky actions. We cover agent security and prompt injection in Part 22.<\/p><\/details>\n<details><summary>Will AI agents replace developers?<\/summary><p>Agents are very good at well-defined tasks, but someone still has to set goals, design tools, review results and own the system. Developers who know how to build and guide agents are in high demand.<\/p><\/details>\n\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>You now know what <strong>agentic AI<\/strong> really means: AI systems that pursue a goal by running a <strong>think \u2192 act \u2192 observe<\/strong> loop with tools, instructions and memory. You saw how agents differ from chatbots and workflows, built a toy agent that runs without any API key, and wrote a real tool-calling agent in Python and Node.js with a step limit for safety. Most importantly, you learned that an agent is not magic: it is an LLM in a loop, and <em>your code<\/em> stays in control of which tools exist and when to stop.<\/p>\n<p>New to LLMs? Start with <a href=\"https:\/\/devdojo.co.in\/?p=215\">Generative AI Part 1<\/a>. Ready for a framework? Try the <a href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/08\/openai-agents-sdk-python\/\">OpenAI Agents SDK tutorial<\/a>.<\/p>\n\n<div class=\"dd-next\"><strong>Next part \u2013 Agentic AI Part 2: Anatomy of an AI Agent: Models, Tools, Instructions and Memory.<\/strong> We will open up each building block: how to choose a model for agents, how to design good tools, how to write agent instructions, and how short-term and long-term memory work.<\/div>\n\n<div class=\"dd-cta\">\n<h3>New posts every day on DevDojo<\/h3>\n<p>Follow the full <strong>Agentic AI series<\/strong> \u2013 30 parts from &#8220;what is an agent&#8221; to building a multi-agent developer assistant. Bookmark <a href=\"https:\/\/devdojo.co.in\/\">devdojo.co.in<\/a> and tell us in the comments which agent you want to build first.<\/p>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.<\/p>\n","protected":false},"author":1,"featured_media":225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[119,42,44,43,52,118,120],"class_list":["post-226","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","tag-agentic-ai","tag-ai-agents","tag-llm","tag-node-js","tag-python","tag-series-agentic-ai","tag-tool-calling"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Lokendra\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DevDojo - Empowering Developers\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"What Is Agentic AI? How AI Agents Work\" \/>\n\t\t<meta property=\"og:description\" content=\"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-10-20T14:34:37+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-10-20T14:34:38+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"What Is Agentic AI? How AI Agents Work\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#blogposting\",\"name\":\"What Is Agentic AI? How AI Agents Work | DevDojo\",\"headline\":\"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?\",\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/agentic-ai-series-part-1-what-is-agentic-ai.jpg\",\"width\":1200,\"height\":630,\"caption\":\"Agentic AI Part 1 banner: an AI agent runs a think, act and observe loop with tools like search, calculator and database\"},\"datePublished\":\"2026-10-20T14:34:37+00:00\",\"dateModified\":\"2026-10-20T14:34:38+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#webpage\"},\"articleSection\":\"AI, Agentic AI, AI Agents, LLM, Node.js, Python, Series: Agentic AI, Tool Calling\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/ai\\\/#listItem\",\"name\":\"AI\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/ai\\\/#listItem\",\"position\":2,\"name\":\"AI\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/ai\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#listItem\",\"name\":\"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#listItem\",\"position\":3,\"name\":\"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/ai\\\/#listItem\",\"name\":\"AI\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/\",\"name\":\"Lokendra\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Lokendra\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#webpage\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/\",\"name\":\"What Is Agentic AI? How AI Agents Work | DevDojo\",\"description\":\"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/agentic-ai-series-part-1-what-is-agentic-ai.jpg\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#mainImage\",\"width\":1200,\"height\":630,\"caption\":\"Agentic AI Part 1 banner: an AI agent runs a think, act and observe loop with tools like search, calculator and database\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/20\\\/agentic-ai-series-part-1-what-is-agentic-ai\\\/#mainImage\"},\"datePublished\":\"2026-10-20T14:34:37+00:00\",\"dateModified\":\"2026-10-20T14:34:38+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"What Is Agentic AI? How AI Agents Work | DevDojo","description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.","canonical_url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#blogposting","name":"What Is Agentic AI? How AI Agents Work | DevDojo","headline":"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?","author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/agentic-ai-series-part-1-what-is-agentic-ai.jpg","width":1200,"height":630,"caption":"Agentic AI Part 1 banner: an AI agent runs a think, act and observe loop with tools like search, calculator and database"},"datePublished":"2026-10-20T14:34:37+00:00","dateModified":"2026-10-20T14:34:38+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#webpage"},"isPartOf":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#webpage"},"articleSection":"AI, Agentic AI, AI Agents, LLM, Node.js, Python, Series: Agentic AI, Tool Calling"},{"@type":"BreadcrumbList","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","position":1,"name":"Home","item":"https:\/\/devdojo.co.in\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/ai\/#listItem","name":"AI"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/ai\/#listItem","position":2,"name":"AI","item":"https:\/\/devdojo.co.in\/index.php\/category\/ai\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#listItem","name":"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?"},"previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#listItem","position":3,"name":"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?","previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/ai\/#listItem","name":"AI"}}]},{"@type":"Organization","@id":"https:\/\/devdojo.co.in\/#organization","name":"DevDojo","description":"Empowering Developers","url":"https:\/\/devdojo.co.in\/"},{"@type":"Person","@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author","url":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/","name":"Lokendra","image":{"@type":"ImageObject","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g","width":96,"height":96,"caption":"Lokendra"}},{"@type":"WebPage","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#webpage","url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/","name":"What Is Agentic AI? How AI Agents Work | DevDojo","description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/devdojo.co.in\/#website"},"breadcrumb":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#breadcrumblist"},"author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"creator":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/agentic-ai-series-part-1-what-is-agentic-ai.jpg","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#mainImage","width":1200,"height":630,"caption":"Agentic AI Part 1 banner: an AI agent runs a think, act and observe loop with tools like search, calculator and database"},"primaryImageOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/#mainImage"},"datePublished":"2026-10-20T14:34:37+00:00","dateModified":"2026-10-20T14:34:38+00:00"},{"@type":"WebSite","@id":"https:\/\/devdojo.co.in\/#website","url":"https:\/\/devdojo.co.in\/","name":"DevDojo","description":"Empowering Developers","inLanguage":"en-US","publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"}}]},"og:locale":"en_US","og:site_name":"DevDojo - Empowering Developers","og:type":"article","og:title":"What Is Agentic AI? How AI Agents Work","og:description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.","og:url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/","article:published_time":"2026-10-20T14:34:37+00:00","article:modified_time":"2026-10-20T14:34:38+00:00","twitter:card":"summary_large_image","twitter:title":"What Is Agentic AI? How AI Agents Work","twitter:description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly."},"aioseo_meta_data":{"post_id":"226","title":"What Is Agentic AI? How AI Agents Work | DevDojo","description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.","keywords":null,"keyphrases":{"focus":{"keyphrase":"agentic AI"},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":"What Is Agentic AI? How AI Agents Work","og_description":"Learn what agentic AI is, how AI agents work with the think-act-observe loop, and build your first tool-calling agent in Python and Node.js. Beginner friendly.","og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":0,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-10-20 14:27:43","updated":"2026-10-20 18:49:42","focus_keyword":"agentic AI","additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/index.php\/category\/ai\/\" title=\"AI\">AI<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tAgentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/devdojo.co.in\/"},{"label":"AI","link":"https:\/\/devdojo.co.in\/index.php\/category\/ai\/"},{"label":"Agentic AI Part 1: What Is Agentic AI and How Do AI Agents Work?","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/20\/agentic-ai-series-part-1-what-is-agentic-ai\/"}],"_links":{"self":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":1,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions\/227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media\/225"}],"wp:attachment":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}