A support desk in plain Python
The support desk is a program that reads a customer message, finds the order and writes a reply; here it is two plain Python functions, before any agent.
Last updated: 28 Sep, 2026 · CrewAI 1.15
With CrewAI installed, start from the desk as plain Python. Seeing it this way shows what the framework changes later and what it keeps.
The shop keeps its orders in a dictionary. A customer writes a message, and two workers deal with it: a clerk who finds the order, and a writer who answers the customer.
The order book and two workers
ORDERS = {"A17": "shipped on 3 March", "C40": "waiting for stock"}
def look_up(message):
for word in message.replace("?", "").split():
if word in ORDERS:
return f"{word} {ORDERS[word]}."
return "I could not find that order."
def write_reply(finding):
return f"Dear customer, {finding}"look_up scans the message for an order id it knows. write_reply turns what the clerk found into a sentence for the customer. The writer never sees the message, only the clerk's finding.
Running the two functions
print(write_reply(look_up("Where is my order A17?")))Dear customer, A17 shipped on 3 March.
print(write_reply(look_up("Where is my order B22?")))Dear customer, I could not find that order.
Reading the two replies
- A17 is in the order book, so look_up returns its status and write_reply wraps it for the customer.
- B22 is not, so the desk says it cannot find the order rather than guess one.
Where plain rules fall short
Each worker follows exact rules. A message that says "order a17" in lower case, or asks two questions at once, falls through them. The shop also has a rule the code has no place for: a refund needs a manager's approval.
CrewAI keeps the same shape. Each worker becomes an agent with a role, and each job becomes a task; a model reads the words and decides, where this code matches strings. The clerk's dictionary lookup survives as a tool in the tools lesson, and the refund rule arrives in the tool-hooks lesson.
| Concern | Plain functions | A CrewAI crew |
|---|---|---|
| Deciding | match a string exactly | a model reads the words |
| New phrasing | falls through the rules | the model still answers |
| The refund rule | no place for it | a hook, in the tool-hooks lesson |
When plain functions are enough
- The input is fixed and well formed, such as an order id from a form.
- No judgement is needed; a lookup or a calculation is the whole job.
- You want the same output every time, with no model in the loop.
Related
- Previous: Setup: installing CrewAI
- Next: A custom LLM with BaseLLM
- Call
look_up("where is order a17?")and read why it fails. - Add B22 to
ORDERSwith any status and run the second example again. - Make
write_replyadd a closing line and print both replies again.
You understood something today that you didn't yesterday.