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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
125e6f2b37f5f60e36a2179a06728e8c43fd8794f6e099fc811e106dab317c38
|
|
| MD5 |
6c7af18bcd220808ba8e112dd959da34
|
|
| BLAKE2b-256 |
2c3d5ef7f7a6fb689cc166be439556a6e71f6586b9b68bbea2a98657c5aa884b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90ff2afe8508432962c0e2666e38ed856162ec7f4109e263a18481745bbe7168
|
|
| MD5 |
1273aae883a2dec8e95006c1a0c0ccfd
|
|
| BLAKE2b-256 |
a729e4ed0405a8a9eec9e0d7d8ac44c588f685c46e4311fea91523f4b51a0a44
|