Prompt injection detection for Microsoft Agent Framework
Arcjet prompt injection detection evaluates each incoming prompt for injection patterns inside your application before it reaches the AI provider. Detected attacks are blocked before the AI call is made, protecting both your application behavior and your AI budget.
What is Arcjet?
Arcjet is the AI agent runtime security platform. Discover the agents running in your organization, enforce policy across every action, prompt, and tool call, and keep the evidence to prove what happened. Detect prompt injection, authorize agent tool calls, redact PII, and block bots and abuse.Quick start
Section titled “Quick start”Screen inbound user text with GuardMiddleware before the model sees it.
package main
import ( "context"
"github.com/arcjet/arcjet-go" "github.com/arcjet/arcjet-go/agentframework" "github.com/microsoft/agent-framework-go/agent")
func inbound(guard *arcjet.GuardClient) (agent.Middleware, error) { promptScan := must(arcjet.GuardPromptInjection(arcjet.GuardPromptInjectionOptions{ Mode: arcjet.ModeLive, })) return agentframework.GuardMiddleware(guard, agentframework.MiddlewareConfig{ Inbound: &agentframework.InboundPolicy{ Action: "message.received", Rules: func(_ context.Context, text string) ([]arcjet.GuardRuleInput, error) { return []arcjet.GuardRuleInput{promptScan.Text(text)}, nil }, }, })}
func must[T any](v T, err error) T { if err != nil { panic(err) } return v}For more information about inbound screening, see the Microsoft Agent Framework agent guard.
What next?
Section titled “What next?” Prompt injection detection intro Learn how prompt injection detection works and when to use it.
AI abuse protection Combine with bot detection for complete AI app protection.
AI data loss prevention Prevent PII from entering model context alongside prompt injection protection.
Testing Write tests for your rules.
Get help
Section titled “Get help”Need help with anything? Email support@arcjet.com to get support from our engineering team.