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.

Download files

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

Source Distribution

modelmri_record-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

modelmri_record-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelmri_record-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for modelmri_record-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c3400df6b1f9face60a303c6a2d1d4e6b9c7d15ee51d1b79008a461539558d3
MD5 f1c95dd29de711f2b4cadaccb61a8419
BLAKE2b-256 24e799e19fddcca93f401329112274f0902ab9b8bad50d5a8999fbde0c6f265c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modelmri_record-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for modelmri_record-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 925cabaa8ef6552d2ed6108261d146a0cadaa891121af2fb6829c4ca591152d1
MD5 375b119d43588ec9804d85d60a1a7a1c
BLAKE2b-256 3d1c2e9a16dbd12545d4b6d42b44a87dcd9b4fad856e630aec5303d783ed201f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page