Skip to main content
Glama

sensorium

Record one run of your program, then let a coding agent ask what actually happened: call trees, exceptions, and where a value came from, answered from the trace or refused.

A failing checkout, three queries, no edits. item_weight returned 1800 grams and shipping_cost took that number as weight_kg.

$ sensorium run -- pytest examples/test_shipping.py -q
F                                                                        [100%]
E       AssertionError: assert 5569.0 == 74.5
run: 20261116-104837-c926b7

$ sensorium exceptions last
raised (1):
  e30 RAISE   test_order_total_for_a_mug_and_kettle raise AssertionError("assert 5569.0 == 74.5\n +  where 5569.0 = order_total([{'name': 'mug', 'price': 12.0, 'grams': 400}, {'name': 'kettle', 'price': 49.0, 'grams': 1800}])") L10
    propagated (handler not in traced code)

$ sensorium flow last --value 1800
  e22 CALL    item_weight(item=dict[3]={'name': 'kettle', 'price': 49.0, 'grams': 1800})   [arg item.grams]
  e23 RETURN  item_weight -> 1800   [return]
  e24 CALL    shipping_cost(weight_kg=1800)   [arg weight_kg]
sightings: 6 event(s), 6 capture(s)

$ sensorium refocus last --focus examples.shipping:shipping_cost --compact
refocus verdict: MATCH -- every recorded thread produced the identical CALL/RETURN/RAISE/HANDLED sequence

From a clone, with sensorium and pytest on PATH:

sensorium run -- pytest examples/test_shipping.py -q

Event ids move when the program does; last is the newest trace. The bug lives in examples/shipping.py.

What Sensorium is

Sensorium records one run (every call, return, and exception, with captured values) into a SQLite trace, and answers debugging questions from that trace in plain text. Four recorders write trace format 4. One command line, sensorium, reads all four.

  • Python: sensorium run -- <command> uses PEP 669 (sys.monitoring). Python 3.12+, no runtime dependencies. A Python child (subprocess, multiprocessing, pytest-xdist) is recorded into that same run. --no-children or SENSORIUM_NO_CHILDREN=1 records the parent only. A non-Python child is counted and not traced.

  • Rust: cargo sensorium test or cargo sensorium run. Stable rustc, Linux. rust/README.md.

  • TypeScript: sensorium ts run [--focus <spec>]… -- vitest run … or -- node --test …. Node 24, vitest 4.1. typescript/README.md.

  • C: sensorium c run -- <cmd> for a Linux x86-64 debug build (gcc or clang, -O0 or -Og). c/README.md.

A query refuses by name when a recorder lacks a capability.

Two commitments run through all of it. The instrument never answers from data it does not have: truncated captures are marked, sites a predicate could not be evaluated at are counted, a recording that died is labelled, and a rerun that was a different execution says so. Nothing here guesses. Every answer is a deterministic function of the recorded trace, and where the trace cannot settle a question the output says so instead of inferring. refocus is the one command that executes anything: it re-runs the program and says whether what came back was the same execution. The per-command limits are docs/claims.md.

Related MCP server: backscroll

Answers from the trace, or refuses

Sensorium never guesses why a test failed. A well formed question whose recording cannot settle it is refused by name.

  • REFUSED. Printed REFUSED: ... when a capability is missing, and refocus verdict: REFUSED -- <run> was recorded and is queryable, but it could NOT be verified against <run>: treat it as a separate, UNVERIFIED execution when a rerun could not be checked. diff prints verdict: REFUSED -- cannot issue a MATCH/DIVERGED verdict. Re-record.

  • NOTHING WAS CHECKED. watch prints verdict: NOTHING WAS CHECKED -- the predicate could not be evaluated at any of the N recorded site(s) when no site had the names the predicate needs. The next line is 'hits: 0' here means 'could not evaluate', NOT 'the invariant held'.

  • DIVERGED. Two runs took different paths. diff prints verdict: DIVERGED at causal step N. refocus prints refocus verdict: DIVERGED -- .... The new trace is queryable and is a different execution.

Exit 3 means change the recording. Exit 2 means fix the call. Details: docs/claims.md.

Quickstart (Python 3.12+)

pip install sensorium-trace pytest
sensorium run -- pytest tests/test_something.py
sensorium exceptions last

uv tool install sensorium-trace puts the same sensorium command on PATH. Run these from your project root, in an environment that can import your code.

Connect your agent (MCP)

Use the absolute path to your project venv's sensorium. --allow-run lets the agent record and rerun; leave it off for read-only.

Cursor, .cursor/mcp.json, and Claude Desktop, claude_desktop_config.json:

{
  "mcpServers": {
    "sensorium": {
      "command": "/abs/path/to/project/.venv/bin/sensorium",
      "args": ["mcp", "--allow-run"]
    }
  }
}

VS Code, .vscode/mcp.json:

{
  "servers": {
    "sensorium": {
      "type": "stdio",
      "command": "${workspaceFolder}/.venv/bin/sensorium",
      "args": ["mcp", "--allow-run"]
    }
  }
}

Claude Code:

claude mcp add sensorium -- /abs/path/to/project/.venv/bin/sensorium mcp --allow-run

sensorium mcp serves the same store on stdio. Every query except redact is a tool. record, refocus, and record_c exist only with --allow-run. Tools, the result header, the cap, and the audit file: docs/mcp.md.

How this differs from live debuggers and LLM tracing

  • Live debuggers over MCP (DAP-based servers) make the agent step through a paused process, one breakpoint at a time. Sensorium records the whole run once, and the agent queries it afterward, as often as it likes, with stable event ids.

  • LLM tracing (LangSmith, Langfuse and similar) records the model's prompts and tool calls. Sensorium records the program under test: its calls, returns, exceptions and values.

  • Not sensorium-mcp. andriyshevchenko/sensorium-mcp is an unrelated Telegram and memory agent that shares the name.

Install

Python 3.12+. The CLI command is sensorium. The name sensorium on PyPI and npm is an unrelated project; these packages publish as sensorium-trace.

pip install sensorium-trace
uv tool install sensorium-trace

Rust recorder (Linux, rustc 1.96+):

cargo install cargo-sensorium

TypeScript recorder (Node 24):

npm install sensorium-trace

Published on PyPI, crates.io and npm; Linux binaries for cargo-sensorium are on GitHub Releases. The import and the CLI stay sensorium. The npm package is the recorder library; traces still report recorder: sensorium-ts.

From git:

uv venv .venv && uv pip install -p .venv/bin/python "sensorium-trace @ git+https://github.com/bricelancasterwcp-sudo/sensorium"

Dev checkout: uv venv .venv && uv pip install -p .venv/bin/python -e ".[dev]". Details: docs/install.md.

The recorder is sys.monitoring and nothing else, so on 3.11 it refuses to start. Witnessing a multiprocessing spawn needs the _posixsubprocess.fork_exec audit event, which arrived in 3.14. Below that, such a spawn is unwitnessed, and refocus says so by withholding the "no child process witnessed" line (docs/claims.md).

Commands

sensorium run -- pytest tests/test_fog.py
sensorium runs
sensorium info last
sensorium tree last --depth 3
sensorium frame last --fn compute
sensorium grep last compute --kind RETURN
sensorium exceptions last
sensorium failures last
sensorium flow last --value 1800
sensorium flow last --object build_key:record
sensorium diff RUN_A RUN_B
sensorium refocus last --focus fog:compute
sensorium redact --all --dry-run
sensorium mcp --allow-run

Per-line state is opt-in: sensorium run --focus fog:compute -- ..., then sensorium watch last --at fog:compute --expr '...'. Asked without that --focus, watch reports NOTHING WAS CHECKED and prints the re-record command. It does not report zero hits.

Traces land in ~/.sensorium/traces (or $SENSORIUM_DIR/traces), one SQLite file per run. Rust, TypeScript, and C write to the same directory, so one runs lists all four. A run reference is a full id, a unique prefix, or last. Events are eN and frames are fN, and those ids stay stable, so an answer from one command is an argument to the next. --fn matches a qualname exactly first, then as a substring, and refuses when more than one name matches. Asyncio frames, --window, and flow --object: docs/use.md.

Rust, TypeScript, and C

  • Rust. rust/ ships sensorium-rt 0.7.3, sensorium-transform 0.5.2, and cargo-sensorium 0.8.4. cargo install cargo-sensorium, then cargo sensorium test or cargo sensorium run from a workspace. Linux, stable rustc. Panics show up in failures. rust/README.md. What it does not see: rust/HONESTY.md.

  • TypeScript. typescript/ ships sensorium-ts 0.6.2. A trace reports recorder: sensorium-ts. Node 24. From a checkout, npm ci --prefix typescript, then sensorium ts run -- vitest run … or sensorium ts run -- node --test …. A shell-free npm test that runs vitest or node --test is expanded. jest is refused by name (no jest transformer). Inline vitest project objects are instrumented; a project named by a string or glob is refused. for await inside a function is recorded; top-level await is not. typescript/README.md.

  • C. sensorium c run -- <cmd> records a Linux x86-64 debug build (-O0 or -Og, gcc or clang). Crashes are what exceptions reads. c/README.md.

Recording follows code under the working directory the run started in, so sensorium run -- pytest ... traces your tests and your code, and not pytest's. --focus module:qualname adds line-level capture for the named code. --window QUALNAME limits that capture to what runs inside one function. The fog.py examples in docs/use.md were run as typed.

Exit statuses

The exit status is the caller's next action, not a health code:

exit

meaning

examples

0

the question was answered affirmatively. The trace says yes

grep found a match; refocus MATCH; watch SATISFIED

1

the question was answered negatively. The trace says no, or none

grep matches: 0; exceptions no exceptions recorded; refocus DIVERGED

2

the call is wrong, edit the command and ask again

an ambiguous --fn; --nth out of range; a run reference that resolves to nothing; refocus refusing before any rerun was attempted

3

the trace cannot settle it, change the recording and re-record

watch NOTHING WAS CHECKED; refocus REFUSED after a rerun; exceptions' uncaught-without-RAISE arm; exceptions on a Rust trace whose recorder predates err flow (recorder sensorium-rt 0.2.0 declares it does not produce (capabilities.err_flow: false))

run exits with the target's own status. It never applies this table to itself.

Every invocation is appended to <trace root>/invocations.jsonl (default ~/.sensorium/invocations.jsonl, or under $SENSORIUM_DIR) as one JSON line with utc, argv, exit and error (the exception class name or null) and nothing else: never the environment, never the working directory. Set SENSORIUM_NO_INVOCATION_LOG to any non-empty value other than 0 to turn it off for one process, =0 leaves logging on. The same branch is docs/agent.md.

For agents

Install, record one run, query it, serve it over MCP: ten steps in docs/agent.md. After install, prove the path with .venv/bin/python -m pytest tests/test_agent_smoke.py -q.

Agent skill

skills/sensorium/SKILL.md is an Agent Skills file (name: sensorium). It tells an agent, when a test fails or output is wrong in Python, Rust, TypeScript, or C, to record one run and query the trace on the CLI or over MCP.

sensorium skill show
sensorium skill install
sensorium skill install --user --target claude

install copies that file. If a destination already exists, nothing is written unless --force is passed. With no --target it writes both .claude/skills/sensorium/SKILL.md (Claude Code: .claude/skills/ in the project, ~/.claude/skills/ for --user) and .agents/skills/sensorium/SKILL.md (Codex reads .agents/skills from the working directory up to the repo root, and ~/.agents/skills for a user skill). --target cursor, --target codex, and --target agents write the .agents/skills path. --target claude writes only the Claude Code path. A path argument is the skill directory itself. Cursor install guides also name .cursor/skills/<name>/, and older Codex pages still say .codex/skills/; pass that directory as a path to use it. The wheel ships the same file at sensorium/_skill/SKILL.md.

What the answers claim

Sensorium reports; the agent reading it reasons. Nothing in an answer is inferred from data the trace does not hold.

  • diff compares the shape of two runs, (file, qualname, kind), not their values. A pure move reads DIVERGED unless --ignore-moves can pair the name uniquely.

  • refocus re-runs, then issues MATCH, DIVERGED, or REFUSED. The licence lists only the checks that ran. A check that could not run withholds the licence. Exit 2 means nothing was re-run.

  • tree derives parentage from the caller frame, not from "the last frame on this thread".

  • exceptions claims SWALLOWED only when the recording establishes it. Anything short of that is ambiguous, with the reason printed.

  • watch never reads zero hits as "the invariant held". A site it could not evaluate is counted.

  • flow is lineage over captured values, not static dataflow.

  • info labels an INCOMPLETE recording and does not print a 0 as proof that nothing happened.

The full wording is docs/claims.md. exceptions, watch, flow, and Rust refocus in detail are docs/query.md.

What a trace holds, and what it does not see

A trace holds the process environment (minus what rule v1 withheld), stdout and stderr, the command line, source digests, and captured values. It does not see children by an unlisted mechanism, non-Python threads, files the program read, code outside the run root, the clock, or the network. Treat a trace as a core dump. docs/visibility.md. Redaction: docs/redaction.md.

Overhead

Recording overhead and read-back cost are docs/overhead.md. Measured with python corpus/run_corpus.py --bench. The headline: 2.9× on the corpus's typical workloads, up to 194× on the call-dense one under --focus. Record failing tests, never benchmarks.

Corpus

python corpus/run_corpus.py                          # verify against seeded bugs
python corpus/run_corpus.py --show                   # print the questions and commands
python corpus/run_corpus.py --bench                  # report recording overhead
python corpus/run_corpus.py --require-driver         # a skipped Rust or TypeScript case is exit 1
python corpus/run_corpus.py --via mcp --compare-cli  # every tool question through the MCP server, diffed against the CLI

Small programs with planted bugs, and questions registered before any output was looked at. 115 cases and 253 questions. A case whose recorder is not built is reported skipped by name. --bench reports; it never gates. Case by case: docs/corpus.md.

Not yet

What each slice deferred, and the ruling each deferral is waiting on, is docs/CARRIED-DEBT.md.

License

MIT, see LICENSE. Copyright © 2026 Brice Lancaster.

Versions after the Proprietary interlude are again under MIT (matching releases through 0.14.0).

Also

Available Tools

10 tools
diffdiffB
Read-onlyIdempotent

first causal divergence between two runs. Aligns the two causal streams and names the first event where they part, with drill-in commands; MATCH or DIVERGED, or REFUSED when no verdict exists.

Inputs: run_a (required), run_b (required), task, context, +1 more.

exceptionsexceptionsA
Read-onlyIdempotent

raises, handles, swallows. Every raise classified swallowed, uncaught, re-raised, propagated or ambiguous, with the reason; SWALLOWED is claimed only when the recording proves it.

Inputs: run, after, limit.

failuresfailuresA
Read-onlyIdempotent

failed tests and the frame they failed in. Each failed test mapped to the frame and the assertion, panic or exception recorded there. A vitest expect, a Rust panic, and a C crash or assert in a test_ frame are listed here; exceptions still judges throw and Err flow and does not list them.

Inputs: run, limit.

flowflowA
Read-onlyIdempotent

provenance of a value or an object. --value follows a literal by equality through captured arguments, locals and returns; --object follows one identity from the event that captured it; one of the two is required, and each refuses by name what the recording did not capture.

Inputs: run, after, limit, value, +1 more.

frameframeA
Read-onlyIdempotent

one activation in full. Arguments, return or raise, and the per-line locals timeline when the run was recorded with --focus; frame ids fN come from exceptions, tree and grep.

Inputs: fn, nth, run, frame.

grepgrepA
Read-onlyIdempotent

search events by name or value. Every CALL, RETURN, RAISE, HANDLED or LINE event whose name or rendered value contains the pattern; --after resumes from an event id a previous answer showed.

Inputs: pattern (required), fn, run, kind, +2 more.

infoinfoA
Read-onlyIdempotent

summarize one trace. Recorder, language, the capabilities the trace declares, what was recorded and what was not, focus, the redaction stamp; read it before any other question on a run.

Inputs: run.

runsrunsA
Read-onlyIdempotent

list recorded traces. One line per trace, oldest first: run id, exit, event count, the command; a refocus rerun names its original and its verdict.

Inputs: no named parameters.

treetreeA
Read-onlyIdempotent

call-tree slice. Parentage derived from the event stream; --around centres the slice on an event id, --root on a frame id; nested dict contents are elided, frame prints them.

Inputs: run, root, depth, limit, +1 more.

watchwatchA
Read-onlyIdempotent

predicate over captured state. A gdb-style watchpoint evaluated after the fact at every recorded site of one function; needs a --focus recording, and NOTHING WAS CHECKED is a refusal, never a pass.

Inputs: at (required), expr (required), run, after, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool targets a distinct trace-analysis question: listing runs, summarizing a trace, searching events, inspecting frames/trees, following provenance, classifying exceptions, mapping failed tests, comparing runs, and evaluating watch predicates. The exceptions/failures boundary is explicitly clarified, and flow/frame/tree are differentiated by their scopes.

    Naming Consistency4/5

    All names are lowercase single tokens with no mixed casing or underscores, giving a consistent surface style. However, they mix singular nouns, plurals (runs, exceptions, failures), and imperative verbs (grep, watch), so the convention is not fully uniform.

    Tool Count5/5

    Ten tools is well-scoped for a trace-analysis server, and each tool maps to a meaningful investigation step rather than duplicating another. The set is neither thin nor bloated.

    Completeness5/5

    The surface covers the full trace-analysis lifecycle: discovery (runs, info), navigation (grep, tree, frame), provenance (flow), error analysis (exceptions, failures), comparison (diff), and state monitoring (watch). No obvious workflow dead ends are apparent.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Local MCP server that lets your AI coding agent query its own cross-tool project history - file/command freshness, past test failures, cost & token spend, cache status, and session handoff - over stdio, 100% local, no telemetry.
      62
      -
    • A
      license
      A
      quality
      C
      maintenance
      Records your terminal sessions per command (PTY + OSC 133) into local SQLite, so AI agents can search, retrieve, and diff what commands actually printed. Secret redaction is applied by default to everything served over MCP.
      4
      7
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A local-first MCP server that gives AI coding agents runtime visibility and AI-managed debug logging. It replaces blind print() debugging by turning runtime execution into causal chains, allowing agents to instantly locate bugs by finding missing .success events in Python and TypeScript code. Single binary with MCP, CLI, and HTTP interfaces.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables local-first observability for MCP agent workflows by recording tool calls, prompts, latency, and token usage in a local SQLite database, and provides tools for inspecting, comparing, exporting, and generating dashboards from traces.
      13
      69 npm
      MIT