Bird
0
0

What is wrong with this LangGraph flow setup?

medium📝 Debug Q7 of 15
LangChain - LangGraph for Stateful Agents
What is wrong with this LangGraph flow setup?
nodeA.connect(nodeB)
nodeB.connect(nodeC, condition=lambda x: x < 0)
nodeC.connect(nodeD)

When input is 5, the flow throws an error.
ACondition lambda must return True for all inputs.
BnodeC cannot connect to nodeD without a condition.
CNo error should occur; the flow stops at nodeB if condition fails.
DnodeB.connect syntax is incorrect.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze flow and condition

    Condition on nodeB to nodeC allows flow only if input < 0.
  2. Step 2: Input 5 fails condition, so flow stops at nodeB

    This is expected behavior; no error should occur.
  3. Final Answer:

    No error should occur; the flow stops at nodeB if condition fails. -> Option C
  4. Quick Check:

    Failed condition = flow stops, no error [OK]
Quick Trick: Failed conditions stop flow, no error [OK]
Common Mistakes:
MISTAKES
  • Expecting errors on failed conditions
  • Thinking all connections need conditions
  • Misreading connect() syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes