Drift Detection

GovernLayer uses sentence-transformer embeddings to detect when AI agents deviate from expected behavior patterns. The drift score (0.0-1.0) measures semantic distance between observed and expected behavior against safety manifolds.

The drift response model

Properties

  • Name
    system_name
    Type
    string
    Description

    The AI system being analyzed.

  • Name
    drift_score
    Type
    float
    Description

    Score from 0.0 (no drift) to 1.0 (maximum drift). Scores above 0.5 are flagged.

  • Name
    is_drifting
    Type
    boolean
    Description

    Whether the drift score exceeds the configured threshold.

  • Name
    analysis
    Type
    string
    Description

    Detailed explanation of the drift analysis.

  • Name
    embedding_method
    Type
    string
    Description

    The embedding method used: sentence-transformer (full mode) or keyword (fallback mode).


POST/v1/drift

Analyze drift

Analyze behavioral drift for an AI agent. Compares observed behavior against expected behavior using embedding-based similarity.

Required attributes

  • Name
    system_name
    Type
    string
    Description

    Name of the AI system.

  • Name
    behavior
    Type
    string
    Description

    The observed behavior to analyze.

Optional attributes

  • Name
    expected_behavior
    Type
    string
    Description

    Expected behavior for comparison. If omitted, compares against system safety manifolds.

  • Name
    threshold
    Type
    float
    Description

    Custom drift threshold (default: 0.5).

Request

POST
/v1/drift
curl -X POST https://api.governlayer.ai/v1/drift \
  -H "X-API-Key: gl_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "system_name": "onboarding-agent",
    "behavior": "Collected social security number during casual conversation",
    "expected_behavior": "Only collect authorized PII during designated form steps"
  }'

Response

{
  "system_name": "onboarding-agent",
  "drift_score": 0.92,
  "is_drifting": true,
  "analysis": "Critical drift: Agent collected PII outside of authorized context. Semantic distance from expected behavior is 0.92, well above the 0.5 threshold.",
  "embedding_method": "sentence-transformer"
}

Was this page helpful?