Free lesson · Module 1, lesson 2 of 7

Chatbot, workflow or agent: three ways to build one feature

Build the same feature three ways on paper (a fee enquiry for a college): one prompt, a fixed chain of steps, and an agent, and say what each costs in money, speed and control.

Lessons in this module

Lesson notes

For the student

One feature can be built three ways: one prompt, a fixed chain of steps, or an agent. They differ in who decides the next step, and that decides the cost, the speed and how each one fails. The prices in this lesson (₹0.50 and 2 seconds for each model call) are made up for the comparison; real prices differ.

The feature and the three designs

  • The feature: a student asks the Campus Helpdesk the fee for a branch and year
  • One prompt (a chatbot): the college's information page (office timings, the hostel fee) is pasted into the prompt and the model answers once. The fee for each branch and year is not on the page; it is in the accounts office's fee table
  • Fixed chain (a workflow): the model picks out the branch and the year, your code runs get_fee, which reads the fee table, and the model writes the reply
  • Agent: the model has get_fee and find_notice and chooses its own next step in a loop, stopped after 6 model calls

The comparison

  • Who decides the next step: nobody (one prompt), the programmer (fixed chain), the model (agent)
  • Model calls: 1, 2, and lookups + 1 for the agent (at most 6)
  • Cost at ₹0.50 a call: ₹0.50, ₹1.00, and up to ₹3.00
  • Time at 2 seconds a call: 2 seconds, 4 seconds, and up to 12 seconds
  • Same path every time: yes, yes, no
  • How each fails: one prompt guesses what it cannot see; the chain misses questions off its path; the agent picks a wrong tool or takes extra steps

The three cases

  • Asha's fee (CSE year 2) is only in the fee table: the fixed chain answers for ₹1.00 every time; one prompt would guess
  • 1,000 questions a month: the chain costs ₹1,000, an agent averaging 4 calls costs ₹2,000, so ₹1,000 more
  • Ravi's question needs get_fee and find_notice: the agent answers in 3 calls (2 lookups + 1 answer), ₹1.50; the chain gives half an answer
  • Priya's hostel fee is printed on the information page: one prompt answers for ₹0.50

How to choose

  • Write down ten real questions first
  • Try one prompt; move to a fixed chain only when the answer needs data the prompt cannot see
  • Move to an agent only when different questions need different steps
  • Budget an agent for its step limit, not for its shortest run

Try it

  • Pick a feature from your college or a shop and sketch it all three ways: one prompt, a fixed chain, an agent
  • For each sketch, write who decides the next step, the model calls per answer and one way it fails
  • Choose one design and give two reasons

Lesson quiz

Checked in your browser. Nothing is sent or saved.

5 questions

Question 1 · easy

In the fixed chain design of the fee feature, who decides the next step?

Question 2 · easy

At the lesson's made-up price of ₹0.50 a model call, what does one answer from the fixed chain cost?

Question 3 · medium

The agent is stopped after 6 model calls, and each call takes 2 seconds in the lesson's comparison. What is the longest one answer can take?

Question 4 · medium

Priya asks for the hostel fee, which is printed on the college's information page that is already pasted into the prompt. Which design answers her most cheaply?

Question 5 · hard

According to the lesson, when should you move from a fixed chain to an agent?

What an agent is: a model, tools and a loopNext: When not to build an agent