Skip to main content

pymmary

Build Status Coverage PyPI

Agent-optimized output compressor for Python tooling.

Status: alpha. The pytest adapter is the only one so far.

Why

Python tools write for humans: progress indicators, a full traceback per problem, colour codes, a summary table. When an AI agent runs one of those tools, it pays for all of it. A green run of a thousand tests tells the agent one thing ("everything passed") and charges thousands of tokens to say it.

Pymmary detects that a coding agent is running the tool and replaces that output with compact JSON. Outside an agent, nothing changes: no agent detected, no compression, byte-identical output for humans.

It is a decision of the project, not of the agent's environment. Add it as a dev dependency and any agent that clones the repo and runs your tools benefits, with no per-machine setup.

Adapters

Each tool gets its own adapter, its own extra, and its own page. The payload speaks that tool's vocabulary rather than a normalized one, so the details live with the adapter:

Tool Install Docs
pytest pymmary[pytest] pytest adapter

Planned: mypy, then unittest.

Features

  • Automatic agent detection via environment variables, no configuration
  • Strict no-op fallback: no agent, no change to output
  • One shared envelope across adapters, with a payload in each tool's own vocabulary
  • Zero runtime dependencies in the core; each adapter ships behind its own extra
  • Hooks into the host tool's native extension points, no global monkey-patching

Requirements

  • Python 3.10+

Adapters add their own, listed on each adapter page.

Installation

pip install pymmary

With an adapter:

pip install pymmary[pytest]

Nothing to wire up after that. Adapters register themselves through the host tool's own plugin mechanism, so installing as a dev dependency is the whole setup.

The envelope

Every adapter emits these four keys, so an agent recognizes any pymmary output at a glance:

Key Meaning
tool Which tool produced this
result "passed" / "failed", the one-word verdict
duration Seconds, float, rounded to 3 decimals
summary Counts, in the host tool's own outcome vocabulary

Adapters add top-level keys where their tool has more to say. The pytest adapter adds exit_code and failures, for example, and a green suite of 1002 tests comes out as one line:

{"tool":"pytest","result":"passed","exit_code":0,"duration":0.32,"summary":{"collected":1002,"passed":1002}}

Two rules hold across every adapter:

  • result follows the tool's exit code, never our own tally. A run that broke before it could report anything is never called a pass.
  • summary uses the tool's own words. pytest counts passed and xfailed, mypy counts errors and notes. Normalizing them would throw away the thing that makes the payload useful.

Agent detection

Agent Signal
Claude Code CLAUDECODE set to any non-empty value
Cursor CURSOR_TRACE_ID set to any non-empty value
Devin TERM_PROGRAM=Devin exactly
Gemini CLI any variable starting with GEMINI_CLI_

Anything else, plain shells and generic CI included, falls through and leaves output untouched. No TTY checks, no parent-process inspection, no network.

Configuration

Two environment variables, no config file and no CLI flags:

Variable Effect
PYMMARY_FORCE=1 Compress even when no agent is detected, useful to see what an agent sees
PYMMARY_MAX_FAILURES=N How many problems to spell out. Default 20; 0 keeps every one of them

The cap is about diminishing returns, not size: an agent facing 400 failures fixes a handful and runs again, so the rest cost context and buy nothing. summary always counts the whole run, and whatever was left out is declared in failures_omitted.

How much it saves

Tokens, not bytes, since tokens are what an agent pays for. On pytest output the saving runs from 1.6× to 28× depending on the shape of the run: best on large green suites, worst on suites with many failures, since failure bodies barely compress. The full table and the method are on the pytest adapter page.

Related

Companion to pyssertive (assert phase) and pyrrange (arrange phase). Pymmary covers the report phase, for AI consumers.

Inspired by laravel/pao, the PHP original.

License

MIT

Metadata

Release files for pymmary 0.2.0

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

Source distribution (sdist)

Source distribution for pymmary 0.2.0
File Size Uploaded
pymmary-0.2.0.tar.gz 19.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymmary 0.2.0
File Interpreter ABI Platform
pymmary-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / pymmary-0.2.0.tar.gz

Download URL pymmary-0.2.0.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
018f31864fda6bfba17a2b9290b73e9292f674d744ddd9f43174707607564712
BLAKE2b-256 checksum
How to use checksums
b53d246336bc632442d86228e2681827fe4ceb564f19cfe0112eb12677ac86ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / pymmary-0.2.0-py3-none-any.whl

Download URL pymmary-0.2.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0a0aa5997376e6c159663e5dbe17e228ef472b77f90d13ef7cef71da86862f8
BLAKE2b-256 checksum
How to use checksums
914c434eca11821b7fd137047d31add47dd1cd0e826e51f7afc62069de735a86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.0 This release

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