Whatever message this page gives is out now! Go check it out!
ragService = agent({
CHATMODEL: chatModel,
ingestion: {
source: expandPath("./test.txt"),
documentSplitter: { chunkSize: 500, chunkOverlap: 100 },
vectorStoreIngestor: { vectorStore: vectorStore }
},
retrievalAugmentor: {
queryRouter: {
contentRetrievers: [{
vectorStore: vectorStore,
maxResults: 3,
minScore: 0.6,
description: "Knowledge base"
}]
}
},
INPUTGUARDRAILS: [
expandPath("./guardrails/PasswordDetectionGuardrail.cfc"),
expandPath("./guardrails/LengthCheckGuardrail.cfc")
],
OUTPUTGUARDRAILS: [
expandPath("./guardrails/ProfanityOutputGuardrail.cfc"),
expandPath("./guardrails/AlwaysSuccessOutputGuardrail.cfc")
]
});
ragService.ingest();
answer = ragService.chat("How was the state of the economy in 2025?");// guardrails/AlwaysSuccessInputGuardrail.cfc
component {
public struct function validate(required string userMessage) {
return {
result: "success",
message: "Input is valid",
repromptMessage: ""
};
}
}// guardrails/SensitiveDataGuardrail.cfc
component {
public struct function validate(required string userMessage) {
var patterns = ["ssn", "social security", "credit card", "password"];
for (var pattern in patterns) {
if (findNoCase(pattern, arguments.userMessage)) {
return {
result: "fatal",
message: "Sensitive data detected: " & pattern,
repromptMessage: ""
};
}
}
return {
result: "success",
message: "No sensitive data",
repromptMessage: ""
};
}
}// guardrails/AlwaysSuccessOutputGuardrail.cfc
component {
public struct function validate(required string aiMessage) {
return {
result: "success",
message: "Output is valid",
repromptMessage: ""
};
}
}Key | Role |
result | One of three values: • success: allow the message through. • fatal: hard block (e.g. sensitive data). • failure: block with guardrail failure path. |
message | Human-readable reason (surfaced in errors such as "The AI request could not be completed…"). |
repromptMessage | Optional text for follow-up / refinement scenarios (used in some output cases). |
component {
public struct function validate(required string userMessage) { // or aiMessage
// Your validation logic here
return {
result: "success", // "success" | "fatal" | "failure"
message: "Reason",
repromptMessage: "" // Optional — used in reprompt scenarios
};
}
}Result type | Applies to | Behavior |
success | Input and output | The guardrail allows the message through. Execution continues to the next guardrail in the array, or proceeds to the pipeline if this was the last. |
fatal | Input and output | Hard block. The pipeline stops immediately. The message value is surfaced in the error (e.g. "The AI request could not be completed…"). Use for sensitive data, PII, or policy-critical violations where no recovery is appropriate. |
failure | Input and output | Block with guardrail failure path. Stops execution and surfaces message. Less severe than fatal; used for recoverable policy violations such as excessive length or profanity. |
repromptMessage | Primarily output | Optional text returned alongside failure to steer the model toward a better answer (e.g. "Provide a definitive answer based on the available data."). Exact runtime behavior depends on API version and whether reprompt flows are active. |
// guardrails/PasswordDetectionGuardrail.cfc
component {
public struct function validate(required string userMessage) {
if (findNoCase("password", arguments.userMessage)) {
return {
result: "fatal",
message: "Password detected",
repromptMessage: ""
};
}
return {
result: "success",
message: "No password",
repromptMessage: ""
};
}
}// guardrails/LengthCheckGuardrail.cfc
component {
public struct function validate(required string userMessage) {
if (len(arguments.userMessage) > 2000) {
return {
result: "failure",
message: "Too long",
repromptMessage: ""
};
}
return {
result: "success",
message: "Length OK",
repromptMessage: ""
};
}
}// guardrails/ShortInputGuardrail.cfc
component {
public struct function validate(required string userMessage) {
if (len(trim(arguments.userMessage)) < 10) {
return {
result: "fatal",
message: "Message too short - please provide a detailed query",
repromptMessage: ""
};
}xt
return {
result: "success",
message: "Input is valid",
repromptMessage: ""
};
}
}// guardrails/ProfanityOutputGuardrail.cfc
component {
public struct function validate(required string aiMessage) {
if (findNoCase("badword", arguments.aiMessage) > 0) {
return {
result: "failure",
message: "Profanity detected in output",
repromptMessage: ""
};
}
return {
result: "success",
message: "Output is clean",
repromptMessage: ""
};
}
}// guardrails/UncertaintyOutputGuardrail.cfc
component {
public struct function validate(required string aiMessage) {
var markers = ["i think", "maybe", "possibly", "not sure", "probably"];
for (var marker in markers) {
if (findNoCase(marker, arguments.aiMessage)) {
return {
result: "failure",
message: "Response contains uncertainty",
repromptMessage: "Provide a definitive answer based on the available data."
};
}
}
return {
result: "success",
message: "Response is definitive",
repromptMessage: ""
};
}
}// guardrails/OrderTrackerInputGuardrailA.cfc
component {
public struct function validate(required string userMessage) {
application.guardrailOrder = (structKeyExists(application, "guardrailOrder")
? application.guardrailOrder : "") & "A";
return {
result: "success",
message: "Guard A passed",
repromptMessage: ""
};
}
}INPUTGUARDRAILS: [
expandPath("./guardrails/OrderTrackerInputGuardrailA.cfc"),
expandPath("./guardrails/OrderTrackerInputGuardrailB.cfc"),
expandPath("./guardrails/OrderTrackerInputGuardrailC.cfc")
]// guardrails/RepromptInputGuardrail.cfc
component {
public struct function validate(required string userMessage) {
if (len(trim(arguments.userMessage)) < 10) {
return {
result: "failure",
message: "Message too short - please provide a detailed query",
repromptMessage: ""
};
}
return {
result: "success",
message: "Input is valid",
repromptMessage: ""
};
}
}// guardrails/AlwaysFailInputGuardrail.cfc
component {
public struct function validate(required string userMessage) {
return {
result: "failure",
message: "Guard blocks this",
repromptMessage: ""
};
}
}