Skip to main content

Drop-in trust enforcement for AI agent frameworks — LangChain, CrewAI, OpenAI, and more

Project description

datops-agent-sdk

Drop-in trust enforcement for AI agent frameworks — LangChain, CrewAI, OpenAI, and more.

Add DatOps trust-gated execution to your existing AI agent in 2 lines of code. Every tool call is authorized against the agent's live trust score, sandboxed by risk level, and reported as a trust signal — no Docker, no Redis, no infrastructure changes.

Install

pip install datops-agent-sdk

With framework extras:

pip install datops-agent-sdk[langchain]   # LangChain support
pip install datops-agent-sdk[crewai]      # CrewAI support
pip install datops-agent-sdk[openai]      # OpenAI Agents SDK support
pip install datops-agent-sdk[all]         # All frameworks

Quick Start

LangChain

from datops_agent import DatOps

agent = DatOps.wrap_langchain(my_agent, api_key="dat_xxx")
agent.invoke({"input": "search for flights to NYC"})

CrewAI

from datops_agent import DatOps

crew = DatOps.wrap_crewai(my_crew, api_key="dat_xxx")
crew.kickoff()

OpenAI Agents SDK

from datops_agent import DatOps

agent = DatOps.wrap_openai(my_agent, api_key="dat_xxx")

Generic (any framework)

from datops_agent import DatOps

datops = DatOps(api_key="dat_xxx")

@datops.trust_gate(risk_level="medium")
def search_web(query: str) -> str:
    return requests.get(f"https://api.search.com?q={query}").text

# Tool call is now trust-gated
result = search_web("weather in NYC")

How It Works

Your Agent Code
      │
      ▼
┌─────────────┐
│  DatOps SDK  │  ← 2 lines of code
├─────────────┤
│  Pre-check   │  Is this tool allowed at this trust level?
│  Execute     │  Run the tool
│  Post-report │  Report success/failure as trust signal
└─────────────┘
      │
      ▼
  DatOps Platform (trust score, reputation, sandbox level)

Before each tool call:

  • Fetch the agent's trust score (cached, 60s TTL)
  • Map score to sandbox level: STRICT (0-30), ADAPTIVE (30-70), OPEN (70-100)
  • Check if the tool's risk level is allowed in the current sandbox
  • Block execution if trust is too low

After each tool call:

  • Report success or failure as a trust signal (fire-and-forget)
  • Signals feed back into the agent's reputation score

Sandbox Levels

Trust Score Sandbox Allowed Risk Levels
0 - 30 STRICT Low only
30 - 70 ADAPTIVE Low + Medium
70 - 100 OPEN All (Low/Medium/High)

New agents start at trust score 50 (ADAPTIVE). As the agent demonstrates reliability, its trust grows and more tools become available.

Configuration

datops = DatOps(
    api_key="dat_xxx",                          # Required
    base_url="https://www.datops.ai",           # Platform URL
    agent_name="my-agent",                      # Display name
    network="testnet",                          # testnet | mainnet
    trust_cache_ttl=60,                         # Cache trust score (seconds)
    heartbeat_interval=300,                     # Heartbeat interval (seconds)
    min_trust_for_tool=10.0,                    # Minimum trust to use any tool
    trust_threshold_high_risk=70.0,             # Minimum trust for high-risk tools
    persist_identity="~/.datops/identity.json", # Persist agent DID across restarts
    auto_initialize=True,                       # Auto-register on first use
    debug=False,                                # Enable debug logging
)

Risk Levels

Assign risk levels to control which sandbox levels can execute each tool:

@datops.trust_gate(risk_level="low")
def read_file(path: str) -> str:
    """Low risk — available in all sandbox levels."""
    ...

@datops.trust_gate(risk_level="medium")
def search_web(query: str) -> str:
    """Medium risk — requires ADAPTIVE or OPEN sandbox."""
    ...

@datops.trust_gate(risk_level="high")
def send_email(to: str, body: str) -> str:
    """High risk — requires OPEN sandbox (trust >= 70)."""
    ...

For framework adapters, set per-tool risk levels:

# CrewAI
crew = DatOps.wrap_crewai(
    my_crew,
    api_key="dat_xxx",
    tool_risk_levels={
        "search_tool": "low",
        "email_tool": "high",
    },
)

# OpenAI
agent = DatOps.wrap_openai(
    my_agent,
    api_key="dat_xxx",
    tool_risk_levels={
        "web_search": "medium",
        "send_email": "high",
    },
)

Error Handling

from datops_agent import DatOps, ToolBlockedError

datops = DatOps(api_key="dat_xxx")

@datops.trust_gate(risk_level="high")
def dangerous_tool():
    ...

try:
    dangerous_tool()
except ToolBlockedError as e:
    print(f"Blocked: {e.reason}")
    print(f"Trust: {e.trust_score}, Sandbox: {e.sandbox_level}")

Inspecting Trust State

datops = DatOps(api_key="dat_xxx")

# Current trust score
print(datops.trust_score)  # 55.0

# Sandbox info
info = datops.get_sandbox_info()
print(info)
# {'trust_score': 55.0, 'sandbox_level': 'ADAPTIVE', 'allowed_risk_levels': ['low', 'medium']}

# Agent DID
print(datops.did)  # did:dat:testnet:agent_abc123

# Force refresh
score = datops.get_trust_score(force_refresh=True)

Context Manager

with DatOps(api_key="dat_xxx") as datops:
    @datops.trust_gate(risk_level="medium")
    def my_tool():
        return "result"

    my_tool()
# Heartbeat stopped, resources cleaned up

Identity Persistence

By default, the SDK generates a new agent DID on each startup. To persist identity across restarts:

datops = DatOps(
    api_key="dat_xxx",
    persist_identity="~/.datops/identity.json",
)

The identity file stores the agent's DID, API key, and trust state. It's created with chmod 600 (owner read/write only).

Architecture

datops_agent/
  __init__.py          # DatOps class (public API)
  core.py              # Registration, trust cache, signal reporting
  trust_gate.py        # Pre/post tool call middleware
  cache.py             # Thread-safe TTL cache (no Redis)
  heartbeat.py         # Background daemon thread
  types.py             # Enums, dataclasses, exceptions
  adapters/
    langchain.py       # LangChain CallbackHandler
    crewai.py          # CrewAI tool wrapping
    openai_sdk.py      # OpenAI SDK tool wrapping
    generic.py         # Decorator pattern

No Redis. No Docker. No infrastructure. Pure Python with requests as the only dependency.

Development

git clone https://github.com/datops-ai/agent-sdk-python.git
cd agent-sdk-python
pip install -e ".[dev]"
pytest tests/ -v

License

MIT

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

datops_agent_sdk-0.1.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datops_agent_sdk-0.1.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file datops_agent_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: datops_agent_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for datops_agent_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0c7940ab36ec53d0a737c431903a681b6fba7057417cb8ad8e177567cc5eaee
MD5 34d655534f5f35aa9dca96ff9cd3cbeb
BLAKE2b-256 4ed611e4063d6e35ce6f334e2dcd9c22c4067552efcb32cd3909637a3a11e3c8

See more details on using hashes here.

File details

Details for the file datops_agent_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datops_agent_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d233beb01613e42d34c938dfaab128d56ff46942eb4b7a7c38d6ca6d211d13c
MD5 3b78e77d54a49d989db027e7e01a1b7c
BLAKE2b-256 35fa98f909459a8127684c8fdb8d3af16718ba258813f382c9a3919fba16ee0c

See more details on using hashes here.

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