Metadata-Version: 2.4
Name: opsveritas
Version: 0.3.1
Summary: Monitor your AI agents in 3 lines of code — tokens, cost, latency, and silent failures
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == "langchain"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest-mock>=3.12; extra == "dev"
Requires-Dist: langchain-core>=0.2; extra == "dev"

# opsveritas

Monitor your AI agents in **three lines of code**. Tracks tokens, cost, latency, model, and silent failures (200 OK with empty output) — and routes alerts to Slack / Email / Teams via [OpsVeritas AI Agents Control Tower](https://agents.opsveritas.com).

```bash
pip install opsveritas
```

## Quick start (3 lines)

```python
import opsveritas

opsveritas.init("<your-ingest-key>")                       # key from Settings → Integrations
client = opsveritas.wrap(openai_client, agent_name="Support Bot")
# use `client` exactly as before — runs appear in your dashboard automatically
```

Works the same for Anthropic and Gemini clients. Prefer manual control? Use the decorator:

```python
@opsveritas.monitor("Nightly Report")
def run_report():
    ...
```

## LangChain (one line)

Attach the handler to any LangChain chat model, LLM or chain — every call reports token / cost / latency / silent-failure automatically:

```python
from langchain_openai import ChatOpenAI
import opsveritas

opsveritas.init("<your-ingest-key>")
model = ChatOpenAI(callbacks=[opsveritas.langchain("My Agent")])
```

Needs `langchain-core` (optional): `pip install "opsveritas[langchain]"`. Works with any LangChain-backed provider (OpenAI, Anthropic, Gemini, Groq…). Inside `opsveritas.run(...)` the handler aggregates into a single execution instead of double-counting.

## What data is sent

By design the SDK sends **metadata only, plus a short output snippet** — never your prompts/inputs:

| Sent | Detail |
|------|--------|
| ✅ Metadata | agent name, status, timestamps, duration, token counts, model, cost, tool-call count |
| ⚠️ Output snippet | first 300 chars of the response (`output_summary`) — powers silent-failure detection |
| ⚠️ Error message | the exception text, if a call fails |
| ❌ Prompts / inputs | **never sent** — only token counts |

### Metadata-only mode (for regulated / client data)

Drop the output snippet and redact error text so **no response content ever leaves your environment** — token/cost/latency metadata still flows:

```python
opsveritas.init("<your-ingest-key>", metadata_only=True)
```

Or set the environment variable:

```bash
OPSVERITAS_METADATA_ONLY=true
```

## Reliability

Telemetry is **non-blocking and fire-and-forget** — it never raises into your code and never slows your agent. If the ingest endpoint is briefly unreachable, sends are **retried with backoff** and **buffered in memory** (bounded), then flushed on the next event — so a transient outage doesn't lose telemetry.

## Configuration

```python
opsveritas.init(
    api_key,
    endpoint="https://agents.opsveritas.com",  # optional
    metadata_only=False,                        # optional; when True, no response content is sent
)
```

## License

MIT
