alerts you when things go wrong in production
Project description
coreason-sentinel
The "Watchtower" & Circuit Breaker for Production AI Agents
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d37d0cc94650782a59bb4fb4399cd7cc2c08b549dd820e967aa322687ee7679c
|
|
| MD5 |
a480227cd8441050012668cde10e1046
|
|
| BLAKE2b-256 |
1b453b95bca222d0d906a1e0d5082db8953422fd1f7a2b6d33ca1b4780ef0111
|
Provenance
The following attestation bundles were made for coreason_sentinel-0.2.1.tar.gz:
Publisher:
publish.yml on CoReason-AI/coreason-sentinel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_sentinel-0.2.1.tar.gz -
Subject digest:
d37d0cc94650782a59bb4fb4399cd7cc2c08b549dd820e967aa322687ee7679c - Sigstore transparency entry: 868036759
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-sentinel@ca0af3c11547291aeef797b932fa9d466f31517e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ca0af3c11547291aeef797b932fa9d466f31517e -
Trigger Event:
release
-
Statement type:
File details
Details for the file coreason_sentinel-0.2.1-py3-none-any.whl.
File metadata
- Download URL: coreason_sentinel-0.2.1-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db06f0f11af9b3c2581818c5cf39bba848906fbaa8d5095d14308a3e10b6778
|
|
| MD5 |
c0f1aa3a4b06e7b64495ce5f50c5d0e1
|
|
| BLAKE2b-256 |
79bc34467f4cf56765e90c2ff82a5c015e0666cc3bb16c42fa2a28d7a1fe15c6
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_sentinel-0.2.1-py3-none-any.whl -
Subject digest:
2db06f0f11af9b3c2581818c5cf39bba848906fbaa8d5095d14308a3e10b6778 - Sigstore transparency entry: 868036784
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-sentinel@ca0af3c11547291aeef797b932fa9d466f31517e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ca0af3c11547291aeef797b932fa9d466f31517e -
Trigger Event:
release
-
Statement type: