Metadata-Version: 2.4
Name: sentinelai-sdk
Version: 0.1.5
Summary: Drop-in reliability observability for multi-agent AI workflows
License: MIT License
        
        Copyright (c) 2026 Sumedha Khatter
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://www.agentsentinelai.com
Project-URL: Repository, https://github.com/SKhatter/sentinel-ai
Project-URL: Bug Tracker, https://github.com/SKhatter/sentinel-ai/issues
Keywords: ai,agents,observability,tracing,llm,langchain,openai,anthropic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: openai
Requires-Dist: openai>=0.28; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20; extra == "anthropic"
Provides-Extra: langchain
Requires-Dist: langchain>=0.0.154; extra == "langchain"
Provides-Extra: all
Requires-Dist: openai>=0.28; extra == "all"
Requires-Dist: anthropic>=0.20; extra == "all"
Requires-Dist: langchain>=0.0.154; extra == "all"
Dynamic: license-file

# sentinelai-sdk

Observability, contract enforcement, and safe replay for multi-agent AI pipelines.

**Dashboard:** [www.agentsentinelai.com/dashboard](https://www.agentsentinelai.com/dashboard)

---

## Install

```bash
pip install sentinelai-sdk
```

Get an API key at the dashboard → ⚙️ Settings → Generate Key. Free, no credit card required.

---

## Pick what you need

| I want to… | Feature | Dashboard tab |
|---|---|---|
| See what my agents are doing — steps, inputs, outputs, latency | Tracing | Traces |
| Block bad data from reaching the next agent, replay from failure | Contract + Replay | Incidents |
| Let concurrent agents write shared state without overwriting each other | Shared State | State |

These stack — use one, two, or all three.

---

## 1. Tracing

### Zero changes — auto_instrument()

One line. Detects openai, anthropic, langchain and patches them automatically.

```python
import sentinel
sentinel.auto_instrument(api_key="sk_live_...")
sentinel.set_active_run("run_001", "my_pipeline")

# Your existing code — completely unchanged
response = client.chat.completions.create(model="gpt-4o", messages=[...])
```

### Or instrument from the CLI

```bash
sentinel instrument pipeline.py
```

Reads your file, asks what you want to add, writes the instrumented version.

### Manual options

```python
# Decorator — 1 line per function
@sentinel.trace_step(name="planner", step_type="llm_call", workflow_name="my_pipeline")
def planner(query): ...

# OpenAI
sentinel.patch_openai(client, workflow_name="my_pipeline")

# Anthropic
sentinel.patch_anthropic(client, workflow_name="my_pipeline")

# LangChain
cb = sentinel.LangChainCallback(workflow_name="my_pipeline")
llm = ChatOpenAI(model="gpt-4o", callbacks=[cb])
```

---

## 2. Contract + Replay

Define what one agent must hand to the next. If invalid, Sentinel blocks the downstream agent, creates an incident, and saves a checkpoint for replay.

```python
from sentinel import Sentinel

client = Sentinel(api_key="sk_live_...")

client.register_contract(
    workflow_name="my_pipeline",
    from_step="planner",
    to_step="research",
    schema={
        "type": "object",
        "required": ["destination", "budget", "days"],
        "properties": {
            "destination": {"type": "string"},
            "budget":      {"type": "number"},
            "days":        {"type": "integer"}
        }
    },
    on_fail="block"
)

run = client.start_workflow(workflow_name="my_pipeline", input={"query": "..."})
plan = planner(query)

result = client.record_step(run_id=run["run_id"], step_name="planner", output=plan)
if result["boundary_check"]["result"] == "failed":
    print("Blocked:", result["boundary_check"]["reason"])
    # replay from checkpoint once fixed:
    client.replay(
        run_id=run["run_id"],
        checkpoint_id=result["boundary_check"]["checkpoint_id"],
        patched_output={"destination": "Japan", "budget": 2000, "days": 5}
    )
```

---

## 3. Shared State

Safe concurrent writes — no silent overwrites between parallel agents.

```python
# Read
value, version = sentinel.get_state(run_id, "key")

# Write with conflict protection
sentinel.propose_state(run_id, "key", new_value, base_version=version)

# Auto-retry on conflict
sentinel.propose_state_with_retry(run_id, "key", lambda cur: {**(cur or {}), "field": value})
```

---

## Links

- [Integration guide](https://github.com/SKhatter/sentinel-ai-demo/blob/main/INTEGRATION_GUIDE.md)
- [Runnable examples](https://github.com/SKhatter/sentinel-ai-demo/tree/main/examples)
- [Dashboard](https://www.agentsentinelai.com/dashboard)
