Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildConversationContext ¶
func BuildConversationContext(messages []ConversationMessage) string
BuildConversationContext formats conversation history for the policy judge. System messages are excluded. Tool outputs are replaced with "[tool output redacted]".
Types ¶
type ApplicablePolicy ¶
type ApplicablePolicy struct {
ID string
Manifest types.MessagePolicyManifest
}
ApplicablePolicy pairs a policy's ID with its manifest.
type ConversationMessage ¶
type ConversationMessage struct {
Role string // "user", "assistant", "tool", "system"
Content string
ToolCalls []ToolCallInfo
ToolCallID string
}
ConversationMessage represents a message in conversation history for policy evaluation.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper evaluates natural-language policies with an LLM judge: the LLM judge guardrail, which message policies became.
func NewHelper ¶
NewHelper returns a judge that calls the default model aliases' models through the LLM gateway.
func (*Helper) EvaluateMessage ¶
func (h *Helper) EvaluateMessage(ctx context.Context, policies []ApplicablePolicy, conversationHistory []ConversationMessage, targetMessage string, direction types.PolicyDirection) []MessagePolicyViolation
EvaluateMessage runs all applicable policies against a message in parallel. Returns a slice of violations (empty if all policies pass). Never returns an error; LLM failures are treated as violations (fail closed).
type MessagePolicyViolation ¶
type MessagePolicyViolation struct {
PolicyID string
PolicyName string
PolicyDefinition string
Explanation string
// Failed reports that the policy could not be evaluated, rather than that the message
// was found to violate it. Message policies fail closed, so it still blocks.
Failed bool
}
MessagePolicyViolation is the result when a message violates a policy. nolint:revive
type ToolCallInfo ¶
ToolCallInfo contains the name and arguments of a tool call.