Metadata-Version: 2.5
Name: risicare
Version: 0.4.0
Summary: AI agent observability and error diagnosis for Python — trace LLM calls, detect errors, get AI-generated fix suggestions
Project-URL: Homepage, https://risicare.ai
Project-URL: Documentation, https://risicare.ai/docs
Author-email: Risicare <founders@risicare.ai>
License: Copyright (c) 2026 Conscience Labs Pvt. Ltd. All rights reserved.
        Contact: info@consciencelabs.ai
        
        COMMERCIAL END USER LICENSE AGREEMENT (EULA)
        
        This software ("SDK") is the proprietary property of Conscience Labs Pvt. Ltd.
        Your use of this SDK is strictly governed by the commercial subscription agreement
        and terms of service entered into between your organization and Conscience Labs Pvt. Ltd.
        
        LICENSE GRANT & RESTRICTIONS:
        1. Subject to an active, paid subscription, you are granted a limited, non-exclusive,
           non-transferable license to integrate this SDK into your applications solely to
           utilize the AI Observability services hosted by Conscience Labs Pvt. Ltd.
        2. You shall not modify, adapt, alter, translate, or create derivative works from this SDK.
        3. You shall not reverse engineer, decompile, disassemble, or otherwise attempt to
           derive the source code of this SDK.
        4. You shall not distribute, sublicense, lease, rent, or loan this SDK to any third
           party as a standalone tool or product.
        
        WARRANTY DISCLAIMER:
        THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
        IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
        FITNESS FOR A PARTICULAR PURPOSE.
        
        For licensing inquiries, custom enterprise terms, or support, please contact:
        info@consciencelabs.ai
License-File: LICENSE
Keywords: agent,agentic-ai,ai,ai-agent,anthropic,claude,error-diagnosis,gemini,gpt,langchain,llm,llm-observability,monitoring,observability,openai,opentelemetry,tracing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
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
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: risicare-core>=0.1.7
Requires-Dist: wrapt>=1.16.0
Provides-Extra: all
Requires-Dist: autogen-agentchat>=0.4.0; extra == 'all'
Requires-Dist: boto3>=1.34.0; extra == 'all'
Requires-Dist: cerebras-cloud-sdk>=1.0.0; extra == 'all'
Requires-Dist: crewai>=0.50.0; extra == 'all'
Requires-Dist: dspy>=2.5.0; extra == 'all'
Requires-Dist: google-cloud-aiplatform>=1.40.0; extra == 'all'
Requires-Dist: groq>=0.4.0; extra == 'all'
Requires-Dist: huggingface-hub>=0.20.0; extra == 'all'
Requires-Dist: instructor>=1.0.0; extra == 'all'
Requires-Dist: langchain-core>=0.2.0; extra == 'all'
Requires-Dist: langgraph>=0.2.0; extra == 'all'
Requires-Dist: litellm>=1.30.0; extra == 'all'
Requires-Dist: llama-index-core>=0.10.20; extra == 'all'
Requires-Dist: ollama>=0.1.0; extra == 'all'
Requires-Dist: openai-agents>=0.1.0; extra == 'all'
Requires-Dist: opentelemetry-api>=1.20.0; extra == 'all'
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == 'all'
Requires-Dist: pydantic-ai>=0.1.0; extra == 'all'
Requires-Dist: together>=1.0.0; extra == 'all'
Provides-Extra: autogen
Requires-Dist: autogen-agentchat>=0.4.0; extra == 'autogen'
Provides-Extra: bedrock
Requires-Dist: boto3>=1.34.0; extra == 'bedrock'
Provides-Extra: cerebras
Requires-Dist: cerebras-cloud-sdk>=1.0.0; extra == 'cerebras'
Provides-Extra: crewai
Requires-Dist: crewai>=0.50.0; extra == 'crewai'
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: dspy
Requires-Dist: dspy>=2.5.0; extra == 'dspy'
Provides-Extra: frameworks
Requires-Dist: autogen-agentchat>=0.4.0; extra == 'frameworks'
Requires-Dist: crewai>=0.50.0; extra == 'frameworks'
Requires-Dist: dspy>=2.5.0; extra == 'frameworks'
Requires-Dist: instructor>=1.0.0; extra == 'frameworks'
Requires-Dist: langchain-core>=0.2.0; extra == 'frameworks'
Requires-Dist: langgraph>=0.2.0; extra == 'frameworks'
Requires-Dist: litellm>=1.30.0; extra == 'frameworks'
Requires-Dist: llama-index-core>=0.10.20; extra == 'frameworks'
Requires-Dist: openai-agents>=0.1.0; extra == 'frameworks'
Requires-Dist: pydantic-ai>=0.1.0; extra == 'frameworks'
Provides-Extra: groq
Requires-Dist: groq>=0.4.0; extra == 'groq'
Provides-Extra: huggingface
Requires-Dist: huggingface-hub>=0.20.0; extra == 'huggingface'
Provides-Extra: instructor
Requires-Dist: instructor>=1.0.0; extra == 'instructor'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langchain-core>=0.2.0; extra == 'langgraph'
Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
Provides-Extra: litellm
Requires-Dist: litellm>=1.30.0; extra == 'litellm'
Provides-Extra: llamaindex
Requires-Dist: llama-index-core>=0.10.20; extra == 'llamaindex'
Provides-Extra: ollama
Requires-Dist: ollama>=0.1.0; extra == 'ollama'
Provides-Extra: openai-agents
Requires-Dist: openai-agents>=0.1.0; extra == 'openai-agents'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20.0; extra == 'otel'
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == 'otel'
Provides-Extra: providers
Requires-Dist: boto3>=1.34.0; extra == 'providers'
Requires-Dist: cerebras-cloud-sdk>=1.0.0; extra == 'providers'
Requires-Dist: google-cloud-aiplatform>=1.40.0; extra == 'providers'
Requires-Dist: groq>=0.4.0; extra == 'providers'
Requires-Dist: huggingface-hub>=0.20.0; extra == 'providers'
Requires-Dist: ollama>=0.1.0; extra == 'providers'
Requires-Dist: together>=1.0.0; extra == 'providers'
Provides-Extra: pydantic-ai
Requires-Dist: pydantic-ai>=0.1.0; extra == 'pydantic-ai'
Provides-Extra: together
Requires-Dist: together>=1.0.0; extra == 'together'
Provides-Extra: vertexai
Requires-Dist: google-cloud-aiplatform>=1.40.0; extra == 'vertexai'
Description-Content-Type: text/markdown

# risicare

AI agent observability and error diagnosis for Python.

[![PyPI version](https://img.shields.io/pypi/v/risicare.svg)](https://pypi.org/project/risicare/)
[![Downloads](https://img.shields.io/pypi/dm/risicare.svg)](https://pypi.org/project/risicare/)
[![Python](https://img.shields.io/pypi/pyversions/risicare.svg)](https://pypi.org/project/risicare/)
[![License: Proprietary](https://img.shields.io/badge/license-proprietary-red.svg)](LICENSE)

Monitor your AI agents in production. Trace every LLM call, detect errors automatically, and get AI-generated fix suggestions — with a single `init()`.

## Quickstart

```bash
pip install risicare
```

```python
import risicare
from openai import OpenAI

# Initialize — auto-instruments all detected LLM providers
risicare.init(
    api_key="rsk-...",
    endpoint="https://ingest.risicare.ai",
)

client = OpenAI()  # Automatically traced by risicare

@risicare.agent(name="research-agent")
def research(query: str) -> str:
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": query}],
    )
    return response.choices[0].message.content

result = research("What is quantum computing?")
risicare.shutdown()
```

**That's it.** Your agent's LLM calls, latency, token usage, and costs now appear in the [Risicare dashboard](https://app.risicare.ai).

## Prompt content is NOT captured by default

**Since 0.2.1, `trace_content` defaults to `False`.** Your prompts and
completions stay in your process. Everything else — model, token counts,
latency, cost, message roles, errors, and any attributes you set — is captured
as normal, so the dashboard, cost tracking and error diagnosis all work
unchanged.

To send prompt and completion text as well, opt in:

```python
risicare.init(api_key="rsk-...", trace_content=True)
# or set RISICARE_TRACE_CONTENT=true
```

**Upgrading from 0.2.0 or earlier?** This is a behaviour change: content that
used to be sent is no longer sent unless you opt in. In those versions the flag
also did not work for content you set by hand — `trace_content=False` did not
stop a `span.set_attribute("gen_ai.prompt.0.content", ...)` from reaching us.
Both are fixed together.

When capture is off, content-bearing attributes are **replaced** with
`<risicare:content-omitted>` rather than removed, so "no prompt was sent" stays
distinguishable from "capture is off".

Since 0.4.0, the gate also covers the OpenTelemetry GenAI, OpenInference and
CrewAI content keys, for example `input.value`, `output.value`,
`gen_ai.input.messages` and `gen_ai.output.messages`.

If you want content captured but redacted first, use the `mask` hook — it is
independent of this switch and runs on every content-bearing field before
export:

```python
risicare.init(api_key="rsk-...", trace_content=True, mask=lambda key, value: ...)
```


## Features

- **Auto-instrumentation** — Detects and patches LLM providers on `init()`, zero code changes
- **12 LLM providers** — OpenAI, Anthropic, Google, Mistral, Groq, Cohere, Together, Ollama, HuggingFace, Cerebras, Bedrock, Vertex AI
- **8 host-detected** — DeepSeek, xAI, Fireworks, Baseten, Novita, BytePlus, vLLM, and any OpenAI-compatible API via `base_url`
- **10 framework integrations** — LangChain, LangGraph, CrewAI, AutoGen, Instructor, LlamaIndex, LiteLLM, DSPy, Pydantic AI, OpenAI Agents
- **Error Diagnosis (beta)** — LLM-powered root cause analysis with fix suggestions; auto-apply not yet wired (see "Error Diagnosis" section below)
- **13 built-in scorers** — Faithfulness, relevance, toxicity, hallucination, and more
- **Streaming support** — Full streaming trace enrichment with token counts
- **OpenTelemetry bridge** — Compatible with existing OTel pipelines
- **Non-blocking** — All telemetry is async, never slows your app

## LLM Providers

```python
# Auto-patching (default) — detects installed providers automatically
risicare.init(api_key="rsk-...", endpoint="https://ingest.risicare.ai")

# Disable auto-patching if needed
risicare.init(api_key="rsk-...", endpoint="https://ingest.risicare.ai", auto_patch=False)
```

All 12 native providers:

| Provider | Package | Provider | Package |
|----------|---------|----------|---------|
| OpenAI | `openai` | Anthropic | `anthropic` |
| Google Gemini | `google-generativeai` | Mistral | `mistralai` |
| Cohere | `cohere` | Groq | `groq` |
| Together AI | `together` | Ollama | `ollama` |
| AWS Bedrock | `boto3` | Google Vertex AI | `google-cloud-aiplatform` |
| Cerebras | `cerebras-cloud-sdk` | HuggingFace | `huggingface-hub` |

Plus 8 auto-detected via OpenAI `base_url`: DeepSeek, xAI, Fireworks, Baseten, Novita, BytePlus, vLLM, and any OpenAI-compatible API.

## Framework Integrations

```bash
pip install risicare[langchain]    # LangChain + LangGraph
pip install risicare[crewai]       # CrewAI
pip install risicare[autogen]      # AutoGen
pip install risicare[instructor]   # Instructor
pip install risicare[litellm]      # LiteLLM
pip install risicare[dspy]         # DSPy
pip install risicare[pydantic-ai]  # Pydantic AI
pip install risicare[llamaindex]   # LlamaIndex
pip install risicare[all]          # Everything
```

## Core API

```python
import risicare

risicare.init(api_key, endpoint)            # Initialize (auto-patches providers)
risicare.shutdown(timeout_ms=5000)          # Flush pending spans and close

@risicare.agent(name="my-agent")            # Trace a function with agent identity
@risicare.trace                             # Trace any function (decorator or CM)
@risicare.session(session_id="sess-1")      # Group traces into user sessions

risicare.report_error(exception)            # Report caught errors for diagnosis
risicare.score(trace_id, "quality", 0.92)   # Record evaluation score [0.0-1.0]

risicare.enable() / risicare.disable()      # Runtime tracing control
risicare.is_enabled()                       # Check tracing status
```

## Decision Phases

Structure your traces to see how your agent thinks, decides, and acts:

```python
@risicare.agent(name="planner")
def plan(query: str):
    @risicare.trace_think
    def analyze():
        return llm.chat("Analyze this query...")

    @risicare.trace_decide
    def choose_action(analysis):
        return llm.chat("Pick the best action...")

    @risicare.trace_act
    def execute(action):
        return run_tool(action)

    analysis = analyze()
    action = choose_action(analysis)
    return execute(action)
```

## Error Diagnosis

> **Beta status (2026-05):** detect → diagnose → suggest is shipped and runs against
> Together.AI Llama-3.3-70B with a circuit-breaker / template-only fallback. Suggested
> fixes land in your dashboard as `status=draft` for human review. Automatic
> deployment, A/B rollout, and learning-from-outcomes (stages 4–6 in our docs) are
> in development and not yet wired in production. Treat this as **AI-assisted
> error diagnosis** today; auto-apply will follow.

When your agent fails, Risicare:

1. **Classifies** the error (154 codes across TOOL, MEMORY, REASONING, OUTPUT, etc.)
2. **Diagnoses** the root cause using AI analysis
3. **Generates** a fix suggestion you can review in the dashboard and apply manually

```python
try:
    result = my_agent(user_input)
except Exception as e:
    risicare.report_error(e)  # Triggers diagnosis pipeline; fix lands as draft for review
```

## Fix application is off by default

**Since 0.4.0, FixRuntime starts only when you opt in.** FixRuntime reads the
active fixes for your project from Risicare and applies them to your LLM calls.
A fix can change a prompt, a parameter, a tool, the retry or fallback behaviour,
a guard, or the model routing. Through 0.3.0, FixRuntime started automatically
when you set an API key.

When FixRuntime is off, the SDK does not request `/fixes/active`, and it does
not change your LLM calls. Tracing, error reporting and scores are not affected.

To opt in:

```python
risicare.init(api_key="rsk-...", fix_runtime=True)
# or set RISICARE_FIX_RUNTIME=true
```

When FixRuntime is on, the SDK requests the active fixes during `init()` and
then every 60 seconds. The `fix_runtime` argument has priority over the environment variable.

## Scoring & Evaluation

```python
# Custom scores
risicare.score(trace_id="tr-123", name="quality", value=0.92)

# 13 built-in scorers, runnable from the dashboard or POST /v1/evaluations:
#   RAG      faithfulness, answer_relevancy, context_precision,
#            context_recall, hallucination
#   Safety   toxicity, bias, pii_leakage
#   Agent    task_completion, tool_correctness, goal_accuracy
#   General  g_eval, factuality
```

## OpenTelemetry

```bash
pip install risicare[otel]
```

```python
risicare.init(api_key="rsk-...", otel_bridge=True)
# Compatible with any OTel-instrumented application
```

## Known limitation — span loss during a backend outage

The SDK does **not** currently survive a sustained outage of the Risicare
backend, and the loss is silent to your application (it is logged, but nothing
raises and `flush()` will not fail your request path).

The HTTP exporter opens a circuit breaker after **5 consecutive failed export
calls** and holds it open for **60 seconds**, returning failure immediately
without touching the network. Queued spans get 3 re-queue attempts, which against
an open breaker resolve in microseconds — so they are dropped — and for the
remainder of the cooldown the SDK will not retry even after your backend is
healthy again.

Measured, for a 1,000-span cohort emitted during the outage:

| outage | delivered |
|--------|-----------|
| 4 s    | 1000 / 1000 |
| 5 s    | 500 / 1000 |
| 6 s +  | 0 / 1000 |

The thresholds are counted in **failed calls, not seconds** — where the 5th
consecutive failure falls in wall-clock time depends on your span rate and on how
fast your endpoint fails. Treat the table as one measured shape, not a constant.

Nothing is lost on a clean `shutdown()`, and short blips that stay under the
5-failure threshold are fully survivable. Tracked as `F-SDKBLIP-001`.

## A note on `debug=True`

`debug=True` attaches a **console exporter** in addition to any HTTP exporter.
That exporter writes every span attribute to **stdout with no redaction** — the
SDK performs none of its own, so prompts, completions and anything else you put
in attributes go to your console verbatim. It is a local-development switch, not
a diagnostic one.

If you are debugging a delivery problem ("spans are NOT reaching ..."), raise the
SDK's logger instead. This prints the HTTP status and transport error and does
**not** print span payloads:

```python
import logging
logging.getLogger("risicare").setLevel(logging.DEBUG)
```

Measured for a failing export: the logger surfaces the transport error and emits
no span payload, while `debug=True` emits the payload and **no** HTTP status.

## Requirements

- Python 3.10+

## Documentation

- [Full docs](https://risicare.ai/docs)
- [Quickstart guide](https://risicare.ai/docs/start/quickstart)
- [Python SDK reference](https://risicare.ai/docs/reference/sdk)
- [LLM providers](https://risicare.ai/docs/instrument/providers)
- [Error Diagnosis](https://risicare.ai/docs/heal)
- [Evaluations](https://risicare.ai/docs/observe/evaluations)
- [JS/TS SDK](https://www.npmjs.com/package/risicare)

## Support

- **Email**: support@risicare.ai
- **Docs**: [risicare.ai/docs](https://risicare.ai/docs)

During the public beta, please file detailed reproduction steps for any
SDK or platform issue — fast feedback shapes GA.

## License

**Proprietary. You need a commercial licence.** See [LICENSE](LICENSE).

Conscience Labs Pvt. Ltd. owns this SDK. You need an active, paid
subscription to use it. You may not change it, make derivative works from
it, reverse engineer it, or redistribute it. Contact <info@consciencelabs.ai>.
