Demonstrates how to add a CodeRifts guard node to a LangGraph agent that aborts execution when the API is unsafe.
pip install requests
python main.py[START] → [coderifts_guard] → (should_continue?) → [execute_tool] → [END]
↓ BLOCK
[END]
The coderifts_guard node calls the public preflight endpoint. The should_continue conditional edge routes to END if the decision is BLOCK, preventing the agent from calling an unsafe API.
def should_continue(state):
if state["coderifts_decision"] == "BLOCK":
return "END" # Abort the graph
return "execute" # Continue to tool execution