Interface Guardrail
- All Known Implementing Classes:
HITLApproval
public interface Guardrail
A guardrail that checks whether an agent action is permitted.
Guardrails are used by SupervisorAgent to enforce safety constraints
on agent actions. Each guardrail evaluates an action request and returns a
result indicating whether the action is allowed.
Usage Example
Guardrail readOnly = new Guardrail() {
public String getName() { return "read-only"; }
public GuardrailResult check(String agentId, String action, Map<String, Object> ctx) {
if (action.startsWith("write")) {
return new GuardrailResult(false, "Write operations not allowed", GuardrailSeverity.BLOCK);
}
return new GuardrailResult(true, "Allowed", GuardrailSeverity.INFO);
}
};
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordResult of a guardrail check.static enumSeverity level for guardrail decisions. -
Method Summary
-
Method Details
-
getName
String getName()Returns the name of this guardrail.- Returns:
- guardrail name, must be unique within a supervisor
-
check
Checks whether an agent action is allowed.- Parameters:
agentId- the ID of the agent attempting the actionaction- the action being attemptedcontext- additional context about the action- Returns:
- result indicating whether the action is allowed
-