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.2.1.tar.gz (23.6 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.2.1-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coreason_sentinel-0.2.1.tar.gz
  • Upload date:
  • Size: 23.6 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.2.1.tar.gz
Algorithm Hash digest
SHA256 d37d0cc94650782a59bb4fb4399cd7cc2c08b549dd820e967aa322687ee7679c
MD5 a480227cd8441050012668cde10e1046
BLAKE2b-256 1b453b95bca222d0d906a1e0d5082db8953422fd1f7a2b6d33ca1b4780ef0111

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sentinel-0.2.1.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.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for coreason_sentinel-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2db06f0f11af9b3c2581818c5cf39bba848906fbaa8d5095d14308a3e10b6778
MD5 c0f1aa3a4b06e7b64495ce5f50c5d0e1
BLAKE2b-256 79bc34467f4cf56765e90c2ff82a5c015e0666cc3bb16c42fa2a28d7a1fe15c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sentinel-0.2.1-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