Aapke paas loop already hai. Yeh course usse engineer karne ke baare mein hai. Pehle, poora territory dekh lete hain.
Aap yeh cheez already likh chuke ho: ek while loop jo model ko call karta hai, jo tool calls wo maangta hai unhe run karta hai, results wapas feed karta hai, aur dobara chal padta hai. Thorsten Ball ki famous line hai ki ek agent bas “an LLM, a loop, and enough tokens” hai1 — aur wo sahi hai ki skeleton ~300 lines ka boilerplate hai.
Loop engineering wo sab hai jo us skeleton ke kaam karne ke baad hota hai. Ek toy loop aur ek aise agent ke beech ka gap jise aap customer ke saamne rakh sako — wo koi genius ka flash nahi hai. Wo kuch levers hain, har ek deliberately tuned. Yeh lesson un levers ka map hai. Har aage wala lesson ek lever mein zoom karta hai.
Map se pehle, unit fix karte hain. Loop engineering turn par operate karta hai — loop ka ek pass. Ek turn ko haddiyon tak utaaro toh wo har baar wahi chhe moves hote hain:
HumanLayer poore apparatus ko nichod kar kehta hai: “prompt + switch statement + context builder + loop.”2 Yeh phrase yaad kar lo — neeche har lever in chaar shabdon mein se kisi ek ko engineer karne ka tareeka hai.
Yeh rahe wahi chhe moves us code ki tarah jo aap already likh chuke ho, spine tak utaar kar. Dhyaan do — koi magic nahi hai, “agent” yahi loop hai:
# Factor 8 — own your control flow: yeh loop HI agent hai
state = init(task)
for turn in range(MAX_TURNS): # move 6 · stop: budget guard
ctx = build_context(state) # move 1 · context assemble
reply = model(ctx) # move 2 · model call
if reply.is_final: # move 6 · stop: goal mil gaya
return reply.answer
calls = parse_tool_calls(reply) # move 3 · output parse
results = [run(c) for c in calls] # move 4 · tools execute (+ errors)
state = append(state, results) # move 5 · observation append
raise BudgetExceeded(state) # move 6 · stop: guard trip
Is course ka har lever in lines mein se kisi ek ko engineer karne ka tareeka hai: build_context Lever 02 hai, run aur uske tools Levers 03/04 hain, MAX_TURNS Lever 05 hai, run ke andar error handling Lever 06 hai, aur state Lever 07 hai. Loop ka shape khud Lever 01 hai.
Yeh raha map. Har card ek dimension hai jise aap independently engineer karte ho. Aaj inhe master nahi karoge — inhe dekhna seekhoge, taaki jab agent misbehave kare toh aapko pata ho kaunsa knob pakadna hai.
Agla step kaun decide karta hai — aapka code (workflow) ya model (agent)? Master lever; baaki sab isi se latakte hain.
Har turn window mein kya aata hai. Anthropic isko curate karna agent performance ka sabse bada factor kehta hai.4
Action space — model kya kar sakta hai, aur uske tools kitne clearly named, typed, aur documented hain.3
Wo ground truth jo loop har turn wapas padhta hai progress aankne ke liye. Feedback nahi → loop guess kar raha hai.3
Loop kab khatam hota hai. Turns/tokens par caps — roughly 3–20 steps handoff se pehle, ek common rule.2
Failures kaise wapas fold hote hain — compacted, dump nahi — taaki loop khud ko correct kare, doob na jaaye.2
Loop ka state aur control kaun rakhta hai — ideally aap: pause/resume, human-in-the-loop, stateless reducers.2
Agar ek cheez yaad rakhni ho, toh Lever 01 yaad rakho. Anthropic line saaf khींchta hai:
Workflows are systems where LLMs and tools are orchestrated through predefined code paths.
Agents are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks. — Anthropic, Building Effective Agents
Yeh ek baar chunne waali binary nahi hai — yeh har decision par ek dial hai. Zyaadatar production “agents” dial ke workflow wale end ki taraf hote hain: zyaadatar ordinary, deterministic software, jisme model kuch high-leverage decision points par rakha hota hai.2 Anthropic ki blunt advice: “add complexity only when it demonstrably improves outcomes.”3 Paanch named workflow patterns — chaining, routing, parallelization, orchestrator–workers, evaluator–optimizer — sab isi dial ke workflow side par points hain. Inke liye hum ek poora lesson denge.
Ab aap do cheezein kar sakte ho jo ek ghante pehle name bhi nahi kar paate the: (1) kisi bhi agent ko chhe-move turn aur saat levers mein decompose karna, aur (2) kisi bhi design point ko workflow (aapka code decide karta hai) ya agent (model decide karta hai) classify karna. Yeh vocabulary aage aane waale sab kuch ke liye aapka diagnostic kit hai. Neeche isse lock karo.
Dobara mat padho — retrieve karo. Effortful recall hi is map ko aisi memory mein badalta hai jo agle hafte tak rahegi. Apne dimaag se answer do; feedback turant milta hai.
Anthropic — Building Effective Agents. Is territory ka sabse high-trust map: workflow/agent split, paanch patterns, aur “start simple” discipline. ~20 minute. Yeh poore course ki backbone hai.
TradingAgents loop, maan lo)? Mujhe bolo ki batau ki saat levers mein se wo kis par sabse weak hai. Bas chat mein apna sawaal type karo.