सामग्री पर जाएँ
22/30अध्याय 22 / 30

AI agent क्या है: पाँच क्लासिक प्रकार, दो प्रतिस्पर्धी परिभाषाएँ

vacuum world को चार बार तोड़कर पाँच क्लासिक agent प्रकार समझें—और कैसे एक tool ने 39 token की call को 420 बना दिया।

इस पेज पर

यह वही सवाल है, उसी model से दो बार पूछा गया, समान weights और greedy decoding के साथ। फर्क सिर्फ इतना था कि दूसरी बार catalogue में एक tool था.

TEXT
no tools in the catalogue
  turn 1  prompt=  39  out=  8  finish=stop        TEXT "The capital of France is Paris."
  => model calls=1  prompt tokens=39  output=8  wall=974 ms

one tool in the catalogue: get_temperature(city)
  turn 1  prompt= 185  out= 20  finish=tool_calls  CALL get_temperature({"city": "Paris"})
          tool  get_temperature -> {"city":"Paris","celsius":11}
  turn 2  prompt= 235  out= 18  finish=stop        TEXT "The capital of France is Paris. It is
                                                        currently at 11 degrees Celsius."
  => model calls=2  prompt tokens=420  output=38  wall=6,685 ms

एक call दो बन गई। उनतालीस input token 420 बन गए, यानी 10.8 गुना। एक सेकंड से कम लगभग सात सेकंड बन गया। और जवाब में एक ऐसा तथ्य आ गया जो किसी ने पूछा ही नहीं था, उस tool से जिसे model ने ऐसे सवाल के लिए call करना चुना जिसमें मौसम का जिक्र तक नहीं था।

दूसरा system वही है जिसे 2026 में industry का अधिकांश हिस्सा agent कहता है। या वह agent नहीं है, यह इस पर निर्भर है कि आप सबसे ज्यादा पढ़ी जाने वाली दो परिभाषाओं में से कौन-सी खोलते हैं — और वे दोनों एक जैसी बात नहीं कहतीं। एक तो खुद से भी पूरी तरह सहमत नहीं है।

यह असहमति ही यह अध्याय है। यह शब्दावली का झगड़ा नहीं है: दोनों परिभाषाएँ सीमा अलग-अलग axes पर खींचती हैं, और आप कौन-सा axis चुनते हैं, उससे तय होता है कि आप क्या बनाते हैं और किसका बिल चुकाते हैं। दोनों एक पुराने taxonomy पर खड़ी हैं, और उसे कमाई का सबसे सस्ता तरीका है दुनिया का सबसे खराब agent बनाना।

विवरण दिखाएँ

इस अध्याय को पिछले अध्यायों से क्या चाहिए।

  • अध्याय 13 ने मापा था कि एक single call समय में कितना खर्च करती है; यह अध्याय उसे turns की संख्या से गुणा करता है।
  • अध्याय 15: prompt ही model की पूरी state है, क्योंकि call के बाद कुछ भी बचता नहीं।
  • अध्याय 16: input tokens बातचीत के वर्ग के साथ बढ़ते हैं।
  • अध्याय 18: tool catalogue, और वह round trip जिसमें model पूछता है और आपका code execute करता है।

यहाँ tensors नहीं हैं। यह अध्याय TypeScript है, जहाँ अध्याय 14 का language rule उसे रखता है, और इसका loop अध्याय 23 के loop का सीधा पूर्वज है।

इस field का सबसे पुराना उदाहरण दो squares, A और B, वाली दुनिया में vacuum cleaner है, जहाँ हर square या तो clean है या dirty.1 यह हर textbook में इसलिए बचा हुआ है क्योंकि यह सबसे छोटी दुनिया है जिसमें कोई agent सही या गलत हो सकता है।

percept एक pair है — मैं कहाँ हूँ, और यहाँ गंदगी है या नहीं — और actions हैं SUCK, LEFT और RIGHT। पूरा program एक line है।

reflex.tsTS
type Percept = { dirty: boolean; where?: "A" | "B" };
type Action = "SUCK" | "LEFT" | "RIGHT";

const textbook = (p: Percept): Action =>
  p.dirty ? "SUCK" : p.where === "A" ? "RIGHT" : "LEFT";   

इसे दो-square दुनिया की हर starting configuration के against चलाइए:

TEXT
A dirty, B dirty, start A    -> steps=3 clean=true
A clean, B dirty, start A    -> steps=2 clean=true
A dirty, B clean, start B    -> steps=2 clean=true

यह एक simple reflex agent है: यह केवल current percept पर act करता है, उससे पहले की किसी चीज़ की memory नहीं रखता। यह toy category नहीं है — thermostat ऐसा ही है, और बिना conversation attached language model की single call भी ऐसी ही है।

अब इसे वैसे तोड़िए जैसे reality तोड़ती है। असली vacuum robot के पास dirt sensor और bumper होता है, carpet के नीचे A labelled square नहीं। percept से location निकाल दीजिए और बाकी कुछ न बदलिए:

reflex.tsTS
const dirtOnly = (p: Percept): Action => (p.dirty ? "SUCK" : "RIGHT");
TEXT
A dirty, B dirty, start A    -> steps=3   clean=true   still dirty=0
      t=0 at=A percept={dirty:true}  -> SUCK
      t=1 at=A percept={dirty:false} -> RIGHT
      t=2 at=B percept={dirty:true}  -> SUCK

A dirty, B clean, start B    -> steps=500 clean=false  still dirty=1
      t=0 at=B percept={dirty:false} -> RIGHT
      t=1 at=B percept={dirty:false} -> RIGHT
      t=2 at=B percept={dirty:false} -> RIGHT
      t=3 at=B percept={dirty:false} -> RIGHT

वही program, दो squares। एक starting state से यह तीन steps में finish करता है; दूसरी से यह right-hand wall में पाँच सौ बार जा टकराता है और battery खत्म होने तक चलता रहता। यह दोनों स्थितियों के बीच फर्क perceive नहीं कर सकता, इसलिए उनमें अलग-अलग act नहीं कर सकता। Russell और Norvig सामान्य परिणाम एक line में बताते हैं: partially observable environments में simple reflex agents के लिए infinite loops अक्सर unavoidable होते हैं.1

एक fix है जिसकी कीमत एक line और zero memory है, और किसी clever चीज़ तक पहुँचने से पहले उसे मापना चाहिए।

reflex.tsTS
let seed = 12345;
const rnd = () => ((seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff);

const coin = (p: Percept): Action => (p.dirty ? "SUCK" : rnd() < 0.5 ? "LEFT" : "RIGHT");  

तीन sizes पर all-dirty corridor के दो हजार runs, पूरे समय एक seeded generator:

roomsmean stepsmedianworst of 2,000never finished
24.04130
416.614810
868.7523060

Randomisation loop को पूरी तरह हटा देता है। इसकी लागत भी है: अगर आपको पता हो कि क्या कर रहे हैं तो आठ rooms को पंद्रह moves चाहिए, और यह agent औसतन 68.7 लेता है और एक बार 306 तक गया। यही पूरा अध्याय miniature में है। हर capability जो हम जोड़ते हैं, उस case में correctness खरीदती है जिसे पिछला agent संभाल नहीं सकता था, और उसका charge ऐसी currency में करती है जिसका नाम आपको पहले रखना पड़ता है।

अब parts के नाम, क्योंकि अब उनकी जरूरत है

सेक्शन का लिंक: अब parts के नाम, क्योंकि अब उनकी जरूरत है

एक agent अपने environment को sensors के जरिए perceive करता है और actuators के जरिए act करता है। agent program percepts से actions तक का function है — ऊपर की हर listing वही है। percept sequence अब तक perceive की गई हर चीज़ है, और simple reflex agent last item को छोड़कर बाकी सब ignore करता है।

Rationality वह शब्द है जिसे ज्यादातर articles गलत समझते हैं, और इसे सही समझना इस अध्याय के बाकी हिस्से को उपयोगी बनाता है। कोई agent अपने आप में rational या irrational नहीं होता। Russell और Norvig rational agent को ऐसे agent के रूप में define करते हैं जो हर possible percept sequence के लिए वह action चुनता है जिससे उसके performance measure को maximise करने की expected संभावना हो, उस sequence के evidence और उसमें जो भी built-in knowledge हो उसके आधार पर.1 performance measure agent के अंदर नहीं होता: यह designer का होता है, और rationality सिर्फ उसके relative define होती है।

Specification conventionally चार चीज़ों के रूप में लिखी जाती है, PEAS: performance measure, environment, actuators, sensors।

vacuum robotproduction में support agent
Performance measuresquares clean, battery की प्रति unittickets resolved, प्रति dollar, escalation के बिना
Environmentfloor, dirt, furniture, carpetticket queue, आपका database, customer
Actuatorswheels, suctiontool calls
Sensorsdirt sensor, bumperuser का message, tool results

ध्यान दीजिए कौन-सी row अलग है। 2026 में agents बनाने वाली लगभग हर team E, A और S लिखती है — tool schemas, integrations, message format — क्योंकि इनके बिना code चलेगा नहीं। लगभग कोई P नहीं लिखता। इसके बिना “our agent is doing well” का कोई अर्थ नहीं जिसे कोई check कर सके, और “rational” system पर लागू ही नहीं किया जा सकता, केवल demonstration पर। अध्याय 29 P को number में बदलने के बारे में है, और इसी वजह से वह मौजूद है।

TEXT
    ┌───────────────────────── the environment ─────────────────────────┐
    │                                                                   │
    │   ┌──────────────────────── the agent ─────────────────────┐      │
    │   │                                                        │      │
 ───┼──►│  sensors  ──►  the agent program  ──►  actuators  ─────┼──────┼──►
percept │                                                        │    action
    │   └────────────────────────────────────────────────────────┘      │
    └───────────────────────────────────────────────────────────────────┘

              the performance measure lives out here, in the head of
              whoever built the thing, and the agent cannot change it

Task environments को आगे सात axes पर classify किया जाता है, जिनमें से पाँच यहाँ की difficulty का अधिकतर हिस्सा तय करते हैं: fully या partially observable, deterministic या नहीं, episodic या sequential, static या dynamic, known या unknown.1 real network पर real tools से बात करने वाला agent इन पाँचों के hard corner में होता है — temperature zero पर भी non-deterministic (अध्याय 17), और जो underestimated है, unknown, क्योंकि आपके पास अपनी ही tools दुनिया के साथ क्या करती हैं इसका कोई reliable model नहीं होता। इसलिए अध्याय 23 के loop को planning से ज्यादा error handling चाहिए।

Real floors one-dimensional नहीं होते, इसलिए दुनिया को plan में promote करें। Hash marks walls हैं, asterisks dirt हैं, और robot middle chamber से शुरू करता है:

TEXT
        col  0 1 2 3 4 5 6
      row 0  * . . # . . *
      row 1  . # . # . # .
      row 2  . # . S . # .        S = the robot starts here
      row 3  . # . # . # .
      row 4  * . . # . . *

सबसे obvious upgrade memory है। agent map रखता है: हर square जहाँ वह खड़ा हुआ और हर square जहाँ bumper चला। इसका rule है किसी ऐसे adjacent square में जाना जिसे उसने visit नहीं किया — right, फिर down, फिर left, फिर up — और जब आसपास सब known हो जाए तो back off करना। यह model-based reflex agent है: यह percept history से internal state maintain करता है, इसलिए जो अभी दिखाई नहीं दे रहा उस पर भी act कर सकता है।

यह real improvement है, और फिर भी enough नहीं:

TEXT
5,000 steps allowed -> steps=5,000  distinct squares visited=13/25  still dirty=2/4

पाँच हजार moves, floor का आधा हिस्सा कभी देखा ही नहीं। map सही है और rules सही हैं। agent जो नहीं कर सकता, वह है map का इस्तेमाल करके कहीं जाना: उसके rules हमेशा केवल “मेरे चार neighbours में से किसमें कदम रखूँ” का जवाब देते हैं, इसलिए जब उसके पास adjacent unvisited squares खत्म हो जाते हैं, तो उसके पास यह thought express करने का कोई तरीका नहीं रहता कि आठ moves दूर एक unvisited square है और मैं वहाँ खड़ा होना चाहूँगा। उसे पता है कि वह कहाँ है। उसे यह नहीं पता कि वह कहाँ होना चाहता है।

एक goal, और फिर एक route को दूसरे पर prefer करने की वजह

सेक्शन का लिंक: एक goal, और फिर एक route को दूसरे पर prefer करने की वजह

goal-based agent world के अपने model के ऊपर उस situation का description रखता है जिसे वह लाना चाहता है, और actions चुनने के लिए उनके sequences पर search करता है जब तक कोई sequence वहाँ end न हो जाए। Goals action selection को lookup से search में बदल देते हैं।

Goal है “no dirty square remains”। Search nearest dirty square तक breadth-first walk है, और जो path लौटता है वही plan है।

TEXT
goal-based (fewest moves)      -> moves=27  battery=52  still dirty=0
      from 2,3 -> 4,6 via 5 moves:  2,3 2,4 3,4 4,4 4,5 4,6
      from 4,6 -> 0,6 via 4 moves:  4,6 3,6 2,6 1,6 0,6
      from 0,6 -> 4,0 via 10 moves: 0,6 0,5 0,4 1,4 2,4 2,3 2,2 3,2 4,2 4,1 4,0
      from 4,0 -> 0,0 via 4 moves:  4,0 3,0 2,0 1,0 0,0

सत्ताईस moves, floor clean। लेकिन battery column और plan की last leg देखें। Column 0 carpeted है: carpeted square cross करने की कीमत battery की छह units है, tiled square की एक। agent column 0 से home गया क्योंकि वह आठ के बजाय चार moves हैं, और उन चार carpeted moves की कीमत 24 थी, जबकि आठ-move detour की 13 होती।

यह otherwise कर ही नहीं सकता। Goal एक binary test है: floor clean है या नहीं। clean floor पर end होने वाला हर plan उसे समान रूप से satisfy करता है, इसलिए जब कई plans सफल हों तो agent के पास उनके बीच choose करने के लिए कुछ नहीं होता। एक success को दूसरे पर prefer करने के लिए outcomes पर एक number चाहिए, और वह number utility function है। जो agent उसे maximise करता है वह utility-based agent है।

Code में change search के अंदर एक term है। Breadth-first search moves गिनती है; उससे cost गिनवाइए और आपके पास Dijkstra का algorithm और एक अलग agent है:

search.tsTS
const nd = dist.get(k)! + (byCost ? cell.cost : 1);   // <- the entire difference
TEXT
goal-based    (fewest moves)   -> moves=27  battery=52  still dirty=0
utility-based (cheapest route) -> moves=31  battery=41  still dirty=0
      from 4,0 -> 0,0 via 8 moves: 4,0 4,1 4,2 3,2 2,2 1,2 0,2 0,1 0,0

चार extra moves, battery की ग्यारह units कम: इक्कीस प्रतिशत cheaper। Same goal, same map, same code लेकिन एक term अलग। दोनों agents केवल इस बात में अलग हैं कि वे किस चीज़ में अच्छा होना चाहते हैं, और वे home लौटने के लिए अलग routes लेते हैं।

यह पहला point भी है जहाँ agent को ऐसी चीज़ चाहिए जो वह खुद produce नहीं कर सकता। किसी को तय करना पड़ता है कि एक move के relative battery की unit कितनी worth रखती है। Utility performance measure है जिसे ऐसे रूप में लिखा गया है जिससे agent compute कर सके, और उसे लिखना designer का काम है। जब लोग कहते हैं कि agent ने “wrong thing optimise” किया, तो उनका मतलब लगभग कभी bug नहीं होता। उनका मतलब होता है कि यह line careless लिखी गई थी।

पाँचवाँ type, और उसके गलत होने का तरीका

सेक्शन का लिंक: पाँचवाँ type, और उसके गलत होने का तरीका

अब dirt को वापस आने दें। चार rooms चार अलग-अलग rates पर फिर से dirty होते हैं, और agent को वे कभी नहीं बताए जाते। वह प्रति tick एक room visit करता है और केवल वही room देखता है। performance measure है 4,000 ticks में dirty बिताए गए room-ticks — कम बेहतर है।

Textbook decomposition में learning agent ऊपर के किसी भी agent में तीन parts जोड़ता है: एक learning element जो agent को बदलता है, एक critic जो बताता है कि fixed performance standard के against agent कैसा कर रहा है, और एक problem generator जो ऐसे actions propose करता है जिन्हें try करना सीखने के लिहाज से worth हो.1 उसी environment में तीन policies। पहली नहीं सीखती; दूसरी और तीसरी वही चीज़ सीखती हैं और उसे अलग तरह से use करती हैं।

policydirty-room-ticks over 4,000versus the patrol
fixed round-robin patrol, no learning2,290
learner A: हर room की dirt rate estimate करो, फिर जहाँ dirt सबसे likely हो वहाँ जाओ11,8205.2× worse
learner B: वही estimates, last visit के बाद कितना समय हुआ उससे weighted1,57631 % better

Hidden rates kitchen के लिए 0.35, hall के लिए 0.05, study के लिए 0.02 और attic के लिए 0.01 थीं — और learner A ने उन्हें find कर लिया। उसने kitchen को house का dirtiest room सही identify किया, फिर simulation के बाकी हर tick kitchen जाता रहा जबकि बाकी तीन हमेशा dirty बैठे रहे। यह बिल्कुल न सीखने से पाँच गुना worse है, और यह broken नहीं है।

Lesson utility section वाला ही है। Learner A ने “probability that the room I am about to visit is dirty” को maximise किया। performance measure था “room-ticks spent dirty”। अलग numbers; दूसरा वही है जिसे critic score कर रहा था, और किसी ने agent को बताया नहीं। Learner B वही learned rate last visit के बाद के time से multiply करता है — किसी dirt को find करने की chance के बजाय वह dirt जिसे वह find करने की expect करता है — और उस patrol को beat कर देता है जिससे उसने शुरुआत की थी।

एक implementation detail ने result तय किया। learner B के first version में, जिस room में तीन visits में कोई dirt नहीं मिली उसकी rate exactly zero हो गई — और zero times anything zero होता है, इसलिए वह फिर कभी visit नहीं हुआ और estimate कभी correct नहीं हो सका। fraction को smooth करना, successes plus one over trials plus two, 11,895 को 1,576 में बदल गया। “Not observed yet” और “measured and came out zero” अलग claims हैं, और जो system उन्हें same field में store करता है वह ऐसे decisions लेता है जिन्हें undo नहीं कर सकता।

TEXT
  1  simple reflex    percept ────────────────────────────────► rules ────► action
  2  model-based      percept ──► [state] ──────────────────► rules ────► action
  3  goal-based       percept ──► [state] ──► [goal] ──────► search ───► action
  4  utility-based    percept ──► [state] ──► [goal] ──► [U] ──► argmax ► action
  5  learning         all of the above, plus [critic] ──► changes the parts above

इन पाँचों में से हर एक आज production में किसी और नाम से मौजूद है।

classic typepercepts के बीच क्या carry करता है2026 में उसका रूपक्या नहीं कर सकता
simple reflexकुछ नहींबिना history वाली एक model call: classifier, extraction endpoint, single-turn completionजो भी previous turn पर depend करता है
model-based reflexpercept history से बनी internal statechat: transcript, हर call पर पूरा re-sentconversation कहाँ end होनी चाहिए यह choose करना
goal-basedstate plus wanted situation का descriptionstopping condition वाला reason-and-act loop2एक successful plan को दूसरे पर prefer करना
utility-basedstate, goal, और outcomes पर एक numberevaluator–optimiser loops, और लिखे criterion से candidate answers rank करना (अध्याय 25)criterion invent करना
learningयह सब, plus critic और problem generatorReflexion, जो weights update करने के बजाय अपने lessons episodic buffer में लिखता है;3 persistent user memory (अध्याय 24)critic किस standard के against score करे यह choose करना

दो rows analogy से भी ज्यादा close हैं, और इसका पैसा लगता है।

chat एक model-based reflex agent है जिसका model internal नहीं है। Textbook में state agent program के अंदर variable होती है। chat में यह transcript है: यह आपकी side पर रहता है, हर call पर पूरा re-sent होता है, और model के अंदर हर बार scratch से rebuild होता है। यही अध्याय 16 का quadratic bill है, और वही object है जिसे textbook ने “state” labelled box के रूप में draw किया था। यहाँ फर्क है, एक follow-up question पर, उससे पहले के दो messages के साथ और बिना मापा गया:

TEXT
with the transcript      prompt=67  "The current temperature in Lisbon, Portugal is 15°C."
without the transcript   prompt=29  "Lisbon is the capital of Portugal, not a city in Portugal."

Same model, user input के वही तीन words, और दूसरा वाला corridor robot है जो wall में drive कर रहा है। उस run में tools नहीं थे, इसलिए 15 invented है — लेकिन state ही follow-up को कोई meaning देती है। आप इसे हर बार rebuild करते हैं और दो-turn conversation पर इसके लिए 2.3× input tokens pay करते हैं। अध्याय 16 ने मापा था कि turn forty तक यह multiplier कहाँ पहुँचता है।

Reflexion एक learning agent है जो अपना program नहीं, input बदलता है। Textbook decomposition में learning element performance element को modify करता है। Reflexion weights को छोड़ देता है और episodic buffer में reflective text लिखता है जिसे next attempt पढ़ता है.3 learning element prompt है, memory database row है, performance element frozen model है — और diagram textbook का ही है, unchanged।

और mapping की honest limit यह है। पाँच types agent program को classify करते हैं। 2026 में वह program बीच से split है: कुछ आपके code में है, कुछ उन weights के अंदर जिन्हें आपने train नहीं किया। जब कोई model अपने आप tool call करने का decision लेता है, goal test आपके program में है या model में? Taxonomy के पास जवाब नहीं है, क्योंकि जब वह लिखी गई थी तो उसके होने की कोई और जगह थी ही नहीं — और यही सवाल वह जगह है जहाँ दो modern definitions अलग हो जाती हैं।

Definitions behaviour के बारे में arguments हैं, और सामने trace हो तो उन्हें judge करना कहीं आसान है।

नीचे वाला loop conversation को model को भेजता है; अगर reply में tool call हो तो वह tool execute करता है, result append करता है और पूरी चीज़ फिर भेजता है। यह इस machine पर OpenAI-shaped endpoint के पीछे local Qwen2.5-0.5B-Instruct के against चलता है — अध्याय 14 वाला seam, इसलिए loop को यह पता भी नहीं और परवाह भी नहीं कि port के पीछे क्या है।

loop.tsTS
const BASE = process.env.LLM_BASE_URL ?? "http://127.0.0.1:8799/v1";

async function loop(question: string, maxTurns = 6) {
  const messages: Msg[] = [
    { role: "system", content: SYSTEM },
    { role: "user", content: question },
  ];

  for (let turn = 1; turn <= maxTurns; turn++) {
    const reply = await call(messages, TOOLS);
    const calls = reply.choices[0].message.tool_calls ?? [];
    messages.push(reply.choices[0].message);

    if (!calls.length) return messages;                      

    for (const c of calls) {
      const out = runTool(c.function.name, JSON.parse(c.function.arguments));
      messages.push({ role: "tool", name: c.function.name, content: out });
    }
  }
  throw new Error("turn cap reached");                       
}

दो lines पूरा idea carry करती हैं, और दोनों marked हैं; बाकी bookkeeping है। एक run में तीनों behaviours दिखते हैं। कुछ ऐसा पूछा जाए जो यह खुद कर सकता है, तो model answers। कुछ ऐसा पूछा जाए जो यह नहीं कर सकता, तो यह calls:

TEXT
=== a question the model cannot answer, one tool available
  turn 1  prompt= 187  out= 21  finish=tool_calls  CALL get_temperature({"city": "Oslo"})
          tool  get_temperature -> {"city":"Oslo","celsius":4}
  turn 2  prompt= 238  out= 12  finish=stop        TEXT "The current temperature in Oslo is 4
                                                        degrees Celsius."
  => model calls=2  prompt tokens=425  output=33  wall=6,257 ms
  => stopped by: the model produced text instead of a call

और यह stops — तीसरा behaviour, और miss करना सबसे आसान, क्योंकि यह ऐसा दिखता है जैसे कुछ नहीं हो रहा। loop इसलिए end होता है क्योंकि turn 2 बिना tool call के वापस आया। यह किसी ने decide नहीं किया; model ने prose emit करके किया। इस program की termination condition absence का sign है।

दो और runs जगह के लायक हैं। दो cities compare करने को कहने पर model एक turn में दोनों tool calls issue करता है, दोनों readings वापस पाता है, और comparison गलत कर देता है:

TEXT
  turn 1  prompt= 188  out= 43  finish=tool_calls  CALL get_temperature({"city": "Oslo"}),
                                                        get_temperature({"city": "Lisbon"})
          tool  get_temperature -> {"city":"Oslo","celsius":4}
          tool  get_temperature -> {"city":"Lisbon","celsius":19}
  turn 2  prompt= 284  out= 13  finish=stop        TEXT "Oslo is currently warmer than Lisbon
                                                        at 4°C."

Tools ने काम किया। parallel call ने काम किया। loop ने काम किया। answer false है, जबकि दोनों correct numbers transcript में बैठे हैं। model को loop में wrap करना उसे reason करने वाला नहीं बनाता; यह गलत model को अपनी गलती पर act करने की ability देता है — जो आगे से अध्याय 30 है, और अध्याय 29 का आधा हिस्सा।

अब marked return delete करें और loop को cap तक run करने दें। Same question, same model:

TEXT
  turn 1  prompt= 187  out= 21  CALL get_temperature({"city": "Oslo"})
  turn 2  prompt= 238  out= 12  TEXT "The current temperature in Oslo is 4 degrees Celsius."
  turn 3  prompt= 261  out= 30  TEXT "Could you please specify the exact location you're..."
  turn 4  prompt= 302  out= 14  TEXT "Sure! Could you tell me which city you're interested in?"
  turn 5  prompt= 327  out= 35  TEXT "I'm sorry, but I need more details to provide an..."
  turn 6  prompt= 373  out= 12  TEXT "Which city would you like to know the temperature for?"
  => model calls=6  prompt tokens=1,688  output=124  wall=25,261 ms  stopped by: turn cap

चार गुना input tokens, चार गुना wall clock, और ऐसा ending जिसमें agent भूल चुका है कि उससे क्या पूछा गया था और user से उस सवाल के बारे में पूछताछ कर रहा है जिसका जवाब वे turn one पर दे चुके थे। सही जवाब turn 2 पर screen पर था, और उसके बाद हर turn ने transcript को worse बनाया।

तो agent loop नहीं है। यह loop plus उसे छोड़ने का rule है, और इस वाले के पास ऐसा exactly एक rule है। अध्याय 23 पाँच खोजता है, और दिखाता है कि हर एक missing होने पर क्या टूटता है।

दोनों को paraphrase करने के बजाय quote किया गया है, क्योंकि confusion paraphrases में manufacture होती है।

Definition one boundary वहाँ रखती है जहाँ flow को कौन control करता है। Anthropic का Building effective agents ambiguity को name करता है और उस पर rule देता है:

“At Anthropic, we categorize all these variations as agentic systems, but draw an important architectural distinction between workflows and agents: Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.”4

Test आपके source code के बारे में सवाल है: next step किसने चुना? आपके program में switch: workflow। model: agent। वही document कहता है कि agents “are typically just LLMs using tools based on environmental feedback in a loop” — जो ऊपर की listing exactly है।

Definition two boundary user से independence पर रखती है। OpenAI का A practical guide to building agents अपनी definitional page ऐसे खोलता है:

“While conventional software enables users to streamline and automate workflows, agents are able to perform the same workflows on the users’ behalf with a high degree of independence. Agents are systems that independently accomplish tasks on your behalf.”5

दो sentences बाद, उसी page पर, यह exclude करता है:

“Applications that integrate LLMs but don’t use them to control workflow execution—think simple chatbots, single-turn LLMs, or sentiment classifiers—are not agents.”5

इन quotations को order में पढ़िए। Opening sentences line independence पर खींचते हैं: क्या यह चीज़ मेरे बिना जाकर job finish करती है? चौथा sentence इसे control of execution पर खींचता है, जो exactly Anthropic की line है। अलग tests, same page, और real systems हैं जिन पर वे disagree करते हैं।

नीचे vocabulary collision है, और यह real meetings में arguments कराता है। पहले document में workflow architecture है, और वही चीज़ है जो agent नहीं है। दूसरे में workflow “a sequence of steps that must be executed to meet the user’s goal” है — यानी job itself, जो हर agent के पास होती है। “We replaced the workflow with an agent” पहली definition के तहत coherent है और दूसरी के तहत लगभग meaningless।

2026 में मौजूद तीन systems, दोनों definitions के तहत।

आप task describe करते हैं; यह files पढ़ता है, test suite चलाता है, edit करता है, फिर से tests चलाता है, और जब वे pass हों या जब यह give up करे तब stop करता है। आपके code में कुछ भी यह decide नहीं करता कि next step “run the tests” है — model करता है, last tool ने क्या लौटाया उससे।

Definition one: agent, क्योंकि model अपना process खुद direct करता है। Definition two: agent, क्योंकि यह task independently accomplish करता है, completion पहचानता है और control वापस देता है। दोनों documents इस shape को अपना central example cite करते हैं।

हर new support ticket के लिए fixed order में तीन model calls — classify, fields extract करना, reply draft करना — और फिर यह send करता है। कोई model कभी next क्या होगा नहीं चुनता; for loop करता है। यह 03:00 पर चलता है और कोई watch नहीं करता।

Definition one: not an agent. यह prompt chaining है, जिसे नाम से workflow के रूप में list किया गया है। Definition two: दोनों answers. Opening sentences के हिसाब से यह आपकी behalf पर independently tasks accomplish करता है; चौथे के हिसाब से यह workflow execution control करने के लिए model use नहीं करता, और excluded है। यही system वजह है कि आपको pull quote के बजाय पूरा page पढ़ना चाहिए।

एक user turn। model खुद decide करता है कि answer करने से पहले search करना है या नहीं, फिर answer करता है और आपका wait करता है।

Definition one: agent, क्योंकि model environment से results पर अपनी tool usage dynamically direct करता है, जो stated test है। Definition two: not an agent, क्योंकि independence नहीं है — एक turn, फिर यह hand back करता है — और “simple chatbots” exclusion list में नाम से हैं।

तीनों में से दो sides बदलते हैं। यह किसी document की failure नहीं है। यह उस तरह की meeting के बारे में warning है जिसमें दो लोग इस बात पर पूरी तरह सहमत होते हैं कि system क्या करता है, और एक घंटा इस पर असहमत रहते हैं कि उसे क्या कहा जाए।

बाहर निकलने का रास्ता दो axes हैं, एक नहीं

सेक्शन का लिंक: बाहर निकलने का रास्ता दो axes हैं, एक नहीं

Definitions collide करती हैं क्योंकि हर एक दो independent questions को एक word में collapse करती है। उन्हें अलग कर दें और disagreement एक table बन जाता है, जो verdict से ज्यादा useful है।

आपका code next step चुनता हैmodel next step चुनता है
हर turn कोई व्यक्ति watch कर रहा हैअंदर model वाला form: classifiers, extraction, single-turn completiontools वाला chat — definition one कहती है agent, definition two कहती है नहीं
done होने तक कोई watch नहीं कर रहाpipeline — definition two की opening कहती है agent, चौथा sentence कहता है नहींसब सहमत: agent

हर definition एक अलग cell dispute करती है, और बाकी दो dispute में हैं ही नहीं। इसलिए जब label matter करता है — contract में, risk review में, postmortem में — लिखने लायक दो sentences “is it an agent” नहीं बल्कि next step किसने चुना और कौन watch कर रहा था हैं। दोनों का जवाब code पढ़कर दिया जा सकता है, किसी की definition की जरूरत नहीं, और साथ मिलकर वे हर consequence carry करते हैं जिसके लिए label खड़ा था।

यह कुछ नया नहीं है। Wooldridge और Jennings ने 1995 में “agent” के competing senses survey किए;6 Franklin और Graesser ने 1996 में इस अध्याय का सवाल पूछा, circulation में definitions इकट्ठी कीं और पाया कि वे disagree करती थीं.7 2023 का survey अभी भी agents को first principles से define करता है — “artificial entities that sense their environment, make decisions, and take actions”8 — क्योंकि cite करने के लिए settled कुछ था ही नहीं, और CoALA boundary खींचने के बजाय parts describe करता है.9 तीस साल तक agree करने से इनकार करना बताता है कि यह word एक से ज्यादा jobs कर रहा है।

अब वह consequence जो philosophy से पहले आता है, यानी bill।

यहाँ हर measurement का shape एक जैसा है। single call की कीमत 39 input tokens थी; वही question one tool के साथ two calls में 420 cost हुआ; stopping rule हटे loop ने six calls में 1,688 cost किया। Growth linear से worse है, क्योंकि turn n अपने साथ हर previous turn carry करता है: उस six-turn run का prompt column 187, 238, 261, 302, 327, 373 पढ़ता है। अध्याय 16 ने derive किया था कि total Θ(n2)\Theta(n^2) है और real conversation पर curve fit किया था। agent हर task को उस conversation में बदल देता है, चाहे कोई human उसे कभी देखे या नहीं।

अगर ये measured token counts किसी commercial endpoint पर उन rates पर गए होते जिन्हें अध्याय 16 ने 6 September 2026 को पढ़ा था — $2.00 प्रति million input tokens और $12.00 प्रति million output — तो चार runs की कीमत ऐसी होती:

runmodel callsinput tokensoutput tokenscost
question, no tools1398$0.000174
वही question, catalogue में one tool242038$0.001296
ऐसा question जिसे tool चाहिए242533$0.001246
वही, stopping rule हटाकर61,688124$0.004864

Row two बनाम row one वह number है जिसे याद रखना चाहिए। साढ़े सात गुना cost, ऐसे question के worse answer के लिए जिसे model पहले से जानता था। कुछ misconfigured नहीं था: एक tool मौजूद था, इसलिए model ने उसका इस्तेमाल किया — और अध्याय 18 की finding, कि catalogue की कीमत hurt करती है, उसकी accuracy नहीं, यहाँ one-item catalogue के साथ अपनी सबसे सस्ती demonstration पाती है।

इसीलिए दोनों documents का useful आधा हिस्सा वह है जो इसे न बनाने के बारे में है। Anthropic blunt है: सबसे simple possible solution खोजो और complexity केवल जब needed हो तब add करो, जिसका मतलब “might mean not building agentic systems at all” हो सकता है, क्योंकि agentic systems “trade latency and cost for better task performance” करते हैं और “for many applications, optimizing single LLM calls with retrieval and in-context examples is usually enough”.4 Agent के पक्ष में उसका case narrow है: open-ended problems जहाँ आप steps की संख्या predict नहीं कर सकते और path hardcode नहीं कर सकते, ऐसे environment में जिस पर आप trust करते हैं, “higher costs, and the potential for compounding errors” accept करते हुए.4 OpenAI की screen mirror image है — complex judgement, unmaintainable rule sets, unstructured data — और उसी तरह end होती है: “otherwise, a deterministic solution may suffice”.5

तो, इस अध्याय की taxonomy में: fixed order में fixed number of steps pipeline है, और उसे agent कहने से वह faster नहीं होगी। अगर steps की संख्या इस पर depend करती है कि रास्ते में क्या मिलता है, तो आपको loop चाहिए — और आप वह flexibility N calls, quadratic transcript, और ऐसे system से खरीदते हैं जो once के बजाय N times गलत हो सकता है।

अब आपके पास taxonomy है, दोनों modern definitions हैं, वे दो axes हैं जो उन्हें compatible बनाते हैं, और एक short loop है जो answers, calls और stops करता है।

उस loop के पास end होने का एक तरीका है: model tools माँगना बंद कर देता है। अध्याय 23 इसे जान-बूझकर सात बार तोड़ता है, और हर break एक piece जोड़ता है। Impossible task, और यह कभी end नहीं होता — turn cap। पूरी रात running, और bill आ जाता है — dollars में budget। Tool fail होता है — error जिस पर model act कर सके। Same call twice — idempotency key। ऐसी file जिसे touch नहीं करना चाहिए था — human approval। halfway restart — session persistence। ऐसा tool जिसे silence में तीन minutes लगते हैं — progress और cancellation। जो निकलता है वह harness है, वह file जिस पर इस course का बाकी हिस्सा चलता है।

इससे वह सवाल बचता है जिसके बारे में इस अध्याय का disputed diagonal सच में था। अपना next step खुद decide करने वाले loop को decide करना पड़ता है कि कब stop करना है, और हमने अभी देखा कि जब वह नहीं कर पाता तो क्या होता है: six turns, चार गुना bill, और एक agent जो user से ऐसे question पर पूछताछ कर रहा है जिसका जवाब वह पहले ही दे चुका था। Stopping एक condition नहीं है। कितनी हैं, और कौन-सी पहले fire होती है?


Lilian Weng का LLM Powered Autonomous Agents (2023) language agent को planning, memory और tool use में decompose करने का best-known तरीका है, और दो vendor documents के साथ सही next read है; इसके three components इस course के अध्याय 23, 24 और 18 हैं, इसी order में।

इस अध्याय का हर number इसी machine पर produce हुआ और कुछ भी estimate नहीं किया गया। Corridor, floor plan, उस पर चलने वाले four agents और three patrol policies ऊपर का TypeScript हैं, Node 22 पर run; randomised agent के figures प्रत्येक 2,000 seeded runs के means हैं और patrol figures 4,000 ticks के single seeded runs हैं। Model traces float32 में CPU पर greedy decoding के साथ Qwen2.5-0.5B-Instruct से आते हैं, loopback पर एक small local Python endpoint द्वारा serve किए गए, जो weights load करता है और OpenAI chat-completions shape बोलता है — वही seam फिर, tensors Python side पर और loop TypeScript side पर — इसलिए token counts उस model का tokenizer हैं और latencies उस machine की हैं। कहीं और से लिए गए केवल figures cost table की दो prices हैं, जो अध्याय 16 ने 6 September 2026 को OpenAI की pricing page से पढ़ी थीं, यहाँ locally measured token counts पर illustration के रूप में apply की गईं, observed invoice के रूप में नहीं।

  1. Russell, S. और Norvig, P. Artificial Intelligence: A Modern Approach, 4th edition, chapter 2, Intelligent Agents. vacuum world, PEAS specification, performance measure के relative rationality की definition, task environments की seven properties, यहाँ use किए गए पाँच agent types, और यह observation कि partially observable environments में simple reflex agents के लिए infinite loops अक्सर unavoidable होते हैं — इन सबका source। Book का companion code GitHub पर aimacode/aima-python है (8,806 stars, last pushed 30 June 2026, read 7 September 2026) — इसे precisely नाम देना worth है कि यह क्या है। यह book का accompanying repository है, कोई reference implementation नहीं जिस पर other projects वैसे build करते हों जैसे karpathy/micrograd (17,412) और karpathy/nanoGPT (62,852) हैं। इसलिए यह अध्याय इसे cite और link करता है, translate नहीं, और इसलिए ecosystem argument जिसने अध्याय 5 को Python में रखा था, यहाँ लागू नहीं होता: इस अध्याय में कुछ भी tensor को touch नहीं करता, और ऊपर लिखा loop अध्याय 23 का direct ancestor है। 2 3 4 5

  2. Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K. और Cao, Y. ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629 (2022). reasoning traces और actions की interleaving, जिसे mapping table की goal-based row refer करती है।

  3. Shinn, N., Cassano, F., Berman, E., Gopinath, A., Narasimhan, K. और Yao, S. Reflexion: Language Agents with Verbal Reinforcement Learning. arXiv:2303.11366 (2023). Mechanism की paper की अपनी summary ही कारण है कि यह learning agent पर map होता है: यह agents को “not by updating weights, but instead through linguistic feedback” reinforce करता है, ऐसे agents के साथ जो “verbally reflect on task feedback signals, then maintain their own reflective text in an episodic memory buffer to induce better decision-making in subsequent trials”। 2

  4. Anthropic, Building effective agents, 19 December 2024, anthropic.com/engineering/building-effective-agents, read 7 September 2026. ऊपर quote किए गए workflow/agent distinction, umbrella term “agentic systems”, agents को “typically just LLMs using tools based on environmental feedback in a loop” बताने, simplest possible solution खोजने की guidance और यह कि इसका मतलब “might mean not building agentic systems at all” हो सकता है, और agents के पक्ष और विपक्ष के case — जिनमें “higher costs, and the potential for compounding errors” और control बनाए रखने के लिए “such as a maximum number of iterations” जैसी stopping conditions की recommendation शामिल है — का source। 2 3

  5. OpenAI, A practical guide to building agents, pages 4 to 7, read 7 September 2026. “Agents are systems that independently accomplish tasks on your behalf”, “simple chatbots, single-turn LLMs, or sentiment classifiers” के exclusion, workflow की definition “a sequence of steps that must be executed to meet the user’s goal”, agent की two core characteristics, three components — model, tools, instructions — और one build कब करना है इसकी screening criteria, जो “otherwise, a deterministic solution may suffice” पर end होती है, इन सबका source। 2 3

  6. Wooldridge, M. और Jennings, N. R. Intelligent Agents: Theory and Practice. The Knowledge Engineering Review, volume 10, issue 2 (1995). वह survey जिसने field के usage को agency की weak notion — autonomy, social ability, reactivity, pro-activeness — और mental vocabulary borrow करने वाली stronger notions में split किया। आज पढ़ने पर यह उसी argument का record है जो इस अध्याय के दो documents अभी भी कर रहे हैं।

  7. Franklin, S. और Graesser, A. Is It an Agent, or Just a Program? A Taxonomy for Autonomous Agents. Proceedings of the Third International Workshop on Agent Theories, Architectures, and Languages, Springer (1996). यहाँ quotation के लिए नहीं बल्कि यह क्या है उसके लिए cited: एक survey जिसने तब circulation में “agent” की definitions इकट्ठी कीं, पाया कि वे disagree करती हैं, और argument replace करने के लिए taxonomy propose की। तीस साल बाद argument बेहतर-designed documentation में है और otherwise unchanged है।

  8. Xi, Z. et al. The Rise and Potential of Large Language Model Based Agents: A Survey. arXiv:2309.07864 (2023). इसकी opening definition “AI agents are artificial entities that sense their environment, make decisions, and take actions” के लिए ऊपर quote किया गया, जो 2023 में textbook definition को restate करती है क्योंकि cite करने के लिए कोई agreed modern one नहीं था।

  9. Sumers, T. R., Yao, S., Narasimhan, K. और Griffiths, T. L. Cognitive Architectures for Language Agents. arXiv:2309.02427 (2023). language agents को “modular memory components, a structured action space to interact with internal memory and external environments, and a generalized decision-making process to choose actions” के रूप में organise करता है, और उन्हें symbolic AI और cognitive science के इतिहास में explicitly situate करता है। Memory taxonomy अध्याय 24 में लौटती है, जहाँ three-store table उसका practical shadow है।

मॉडल चुनने का काम LIA पर छोड़ने के लिए तैयार हैं?

हर AI मॉडल एक ही जगह — आज ही मुफ़्त शुरू करें।