Skip to course content
Free LangGraph course

LangGraph for Agentic Workflows

Unit 03.00: Which decisions need judgement

Every step in a graph is either a rule you can write down or a judgement you cannot. Sorting them correctly is most of what makes a workflow cheap and reliable.

Could you write the rule down?

That is the test. If the answer is yes, write it down - an if statement is free, instant, and wrong only when you made a mistake you can find.

The code sorts six decisions.

DECISIONS = [
    ("is this number greater than 100?",        "code"),
    ("is this email angry or neutral?",         "model"),
    ("does this string parse as a date?",       "code"),
    ("which of these four teams should handle it?", "model"),
    ("has the retry count reached 3?",          "code"),
    ("summarise these findings in two lines",   "model"),
]

print(f"{'decision':46} belongs in")
for decision, owner in DECISIONS:
    print(f"{decision:46} {owner}")

code = sum(1 for _, o in DECISIONS if o == "code")
print(f"\n{code} of {len(DECISIONS)} need no model at all.")

# The test: could you write the rule down? If yes, write it down. A model asked
# to compare two numbers will usually be right, costs money and latency, and is
# wrong unpredictably -- three properties an `if` statement does not have.

Four of the six need no model. "Is this number greater than 100" and "has the retry count reached 3" are comparisons; "does this string parse as a date" is a library call.

The two that genuinely need a model - sentiment and routing to one of four teams - share a property: you could not write the rule down without enumerating cases you have not seen. That is what judgement means here.

The mistake this prevents

The mistake is using a model for a decision because the surrounding step already involves one. Once a model is in the node it feels free to ask it one more thing, and each extra question adds latency, cost, and a failure mode that is wrong unpredictably rather than reproducibly.

Takeaway

Write down every rule you can write down. Reserve the model for decisions where enumerating the cases is the part you cannot do - and note that those are usually a minority of the steps.