Lesson 82 — Intermediate

Capstone: Context-Managed Long-Horizon Agent

L6 ke saare pieces — budget, assembly, compaction, offload, tool slimming, caching, harness — ek agent mein. Yeh agent lamba task karta hai, crash se resume karta hai, aur khud verify kar ke hi "done" bolta hai.

⏱ 10 min• Intermediate• Harness Engineering

Capstone kya banega

WHAT

Context-managed long-horizon agent: budget-aware assembly, compaction triggers, NOTES.md offloading, slim tool outputs, step/time/token limits aur tests se verification — sab live components.

WHEN

L6 ka final check; portfolio project jo dikhata hai context engineering production level par kaise lagti hai.

WHERE

Ek repo: harness loop + notes protocol + ek eval scenario jo ek window mein na fit ho (yahin proof hai).

Success criteria pehle likho, baad mein build karo: task complete, budget kabhi over nahi, doosra run resume kar sake, tests green. Yeh chaar lines hi demo script hain.

Scope: Ek task type, ek environment. Feature jodne se pehle reliability (kill test + budget) green honi chahiye.

Design — loop mein L6

Boot → assemble (audit) → act (slim) → write-back → compact (trigger) — yahi loop chalega, verification ke saath.

Crash safety: Har step ka write-back hi kill test pass karata hai — process gaya toh NOTES mein wahi tak ka progress pada hai.

Starter code

def horizon(task, limits=LIMITS):
    notes = load_notes()
    plan = notes.plan or make_plan(task)
    while not plan.done and budget_ok(limits):
        ctx = assemble(RULES, notes.summary, plan.active, recent())  # audit on
        step = model(ctx, tools=tools_for(plan.active))
        result = run(step)
        notes.write(step, slim(result))            # write-back har step
        if ctx.over(0.7):
            compact(notes)                          # compaction trigger
    verify(plan)                                   # tests/linters
    return notes.final()
Done ka matlab: Verify fail toh plan wapas pending — "done" sirf green tests ke baad. Yehi ek line agent ko trustworthy banati hai.

Kill test aur metrics

Demo line: "Maine agent ko beech mein maar diya, restart par wahi se chala — context budget ke andar." Interview mein yeh do lines poore L6 ka proof hain.

Exercise

Question: Crash ke baad wapas chal kar wahin se jaari karna — ek shabd, English?

Question: Budget threshold par context chhota karna — ek shabd, English?

Question: Agent ke self-verification steps (tests, linters) — do shabd, English?

Common mistakes

Desi example: Hiking base camp

Lambi trek mein har base camp par likha jaata hai — aaj kahan tak, kal ka plan, kya bacha. Agle din wahi padh ke chalte ho. Long-horizon agent wahi hai: NOTES.md = base camp diary.

text
day_start  = read(NOTES)      # progress + plan
climb      = do_one_task()
night_note = write(done, next, facts)   # har raaz likho
# Camp skip = resume nahi — isi liye har step par write-back
Interview angle — yahan se sawaal aate hain
  • Q: L6 ke pieces ek loop mein kaise aate hain? (budget → assembly → act → slim → write-back → compact → verify)
  • Q: Kill test kaise karoge aur kya expect? (process band → restart → NOTES se resume, metrics ke saath)
  • Q: Compaction trigger kaise set karoge? (context over threshold par, har turn nahi — latency/quality balance)
  • Q: Sub-agent kab use karoge? (focused branch ke liye isolated context; condensed result wapas main loop mein)
Lesson complete?

L6 capstone ready: budget se lekar harness tak sab joda hua. Agla level L7 (LLM Evaluations) — wahan tum is agent ko measure karna seekhoge.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course