A support desk in plain Python
Before any agent, the desk is two Python functions: one finds the order, one writes the reply. CrewAI keeps that shape and lets a model decide.
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.
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.
print(write_reply(look_up("Where is my order A17?")))print(write_reply(look_up("Where is my order B22?")))A17 is in the dictionary, so the clerk finds it and the writer passes it on. B22 is not, and the desk says so instead of guessing.
What this code cannot do
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 lesson 8, and the refund rule arrives in lesson 12.
- 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.