Node implementation is where architecture becomes executable behavior. In this step you implement two concrete nodes:
- reason node: invoke reasoning runnable and write
agent_outcome.
- act node: execute tool based on
agent_outcome and append (action, observation) to intermediate_steps.
Reason node requirements: pass exact expected state keys, validate runnable output type, and never write tool outputs directly.
Act node requirements: resolve tool from registry, validate input schema, enforce timeout, catch tool errors, and convert output into stable string/JSON representation for state.
Critical invariant: act node should only run when current outcome is AgentAction; finish outcomes must bypass action execution.
Failure handling strategy:
- Tool not found -> append structured error observation and route to reason for fallback decision.
- Tool timeout -> append timeout marker + increment retry counter.
- Serialization error -> safe-stringify observation and attach parse status.
Testing priority: node-level tests for state updates and error branches, then integration tests for full loop routing.
Deepening Notes
Source-backed reinforcement: these points are extracted from the LangGraph source note to sharpen architecture and flow intuition.
- n node as well as the ACT node right here so let's actually let me take you through it step by step so right here you can see that we are going to use the react agent runnable that
- ing to use the react agent runnable that we wrote in the previous section and all that we are going to do is we are going to invoke on it using the agent State okay so all the valu
- ing the agent State okay so all the values all the these things that we see right here these are reserved keywords and this you know runnable is going to know exactly what to do wi
- ere we have the agent outcome that is going to be an agent action or the finish so as soon as this node is executed it is either going to have agent action or agent finish only dur
- there's always going to be action or finish all right all right so let's come back to the graph so now let's let's assume that it is going to be agent action now it is going to com
Interview-Ready Deepening
Source-backed reinforcement: these points add detail beyond short-duration UI hints and emphasize production tradeoffs.
- Implement reason and act nodes with strict contracts, deterministic state updates, and safe tool invocation.
- Reason node requirements: pass exact expected state keys, validate runnable output type, and never write tool outputs directly.
- Act node requirements: resolve tool from registry, validate input schema, enforce timeout, catch tool errors, and convert output into stable string/JSON representation for state.
- Testing priority: node-level tests for state updates and error branches, then integration tests for full loop routing.
- Fine-grained state graphs improve control, but poor state contracts can create brittle routing behavior.
- Tool-heavy loops improve grounding, but latency and failure surfaces rise with each external dependency.
- Node implementation is where architecture becomes executable behavior.
- Critical invariant: act node should only run when current outcome is AgentAction ; finish outcomes must bypass action execution.
Tradeoffs You Should Be Able to Explain
- More agent autonomy increases adaptability but also increases non-determinism and debugging effort.
- Tool-heavy loops improve grounding, but latency and failure surfaces rise with each external dependency.
- Fine-grained state graphs improve control, but poor state contracts can create brittle routing behavior.
First-time learner note: Think in state transitions, not giant prompts. Keep node responsibilities small and route logic deterministic so each step is easy to reason about.
Production note: Bound autonomy with loop limits, tool policies, and checkpoints. Capture route decisions and state snapshots for replay and incident analysis.