Fix false positives in agent guardrails

Skip empty fingerprints in SystemPromptLeakGuardrail to prevent blank
values from flagging every message. Replace overly broad "sk-" pattern
in SensitiveDataGuardrail with specific LLM provider prefixes
("sk-proj-" for OpenAI, "sk-ant-" for Anthropic) to avoid false
positives on common words like "risk-based" or "task-management".

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-27 12:16:37 +01:00
committed by Sacha Al Himdani
parent 2f8674471b
commit 4725a1b080
5 changed files with 32 additions and 16 deletions

View File

@@ -59,20 +59,20 @@ func (g *PromptInjectionGuardrail) Check(ctx context.Context, messages []llm.Mes
resp, err := g.client.ChatCompletion(
ctx,
&llm.ChatCompletionRequest{
Model: "gpt-4o-mini",
Messages: []llm.Message{
{
Role: llm.RoleSystem,
Parts: []llm.Part{llm.TextPart{Text: promptInjectionClassifierPrompt}},
},
{
Role: llm.RoleUser,
Parts: []llm.Part{llm.TextPart{Text: userText}},
Model: "gpt-4o-mini",
Messages: []llm.Message{
{
Role: llm.RoleSystem,
Parts: []llm.Part{llm.TextPart{Text: promptInjectionClassifierPrompt}},
},
{
Role: llm.RoleUser,
Parts: []llm.Part{llm.TextPart{Text: userText}},
},
},
MaxTokens: new(10),
Temperature: new(0.0),
},
MaxTokens: new(10),
Temperature: new(0.0),
},
)
if err != nil {
// If the classifier fails, allow the message through rather than