Skip to main content

alerts you when things go wrong in production

Project description

coreason-sentinel

The "Watchtower" & Circuit Breaker for Production AI Agents

License: Prosperity 3.0 CI Code Style: Ruff Docs

coreason-sentinel is an automated monitoring service for deployed LLM agents. It goes beyond simple "System Error" tracking to detect "Cognitive Errors" (Hallucinations) and "Business Errors" (Budget Spikes). Acting as a pharmacovigilance unit for AI, it monitors the agent's behavior in the real world, detects side effects like drift or toxicity, and triggers a Circuit Breaker to protect users and budgets if safety limits are breached.

Features

  • Deep Tracing & Observability: visualize the entire cognitive chain (Retrieve -> Rerank -> Scout -> Generate) using OpenTelemetry and Arize Phoenix.
  • Holistic Signal Detection: Monitors three key signal planes:
    • Cognitive: Hallucination rates, RAG relevance.
    • Business: Token costs, Latency spikes.
    • User: Sentiment analysis, refusal rates, and frustration signals.
  • The Drift Engine: Advanced statistical detection for:
    • Content Drift: Changes in retrieved document vectors.
    • Style Drift: "Lazy Agent" syndrome detection using Kullback-Leibler (KL) Divergence.
    • Relevance Drift: Semantic distance between queries and responses.
  • Automated Circuit Breaker: A "Dead Man's Switch" that transitions to OPEN (blocking traffic) if quality or safety drops below configured thresholds. Includes HALF-OPEN self-healing to test recovery.
  • The Spot Checker: Automated QA that randomly samples live traffic (or focuses on negative sentiment) and loops it back for grading.

For a full breakdown of requirements and philosophy, see the Product Requirements Document.

Installation

pip install coreason-sentinel

Usage

Here is how to initialize the Circuit Breaker to protect your agent:

import time
from redis import Redis
from coreason_sentinel.circuit_breaker import CircuitBreaker
from coreason_sentinel.models import SentinelConfig, CircuitBreakerTrigger

# 1. Configure the Sentinel
config = SentinelConfig(
    agent_id="agent-alpha",
    owner_email="ops@coreason.ai",
    phoenix_endpoint="http://localhost:6006",
    triggers=[
        # Trip if Faithfulness drops below 0.7 in the last hour
        CircuitBreakerTrigger(metric="faithfulness", threshold=0.7, window_seconds=3600, operator="<"),
        # Trip if Latency exceeds 10s in the last minute
        CircuitBreakerTrigger(metric="latency", threshold=10.0, window_seconds=60, operator=">"),
    ]
)

# 2. Initialize the Circuit Breaker
# Note: You must provide a valid Redis client and a NotificationService implementation.
# (Assuming a mock notification service for this example)
class MockNotificationService:
    def notify(self, message):
        print(f"NOTIFICATION: {message}")

breaker = CircuitBreaker(
    redis_client=Redis(),
    config=config,
    notification_service=MockNotificationService()
)

# 3. Protect your Agent
if not breaker.allow_request():
    # Return a maintenance message or failover
    print("Circuit Breaker OPEN: Traffic blocked due to safety violation.")
else:
    # Process your agent request...
    start_time = time.time()
    try:
        # ... agent logic ...
        print("Agent processing request...")
        pass
    finally:
        # Record metrics for the breaker to monitor
        # In a real app, you would calculate actual latency
        breaker.record_metric("latency", time.time() - start_time)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coreason_sentinel-0.1.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreason_sentinel-0.1.0-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file coreason_sentinel-0.1.0.tar.gz.

File metadata

  • Download URL: coreason_sentinel-0.1.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_sentinel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 835bbe3484cc880166f357aacd8c83f4392f3d174da641c2213166be21b715f6
MD5 b613d6c9e484e6b394148a527d029b6b
BLAKE2b-256 26682e5dace81be0b28827dca5801eff33ce912c8c0dc3fd26920051e81350aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sentinel-0.1.0.tar.gz:

Publisher: publish.yml on CoReason-AI/coreason-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coreason_sentinel-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for coreason_sentinel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11f39d05340209f2c4289980ea8c1c35bbc250efb7841a309d4b215b51689087
MD5 53b3b699bb0bbff847116b0f629cbc26
BLAKE2b-256 9124414982172c2196c337795cdfd2be0218e34381b967494bfa3e7eda0cf5d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sentinel-0.1.0-py3-none-any.whl:

Publisher: publish.yml on CoReason-AI/coreason-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page