Skip to main content

nexusobserve

Instrument AI agents to capture chosen + discarded alternatives + opportunity cost at every decision point. Then replay any discarded alternative to diff the outcome — without executing side-effects.

pip install nexusobserve

Quickstart

from nexusobserve import record_decision

rec = record_decision(
    run_id="run-123",
    context={"order_id": "ORD-1042", "amount": 500, "customer_tier": "gold"},
    chosen={"action": "full_refund", "cost": 500},
    alternatives=[
        {"action": "escalate",       "cost": 120},
        {"action": "partial_refund", "cost": 200},
        {"action": "deny+coupon",    "cost": 30},
    ],
    latency_ms=12.3,
    replay_payload={
        "tools": [
            {"name": "order_lookup",  "type": "query",       "inputs": {...}, "outputs": {...}},
            {"name": "refund_execute","type": "side_effect",  "inputs": {...}},
        ]
    },
    server_url="http://localhost:8000",  # optional — POSTs to Nexus Collector
)

# Opportunity cost of each discarded alternative (pure math, no LLM)
for opp in rec.opportunity_costs():
    print(opp)  # {"action": "escalate", "cost": 120, "opportunity_cost": -380}

How it works

  1. SDK (nexusobserve) — call record_decision() inside the agent.
  2. Collector (nexus-collector) — FastAPI + SQLite; receives and stores records.
  3. Dashboard Lite — React force-graph; click a discarded alternative → see the replay diff.

The contracts/schema.py DecisionRecord is the single source of truth shared by all three layers.

replay_payload conventions

# Multi-tool list (preferred)
replay_payload = {
    "tools": [
        {"name": "lookup",  "type": "query",       "inputs": {...}, "outputs": {...}},
        {"name": "execute", "type": "side_effect",  "inputs": {...}},
    ]
}

# Single-tool shorthand (backward-compat)
replay_payload = {"tool": "policy_engine", "inputs": {...}, "outputs": {...}}

Side-effect tools are never re-executed during replay — they are marked SIMULATED. Query tools return their recorded outputs.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexusobserve-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

nexusobserve-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nexusobserve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 125e6f2b37f5f60e36a2179a06728e8c43fd8794f6e099fc811e106dab317c38
MD5 6c7af18bcd220808ba8e112dd959da34
BLAKE2b-256 2c3d5ef7f7a6fb689cc166be439556a6e71f6586b9b68bbea2a98657c5aa884b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nexusobserve-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for nexusobserve-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90ff2afe8508432962c0e2666e38ed856162ec7f4109e263a18481745bbe7168
MD5 1273aae883a2dec8e95006c1a0c0ccfd
BLAKE2b-256 a729e4ed0405a8a9eec9e0d7d8ac44c588f685c46e4311fea91523f4b51a0a44

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page