Guard Fixes
Add input/output validation.
Guard fixes add validation to inputs, outputs, or both.
Use Cases
- Content safety filtering
- JSON format validation
- Input length constraints
- Output length constraints
Configuration
Guard fixes use a guard_type and guard_config structure:
{
"fix_id": "fix-guard-001",
"fix_type": "guard",
"config": {
"guard_type": "content_filter",
"guard_config": {
"blocked_patterns": ["(?i)password", "(?i)secret"]
}
}
}Config Keys
| Key | Type | Description |
|---|---|---|
guard_type | string | One of "content_filter", "format_check", "input_validation", "output_validation" |
guard_config | object | Type-specific guard configuration |
Guard Types
Content Filter
Block content matching regex patterns. Applies to both input and output:
{
"fix_type": "guard",
"config": {
"guard_type": "content_filter",
"guard_config": {
"blocked_patterns": [
"(?i)password",
"(?i)api[_-]?key",
"\\b\\d{3}-\\d{2}-\\d{4}\\b"
]
}
}
}Format Check
Validate output format (e.g., valid JSON). Applies to output only:
{
"fix_type": "guard",
"config": {
"guard_type": "format_check",
"guard_config": {
"format": "json"
}
}
}Input Validation
Validate input content constraints:
{
"fix_type": "guard",
"config": {
"guard_type": "input_validation",
"guard_config": {
"min_length": 1,
"max_length": 50000
}
}
}Output Validation
Validate output content constraints:
{
"fix_type": "guard",
"config": {
"guard_type": "output_validation",
"guard_config": {
"min_length": 10,
"max_length": 10000
}
}
}Guard Direction
Each guard type applies to a specific direction:
| Guard Type | Input | Output |
|---|---|---|
content_filter | Yes | No |
format_check | No | Yes |
input_validation | Yes | No |
output_validation | No | Yes |
Common Fixes
Block Sensitive Content
{
"fix_type": "guard",
"config": {
"guard_type": "content_filter",
"guard_config": {
"blocked_patterns": [
"(?i)password",
"(?i)secret",
"(?i)api[_-]?key",
"\\b\\d{16}\\b"
]
}
}
}Ensure JSON Output
{
"fix_type": "guard",
"config": {
"guard_type": "format_check",
"guard_config": {
"format": "json"
}
}
}Limit Input Size
{
"fix_type": "guard",
"config": {
"guard_type": "input_validation",
"guard_config": {
"max_length": 50000
}
}
}