Lesson 170 — Advanced

Agentic AI interview scenarios

Agent ka sawaal interview mein aksar ulta chalta hai — interviewer tumse autonomy badhwata hai aur tumhe decision defend karna hota hai: workflow ya agent, kaunsi tool, kitni autonomy, kahan human checkpoint. Is lesson mein tum ek business task ka agent design karoge (planning, tools, memory, multi-step execution), ek failure-modes ka menu pakadoge (runaway loops se lekar over-powered tools tak), HITL guardrails rakhna seekhoge, aur trajectory se debug karna — kyunki test mein success aur production mein failure ka farq hi asli interview question hai.

⏱ 20 min• Advanced• Production RAG interview scenarios

Workflow ya agent — autonomy pehle, capability baad mein

Kya hai?

Agent ka matlab hai LLM khud plan banata hai, tools leta hai aur result dekh kar agla kadam chunta hai. Workflow mein raasta tumne pehle likha hai, LLM sirf har step ka input/output sambhaalta hai. Farq autonomy ka hai, capability ka nahi.

Kab kaam aata hai?

Workflow tab jab raasta predictable hai — ticket classify → DB lookup → template reply. Agent tab jab raasta har case mein alag ho — research, multi-system debugging, open-ended procurement. Pehle "raasta predictable hai?" poochho.

Kahan milta hai?

Automation tools, support copilots, SRE assistants, research agents — aur unke andar bhi aksar ek workflow skeleton ke chhote agent islands. Sab kuch autonomous karne ki zarurat nahi hoti.

Defence ka frame do line mein hai: "is task ka raasta pehle se likh sakte hain?" Haan toh workflow — sasta, testable, tez. Nahi toh agent — mehnga, unpredictable, par flexible. Interview mein ye hi do line decision hai; framework ka naam baad mein aata hai.

Autonomy ladder: 0 = rules, 1 = ek LLM call, 2 = fixed chain of LLM steps, 3 = planner + tools, 4 = multi-agent. Har rung upar cost, latency aur debuggability kharab hota hai. Default hamesha sabse neeche ka rung jo kaam kare — upar sirf tab jao jab neeche genuinely fail ho.

Agent design — planning, tools, memory, multi-step

agent loop (single agent, ek business task):
  goal    = user ka job (e.g. "is ticket ka root cause dhoondho")
  plan    = LLM chunta hai: kaunsi tool pehle, kab stop (think-act-observe)
  tools   = search_kb(), get_logs(ticket_id), query_db(sql), create_ticket()
  memory  = short-term: trajectory (abhi tak kya kiya) + running summary
            long-term: user prefs, past resolutions (vector store se retrieval)
  stop    = budget (max steps) + confidence check + ya tool ne final answer diya

har step ka log: tool, args, result, tokens, latency -> trajectory = debugging fuel
Interview probe: "Agent ne ye tool kyun li?" — is sawaal ka seedha jawab tool ke description aur task ke goal se hai. Agent ka har step uske apne trajectory se justify hona chahiye; agar kadam ka koi source nahi toh wo hallucination hai, planning nahi.

Failure modes ka menu — signal pakdo, fix batao

failure                  signal                      fix
runaway loop             same tool repeat, budget     max steps, progress check, hard stop
poor tool selection      wrong tool, phir retry       fewer tools, descriptions, few-shot
tool failure             timeout/5xx/empty result     idempotent retries, clear error to model
nondeterministic run     do runs, alag raaste         evals on outcomes, guardrails on paths
token cost blowup        long context, deep loops     summarise trajectory, cap context, cache
context degradation      purani steps bhool gaya      running summary, key facts pinned
over-powered tool perms  delete-all / prod scope      least privilege, read-only default
Sabse mehnga failure: Over-powered tools. Agent 99 baar sahi chala, ek baar galat tool chun liya — refund delete, prod deploy, mass email. Blast radius wahi hai jo tumne permission se pehle se decide kar diya tha. Default deny, least privilege, explicit allowlist.

Human-in-the-loop checkpoints aur guardrails

approval_policy:            # frame — apne product ke risk se bharo
  read_only:    agent khud chala sakta hai, log ke saath
  low_risk_write: agent chala sakta hai + undo window + audit log
  high_risk:    human approval mandatory (refund, delete, external email, prod deploy)

guardrails:
  scope:        approval per RUN, na ki per user (warna session reuse se leak)
  timeout:      approval ka time na mile -> default DENY, na ki default allow
  budgets:      max_steps, max_tokens_per_run, max_cost_per_day
  filters:      input (prompt injection check) + output (PII, harmful) checks
Checkpoint ka test: Poochho: "ye action reversible hai?" Haan toh undo window + log kaafi. Nahi toh human checkpoint — bina exceptions ke. Interview mein ye do line dikhata hai ki tum risk se sochte ho, features se nahi.

Trajectory se debug karna — test success vs prod failure

trajectory (debug fuel) — step by step padho, output nahi:
[
  {step: 1, tool: search_kb,     args: {q: "refund policy"},   ok: true},
  {step: 2, tool: search_kb,     args: {q: "refund policy"},   ok: true},  <- repeat: loop smell
  {step: 3, tool: query_db,      args: {sql: "update ..."},    blocked: by_policy},
  {step: 4, tool: create_ticket, args: {...},                  ok: true}
]

test mein success, prod mein failure ke aam kaaran:
  test queries clean the, prod queries messy/indian-english/spanglish
  prod tools ke paas rate limits/latency hain jo test stubs mein nahi the
  prod memory mein purane, galat resolutions bhi retrieve ho rahe hain
Debug ka order: Trajectory -> tool quality -> prompt -> model. Pehle dekho agent ne kya kiya; agar steps sahi the aur phir bhi galat toh prompt/model pe jao. Har baar prompt badalna pehla option nahi hai — trajectory sabse sasta evidence hai.

Exercise

Question: Agent aur workflow ka farq ek shabd mein kya hai? (kya badalta hai)

Question: Runaway loop ko rokne ka sabse direct control kya hai — temperature ya max steps?

Question: Consequential action se pehle lagne wala human checkpoint kya kehlata hai? (teen shabd)

Question: Ek run mein tool ki permission se tay hone wala nuksaan ka scope kya kehlata hai? (do shabd)

Question: Agent ko debugging fuel kya deta hai — final output ya step-by-step log?

Common mistakes

Desi example: Naye waiter ko menu dena

Agent ek naye waiter jaisa hai: har dish ka recipe nahi, sirf ek chhota sharply-defined menu chahiye (tools). Cash refund manager se poochhna padta hai (HITL), aur har order ka kitchen ticket (trajectory) rakho — tabhi toh galat order ka pata chalega:

text
menu (tools)      -> 3-6 items, alag-alag, clearly named
refund policy     -> waiter khud nahi, manager (HITL) approve
tip jo kabhi nahi -> delete-all wali dish menu mein hi nahi
kitchen ticket    -> trajectory log: step, order, status
busy night (prod) -> running tally (summary) bhoolta nahi
Interview angle — yahan se sawaal aate hain
  • Q: Workflow vs agent kab chunoge? — Raasta predictable hai toh workflow (sasta, testable); unknown hai toh agent (flexible, mehnga). Autonomy ka farq, capability ka nahi.
  • Q: Agent ne galat tool kyun li? — Tool descriptions dekho (overlapping? vague?), phir task-tool fit. Model ko dosh dene se pehle tool design audit karo.
  • Q: Runaway loop kaise rokoge? — Max steps, progress check, hard budget; aur tool ke error messages ko clear banao taaki model repeat na kare.
  • Q: HITL kahan lagana chahiye? — Consequential, irreversible action se pehle; scope per-run; timeout pe default deny. Reversible action pe undo window + audit log kaafi.
  • Q: Test mein pass, prod mein fail — kaise debug? — Trajectory padho, tool quality check karo (errors, rate limits), phir inputs (messy queries) aur memory (stale resolutions) audit karo.
Lesson complete?

Agent design aur defense ka frame ready — ab tum autonomy ko justify kar sakte ho aur failure ko trajectory se dhoond sakte ho. Agla lesson — Fine-tuning & Model Adaptation Interviews — mein decide karenge kab weights badalne hain aur kab sirf prompt.

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