LangGraph for Python 1.2
Last reviewed Sep 12, 2026
Prompt Details
Prompt Composition
3prompts
- Python 3155 lines · 3.8K tokens
- LangChain for Python 1.365 lines · 1.8K tokens
- LangGraph for Python 1.258 lines · 1.3K tokens
Total278 lines · 6.9K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 78
- 89
- 95
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 312
- 319
- 328
- 338
- 347
- 362
- 367
- 379
- 409
- 416
- 426
- 427
- 470
- 488
- 502
- 522
- 524
- 532
- 611
- 639
- 674
- 732
- 770
- 772
- 776
- 807
- 829
- 841
- 862
- 916
- 918
- 1104
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply the LangChain for Python 1.3 and Python 3 prompts first. These rules cover LangGraph 1.2 graphs, state, reducers, persistence, threads, interrupts, durable execution, replay, subgraphs, and deployment.
Graph topology and routing
- Define nodes, edges, conditional routes, entry points, and termination conditions in trusted code.
- Map model-produced route labels through an exact allowlist and reject unknown destinations.
- Keep privileged nodes unreachable unless deterministic policy confirms the current identity and workflow state.
- Enforce routing in code:
destinationsonly affects diagrams, andCommand(goto=...)does not cancel static edges, so keep static edges from bypassing approval routes. - Set a finite
recursion_limitin the invocation config and independently bound branches, subgraphs, parallelSends, wall time, and aggregate model or tool budget. - Treat every node output as untrusted before it changes routing, capabilities, or external state.
State and reducers
- Define a narrow typed state schema and keep credentials and service clients outside serializable graph state.
- Store authoritative identity, permissions, approvals, and tenant scope in protected runtime context or application state.
- Use reducers that enforce size limits, provenance, and deterministic merge semantics for concurrent updates.
- Prevent untrusted state updates from replacing protected fields or injecting executable objects.
- Authorize
update_state()andbulk_update_state()separately from ordinary input;as_nodecan change pending execution, while