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.0.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.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coreason_sentinel-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 c7d45c799a34ac061ec7b009f7c489de5ffb12cee5243a79470a69bc5bc4991f
MD5 d67762f64c20b7079f802f5a6b1f50bf
BLAKE2b-256 21940aaf02e2d51aa2a6b323fb59636d93806bd78aae44626b2e8f2fc934d261

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for coreason_sentinel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8507a4f858c9160b2fbd6c455e965fd63a26532eb6aa38740a6f550f437e9625
MD5 632c371f65b77fd9fb3affc870442585
BLAKE2b-256 49562726902f9f859ec45f14d9f28ce136f8ad42e84b0a39ff0299ffa7b1451d

See more details on using hashes here.

Provenance

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