Guardrail Middleware (AutoMode)
BipkitGuardrailMiddleware wraps sensitive agent tools (such as shell execution, SQL runners, or refund endpoints) and blocks hazardous invocations before execution.
Installation
Section titled “Installation”pip install "bipkit[langchain]"from bipkit.integrations.langchain import BipkitClassifier, BipkitGuardrailMiddleware
# Reads BIPKIT_API_KEY from environment by defaultguardrail = BipkitGuardrailMiddleware( tools=["bash"], danger_instructions="Destructive deletion of database records or wiping filesystems with rm -rf", threshold=0.60, classifier=BipkitClassifier(engine="bip-instant"),)
def execute_bash(cmd: str) -> str: return run_shell(cmd)
safe_bash = guardrail.wrap_tool(execute_bash, tool_name="bash")
# Safe command succeedssafe_bash(cmd="git status")
# Destructive command is intercepted before execution (raises PermissionError)safe_bash(cmd="rm -rf /production/database and drop all records")