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
- SDK (
nexusobserve) — callrecord_decision()inside the agent. - Collector (
nexus-collector) — FastAPI + SQLite; receives and stores records. - 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
Metadata
Release files for nexusobserve 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nexusobserve-0.1.0.tar.gz | 7.9 kB | Without provenance | Details for nexusobserve-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nexusobserve-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nexusobserve-0.1.0-py3-none-any.whl |
Total release size: 16.2 kB
Release files / nexusobserve-0.1.0.tar.gz
| Download URL | nexusobserve-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
125e6f2b37f5f60e36a2179a06728e8c43fd8794f6e099fc811e106dab317c38
|
|
BLAKE2b-256 checksum How to use checksums |
2c3d5ef7f7a6fb689cc166be439556a6e71f6586b9b68bbea2a98657c5aa884b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / nexusobserve-0.1.0-py3-none-any.whl
| Download URL | nexusobserve-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90ff2afe8508432962c0e2666e38ed856162ec7f4109e263a18481745bbe7168
|
|
BLAKE2b-256 checksum How to use checksums |
a729e4ed0405a8a9eec9e0d7d8ac44c588f685c46e4311fea91523f4b51a0a44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for nexusobserve 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.