Skip to main content

modelmri-record

Record what your agent actually did — LLM calls, tool calls, subagents, errors — and look at it on a timeline instead of scrolling logs.

pip install modelmri-record

Stdlib only. No torch, no numpy, no SDK pins. Instrumenting an agent shouldn't cost you a 2.5 GB install.

Use

from modelmri_record import trace, step

with trace("fix-failing-tests"):
    step("llm_call", name="plan", input=prompt, output=answer,
         duration_ms=1200, tokens_in=900, tokens_out=200)

    with step("subagent", name="test-runner"):
        step("tool_call", name="pytest", input="-q", output="3 failed")

Nesting is automatic — a step used as a context manager becomes the parent of everything recorded inside it, and its duration is measured for you.

Auto-instrument an SDK instead:

from modelmri_record import instrument_anthropic
instrument_anthropic()      # every Messages.create is now an llm_call step

Where traces go

POSTed to a running ModelMRI viewer on http://127.0.0.1:5900. If nothing is listening, they're written to ./modelmri-traces/*.json to import later — so you can record on a box that has no viewer and look at it somewhere else.

To view them: pip install modelmri && modelmri serve.

Credentials are redacted by default

Agent prompts routinely contain the key the agent was handed. A recorder that writes those to disk verbatim is a liability dressed as an observability feature, so redaction is on unless you switch it off:

with trace("run"):                      # default scrubber
with trace("run", redact=my_function)   # your own str -> str
with trace("run", redact=False)         # verbatim, deliberately

Covered: sk-…, hf_…, pypi-…, ghp_…/github_pat_…, xoxb-…, Google AIza…, AWS key ids, Bearer …, and whole PEM private-key blocks.

Patterns are deliberately narrow — known credential shapes, not "anything high-entropy". A redactor that eats hashes and UUIDs makes traces useless, and a useless trace gets the feature turned off, which protects nobody. Add your own shapes:

from modelmri_record.redact import make_redactor
red = make_redactor([r"ACME-[0-9]{6}"])

It will not take down your app

Recording is best-effort by contract. If the viewer is unreachable, the disk is read-only, or the payload won't serialise, it gives up quietly. A tracing library that can raise is one nobody leaves switched on.

Traces still open when the process exits are flushed by an atexit hook — a crash or a SIGTERM is exactly the run you most wanted to look at.

Licence

MIT. Part of ModelMRI.

Metadata

Release files for modelmri-record 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelmri-record 0.1.4
File Size Uploaded
modelmri_record-0.1.4.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modelmri-record 0.1.4
File Interpreter ABI Platform
modelmri_record-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 25.6 kB

Release files / modelmri_record-0.1.4.tar.gz

Download URL modelmri_record-0.1.4.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d664f3100cd7e1e222647c1a075d2334f0e3cefcf06181d0046a3818f3c7401c
BLAKE2b-256 checksum
How to use checksums
fe576bbc18745c204d9753b2f7aa0cb6510757c2ace1988e72d59f471ff38caf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / modelmri_record-0.1.4-py3-none-any.whl

Download URL modelmri_record-0.1.4-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4a76113f187c2fe7fda707992b91061b935bcbce6c388c9274ba060e3ba2329
BLAKE2b-256 checksum
How to use checksums
07b1a3d2e83b9b443f2bfea0dbb958fc0c6cf411053c79d340a187d8548fce27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.4 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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