Skip to main content

Overview

Upsonic ships with built-in skill safety policies that validate skill content before it reaches the agent. Apply them via Skills(policy=...) to protect against prompt injection, secret leaks, and dangerous code patterns in skill instructions and references.

Built-in Skill Policies

Each policy comes in multiple variants:
  • Block — blocks the content and returns an error to the agent
  • RaiseException — raises a DisallowedOperation exception
  • LLM variants — use an LLM for smarter detection or contextual error messages

Example 1: Prompt Injection Protection

Protect your agent from malicious skill content that attempts to hijack its behavior. The policy detects patterns like “ignore all previous instructions” and “you are now a different agent” and blocks the skill content before the agent can see it.

Example 2: Secret Leak Protection

Prevent skills from accidentally exposing API keys, tokens, or passwords to the agent. The policy scans skill content for known secret formats (AWS keys, GitHub tokens, Anthropic keys, etc.) and blocks it when secrets are found.

Example 3: Multiple Policies

Pass a list of policies — all are checked. Here a skill contains dangerous code patterns (eval(), exec(), os.system()). The code injection policy catches it even though the other two policies pass.

How It Works

When an agent accesses skill content (instructions or references), the content is checked against all configured policies:
  1. Each policy’s check() method receives a PolicyInput with the content
  2. If any policy returns a result with confidence > 0.7, the content is blocked
  3. The agent receives an error message instead of the skill content
Script execution results are not policy-checked — only skill instructions and reference document content pass through the safety engine.

Parameters