GuardrailMiddleware
Block or reject tool invocations by tool name and argument regex policies
Class: bxModules.bxai.models.middleware.core.GuardrailMiddleware
Guards tool execution only. It can block specific tools or reject calls whose arguments match forbidden regex patterns.
Features
Denylist tool names with
blockedToolsValidate arguments per tool with
argPatternsWorks with both normalized
toolArgsand provider-native tool call shapesReturns
reject()with reason when a rule matches
Constructor
middleware = new bxModules.bxai.models.middleware.core.GuardrailMiddleware(
blockedTools: [ "deleteRecord", "dropTable" ],
argPatterns : {
runSQL: [ { query: "^SELECT" } ]
}
)Configuration
blockedTools
array
[]
Tool names that are always rejected
argPatterns
struct
{}
Per-tool regex rules in the form { toolName: [ { paramName: "pattern" } ] }
Hooks Used
beforeToolCall
Example
Notes
Tool-name matching for
blockedToolsis case-insensitive.Pattern rules run only for tools present in
argPatterns.This middleware does not sanitize prompt text or model output.
Last updated