Skip to main content

Runtime Validation

Runtime validation ensures AXAG contracts are honored during agent execution. While static validation catches structural errors, runtime validation catches behavioral violations — an agent attempting an action without meeting preconditions, exceeding parameter constraints, or violating safety boundaries.

Runtime Validation Points

Pre-Execution Validation

Before executing a tool call, the runtime validates:

  • Required parameters: All required parameters are present and non-null
  • Type constraints: Parameter values match declared types
  • Range constraints: Numeric values are within minimum/maximum bounds
  • Enum constraints: String values are from declared enum sets
  • Format constraints: Values match declared formats (email, date, URI)
  • Preconditions: Declared preconditions are checked (where machine-checkable)

Execution-Time Validation

During execution, the runtime enforces:

  • Confirmation gate: If confirmation_required=true, ensure user confirmation was obtained
  • Approval gate: If approval_required=true, verify approval token from authorized role
  • Scope boundary: Ensure the operation stays within declared scope (tenant, user, etc.)
  • Idempotency check: For non-idempotent operations, warn if duplicate detected

Post-Execution Validation

After execution, the runtime verifies:

  • Postconditions: Declared postconditions are met (where verifiable)
  • Side-effects: Declared side-effects occurred as expected
  • Error semantics: Error responses follow the declared error schema

Implementation Pattern

AXAGRuntimeValidator — interface
interface AXAGRuntimeValidator {
validatePreExecution(
toolCall: ToolCall,
manifest: ManifestAction
): ValidationResult;

validateConfirmation(
toolCall: ToolCall,
confirmationToken: string | null
): ValidationResult;

validateApproval(
toolCall: ToolCall,
approvalToken: string | null,
approverRole: string
): ValidationResult;

validatePostExecution(
toolCall: ToolCall,
result: ExecutionResult,
manifest: ManifestAction
): ValidationResult;
}

interface ValidationResult {
valid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
}

Error Response Format

When runtime validation fails, the error response follows a standard format:

Validation error response
{
"error": {
"code": "AXAG_VALIDATION_ERROR",
"type": "precondition_failed",
"message": "Precondition not met: cart must have at least one item",
"details": {
"intent": "cart.begin_checkout",
"failed_precondition": "cart must have at least one item",
"suggestion": "Add items to cart before beginning checkout"
}
}
}

Common Runtime Validation Errors

Error CodeTypeDescription
AXAG_MISSING_PARAMparameter_errorRequired parameter not provided
AXAG_INVALID_TYPEparameter_errorParameter value has wrong type
AXAG_OUT_OF_RANGEconstraint_errorNumeric value outside min/max
AXAG_INVALID_ENUMconstraint_errorValue not in allowed enum set
AXAG_PRECONDITION_FAILEDprecondition_errorPrecondition check failed
AXAG_CONFIRMATION_MISSINGsafety_errorConfirmation required but not provided
AXAG_APPROVAL_MISSINGsafety_errorApproval required but not provided
AXAG_SCOPE_VIOLATIONsecurity_errorOperation outside declared scope
AXAG_TENANT_BOUNDARYsecurity_errorCross-tenant access attempt
AXAG_ROLE_INSUFFICIENTauthorization_errorCaller lacks required role