AI Agents & Tool Use
Chapter: 6.2 AI Agents & Tool Use Level: 2 — Recall (definitions, standard problems, short derivations) Time Limit: 30 minutes Total Marks: 40
Q1. Define an AI agent in the context of LLM-based systems, and name the three core components of a basic agent reasoning loop. (4 marks)
Q2. The ReAct framework interleaves two kinds of steps. Name them and briefly explain what each produces in a single loop iteration. (4 marks)
Q3. Explain what function calling (tool use) means for an LLM. List two pieces of information that must be provided in a tool/function schema so the model can call it correctly. (4 marks)
Q4. Define task decomposition in agent planning. State one advantage of decomposing a complex task into subtasks. (4 marks)
Q5. Distinguish between short-term (working) memory and long-term memory in an agent. Name the common storage mechanism used for long-term semantic memory. (4 marks)
Q6. In a multi-agent system, briefly describe two common collaboration patterns (e.g., roles/topologies) used to coordinate agents. (4 marks)
Q7. Name two popular agentic frameworks and state, in one line each, the primary purpose each is best known for. (4 marks)
Q8. Define guardrails in the context of agentic systems, and give one example of an input-side guardrail and one output-side guardrail. (4 marks)
Q9. (Short derivation / calculation) An agent runs a ReAct loop. Each iteration consists of 1 reasoning (thought) call and 1 action call. A task requires 5 iterations to finish, plus 1 final answer call. (a) How many total LLM calls are made? (2 marks) (b) If each LLM call costs 800 input tokens and 200 output tokens, compute the total tokens consumed. (2 marks) (c) If input tokens cost $2 per million and output tokens cost $6 per million, compute the total cost in dollars. (2 marks)
Q10. In autonomous agent evaluation, define task success rate. If an agent completes 42 out of 60 benchmark tasks successfully, compute the success rate as a percentage. (2 marks)
Answer keyMark scheme & solutions
Q1. (4 marks)
- An AI agent is a system that uses an LLM as a reasoning engine to autonomously perceive input/state, decide on actions, and interact with an environment or tools to achieve a goal. (2)
- Three core components of the reasoning loop: (a) perception/observation, (b) reasoning/planning (decide next action), (c) action/execution — repeated until the goal is met. (2, 1 each for any 2–3 correct: sense → think → act)
Q2. (4 marks)
- Reasoning (Thought): the model generates an internal chain-of-thought explaining what to do next. (2)
- Acting (Action): the model issues a concrete action such as a tool/API call and receives an Observation back. (2)
- Why: ReAct = Reasoning + Acting; thoughts guide actions, observations ground reasoning, reducing hallucination.
Q3. (4 marks)
- Function calling = the LLM outputs a structured request (function name + arguments) that an external tool executes, with results returned to the model. (2)
- Two required schema pieces (any two): function name, parameter names & types, description of what the function does, required vs optional args. (2, 1 each)
Q4. (4 marks)
- Task decomposition = breaking a large/complex goal into smaller, ordered, solvable subtasks (a plan). (2)
- Advantage (any one): easier reasoning per step, better tool selection, parallelizability, error isolation/recovery, improved reliability. (2)
Q5. (4 marks)
- Short-term/working memory: holds current context, recent messages, and intermediate state within a single task/session (bounded by context window). (1.5)
- Long-term memory: persists knowledge/experience across sessions. (1.5)
- Common mechanism for long-term semantic memory: vector database / embedding store with similarity retrieval (RAG). (1)
Q6. (4 marks) (any two, 2 marks each)
- Supervisor/orchestrator pattern: a manager agent delegates subtasks to specialist worker agents.
- Role-based / debate / cooperative pattern: agents assume distinct roles (e.g., planner, coder, critic) and exchange messages.
- Sequential pipeline or hierarchical topologies also acceptable.
Q7. (4 marks) (2 each)
- LangChain: framework for chaining LLM calls, tools, and agents (orchestration/agent workflows).
- LlamaIndex: framework focused on data indexing/retrieval (RAG) connecting LLMs to external data.
Q8. (4 marks)
- Guardrails = rules/filters/constraints that keep agent behavior safe, valid, and within policy. (2)
- Input-side example: prompt-injection / PII / toxicity filtering on user input. (1)
- Output-side example: schema/format validation, content moderation, blocking unsafe tool calls. (1)
Q9. (6 marks) (a) Calls = 5 iterations × 2 calls + 1 final = 11 calls. (2) (b) Total tokens = 11 × (800 + 200) = 11 × 1000 = 11,000 tokens (8,800 input + 2,200 output). (2) (c) Cost = input: 8800 × $2/1e6 = $0.0176; output: 2200 × $6/1e6 = $0.0132; total = $0.0308. (2)
Q10. (2 marks)
- Task success rate = (successful tasks / total tasks) × 100%. (1)
- = 42/60 × 100 = 70%. (1)
[
{"claim":"Q9a total LLM calls = 11","code":"iters=5; result = (iters*2+1)==11"},
{"claim":"Q9b total tokens = 11000","code":"calls=11; result = calls*(800+200)==11000"},
{"claim":"Q9c total cost = 0.0308 dollars","code":"cost = 8800*2/1000000 + 2200*6/1000000; result = abs(cost-0.0308)<1e-9"},
{"claim":"Q10 success rate = 70 percent","code":"result = Rational(42,60)*100==70"}
]