Overview
An anchor is a hard constraint that can never be violated during flow execution. Unlike soft preferences or validation checks, anchors are inviolable rules enforced by the runtime. Think of them as safety guardrails that the AI cannot cross.Syntax
Core Concept
Anchors vs. Validation:Fields
require (optional)
Type: Identifier
Specifies a required property that must be present in all outputs.
source_citation— Must cite sourcesfactual_claim— Must be factual (not opinion)structured_output— Must follow schemaverified— Must be verified against ground truthcomplete— Must be complete (no partial answers)
reject (optional)
Type: List of identifiers
Conditions that must never appear in outputs.
speculation— Speculative statementsopinion— Subjective opinionsharmful— Harmful contentoffensive— Offensive contentillegal— Illegal advice or contentprivate— Private informationguessing— Uncertain guessesbias— Biased statements
enforce (optional)
Type: Identifier
A policy to enforce throughout execution.
confidence_floor (optional)
Type: Float (range: 0.0 to 1.0)
Minimum confidence level required. Below this threshold, the anchor’s unknown_response is returned.
| Domain | Recommended Floor | Rationale |
|---|---|---|
| Medical | 0.95-0.99 | Lives at stake |
| Legal | 0.90-0.95 | Legal consequences |
| Financial | 0.90-0.95 | Money at stake |
| General | 0.75-0.85 | Standard accuracy |
| Creative | 0.50-0.70 | More flexibility |
unknown_response (optional)
Type: String
Response returned when confidence is below the floor or constraints cannot be met.
- Be specific about why the anchor prevented a response
- Guide users toward appropriate alternatives
- Maintain professional tone
- Don’t apologize excessively
on_violation (optional)
Type: One of raise, warn, log, escalate, fallback
Action to take when the anchor is violated.
Violation Actions
| Action | Syntax | Behavior |
|---|---|---|
raise | raise ErrorName | Throw error, halt execution |
warn | warn | Emit warning, continue |
log | log | Log violation, continue |
escalate | escalate | Flag for human review |
fallback | fallback("message") | Return fallback message |
on_violation_target (internal)
For raise and fallback actions, specifies the error name or fallback message.
Complete Examples
No Hallucination Anchor
Safe Content Anchor
Medical Disclaimer Anchor
Legal Caution Anchor
No Bias Anchor
Factual Only Anchor
Usage with Run Statements
Anchors are applied using theconstrained_by modifier:
Multiple Anchors
You can apply multiple anchors to a single flow:Anchors vs. Validation
| Aspect | Anchor | Validation |
|---|---|---|
| When | During generation | After generation |
| Purpose | Prevent violations | Detect violations |
| Action | Block invalid outputs | Refine invalid outputs |
| Flexibility | None (hard constraint) | Configurable (soft check) |
| Use Case | Safety, compliance | Quality, correctness |
Example: Both Together
Best Practices
1. Use Anchors for Safety-Critical Constraints
2. Combine Multiple Constraints
3. Provide Helpful Unknown Responses
4. Match Severity to Violation Action
5. Domain-Specific Anchors
Create specialized anchors for different domains:Common Patterns
Source Citation Requirement
Content Safety
Professional Disclaimer
Audit and Compliance
Type Checking
The AXON type checker validates: ✅ Confidence floor: Must be between 0.0 and 1.0✅ Violation actions: Must be valid actions
✅ Raise targets: If using
raise, must specify error name✅ Anchor references: Referenced anchors must exist
