Bird
0
0

Given this routing setup:

medium📝 component behavior Q4 of 15
LangChain - LangGraph for Stateful Agents
Given this routing setup:
conditions = [lambda ctx: ctx['age'] > 18, lambda ctx: ctx['age'] <= 18]
routes = ['adult_node', 'child_node']
ctx = {'age': 20}

Which node will the graph route to?
Aadult_node
Bchild_node
CNo routing occurs
DBoth nodes run
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate conditions with ctx

    ctx['age'] is 20, so first condition ctx['age'] > 18 is True.
  2. Step 2: Determine routing based on first True condition

    Graph routes to 'adult_node' because first condition is True.
  3. Final Answer:

    adult_node -> Option A
  4. Quick Check:

    Condition True routes to adult_node [OK]
Quick Trick: First True condition decides route [OK]
Common Mistakes:
MISTAKES
  • Choosing child_node despite age 20
  • Assuming both nodes run
  • Thinking no routing happens

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes