Whatever message this page gives is out now! Go check it out!
validate() function is the required public method that a guardrail CFC must implement to participate in the Agent() guardrail pipeline. Input guardrails receive the user message; output guardrails receive the AI-generated response.// Input guardrail
public struct function validate(required string userMessage) { ... }
// Output guardrail
public struct function validate(required string aiMessage) { ... }Parameter | Type | Required | Description |
|---|---|---|---|
userMessage | String | Required (input guardrail) | The user's raw input string. Present only in input guardrails, which execute before the LLM is invoked. |
aiMessage | String | Required (output guardrail) | The AI-generated response string. Present only in output guardrails, which execute after the LLM produces its response. |
Key | Description |
|---|---|
result | Controls execution flow. Valid values: "success" (allow through), "failure" (block with non-fatal error), "fatal" (block and throw immediately). |
message | Diagnostic or explanatory message used for logging or error responses. |
repromptMessage | Optional message used when the guardrail requests a user reprompt. Pass an empty string when not applicable. |
action as the control key (with values "success", "failure", "fatal", "reprompt"), whereas CFC guardrails use result as shown above. Both styles are functionally equivalent; the key name differs only between declaration styles.inputGuardrails or outputGuardrails array when calling Agent():agent({
CHATMODEL: chatModel,
retrievalAugmentor: {
contentRetriever: {
vectorStore: vs,
maxResults: 5,
minScore: 0.5
}
},
inputGuardrails: [ expandPath("./guardrails/SensitiveData.cfc") ],
outputGuardrails: [ expandPath("./guardrails/Profanity.cfc") ]
});// /guardrails/SensitiveData.cfc
component {
public struct function validate(required string userMessage) {
if (findNoCase("password", arguments.userMessage)) {
return {
result: "fatal",
message: "Sensitive data detected",
repromptMessage: ""
};
}
return {
result: "success",
message: "OK",
repromptMessage: ""
};
}
}