Unit 06.01: Moving logic out of the model and into code
Most routing decisions in a crew are keyword decisions dressed up as judgement.
The same decision, written down
A manager agent routing a ticket costs a model call. The same routing written as a function costs nothing and gives the same answer every time.
The code routes four tickets by rule.
def route_by_agent(ticket):
"""What a manager agent does: a model call, ~1,200 tokens, usually right."""
return "billing" # stand-in for the call
def route_by_rule(ticket):
"""The same decision, written down."""
text = ticket["text"].lower()
if any(w in text for w in ("refund", "charge", "invoice", "billing")):
return "billing"
if any(w in text for w in ("password", "login", "access")):
return "account"
if any(w in text for w in ("error", "crash", "broken")):
return "technical"
return "general"
TICKETS = [
{"text": "I was charged twice"},
{"text": "cannot log in, password reset broken"},
{"text": "the export crashes every time"},
{"text": "just saying hello"},
]
for ticket in TICKETS:
print(f"{ticket['text']:38} -> {route_by_rule(ticket)}")
print(f"\nrule cost: 0 tokens, identical every run, testable in {len(TICKETS)} lines")
# The second ticket mentions both "password" and "broken". The rule resolves it
# by order, which is a decision you can see and change. A manager agent resolves
# it however it resolves it that run.
The second ticket is the useful one: it mentions both password and broken, so it could go to account or to technical. The rule resolves it by the order of the checks - a decision you can see in the source and change deliberately.
A manager agent resolves the same ambiguity however it resolves it that run. There is no line to read, no ordering to change, and no way to know it happened.
The mistake this prevents
The mistake is concluding from an ambiguous case that the decision needs judgement after all. Ambiguity means the rule needs a tie-break, and writing the tie-break down is strictly better than delegating it to something that will not tell you which way it went.
Takeaway
Write routing rules down. Ambiguous cases argue for an explicit tie-break, not for a model - a rule you can read beats a decision you cannot inspect.
