pymmary
Agent-optimized output compressor for Python tooling.
Status: early development. The pytest adapter works; nothing is published to PyPI yet.
Why
When an AI agent runs pytest, it pays for output written for humans — progress dots, a full traceback per failure, colour codes, a summary table. 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 pytest benefits, with no per-machine setup.
Features
- Automatic agent detection via environment variables — no configuration
- Strict no-op fallback: no agent, no change to output
- Compact JSON keyed by pytest
nodeid, so failures are pasteable straight back into the CLI - 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+
- pytest 9.1+ (optional, for
pymmary[pytest])
Installation
pip install pymmary
With the pytest adapter:
pip install pymmary[pytest]
Usage
Nothing to wire up. Install it as a dev dependency and run your tools as usual — when a supported agent is detected, output is compressed.
pytest
{"tool":"pytest","result":"passed","exit_code":0,"duration":0.32,"summary":{"collected":1002,"passed":1002}}
On failure, only what the agent needs to act:
{
"tool": "pytest",
"result": "failed",
"exit_code": 1,
"duration": 0.32,
"summary": { "collected": 1002, "passed": 999, "failed": 2, "error": 1 },
"failures": [
{
"nodeid": "tests/test_api.py::TestAuth::test_login[user-2]",
"phase": "call",
"file": "tests/test_api.py",
"line": 42,
"type": "AssertionError",
"message": "assert 401 == 200"
}
]
}
A run that fails to collect is never reported as a pass — the verdict follows pytest's exit code, not our own tally:
{"tool":"pytest","result":"failed","exit_code":2,"duration":0.008,"summary":{"error":1},"failures":[{"nodeid":"test_broken.py","phase":"collect","file":"test_broken.py","line":1,"type":"ModuleNotFoundError","message":"No module named 'requests'"}]}
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 failures 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. On a 400-failure suite: 98,671 bytes of human output, 56,826 uncapped, 2,900 by default.
Limitations
- pytest-xdist: pymmary stands down completely under
-n, leaving normal pytest output. The controller never runs the tests itself, so a compressed summary would count none of them. Aggregating the worker streams is planned. - pytest 9.1 is a hard floor. The adapter unregisters pytest's terminal reporter to own the output. Before 9.1, pytest built assertion explanations through
config.get_terminal_writer(), which asserts that reporter is still registered — so on older versions everyassertfailure degrades to a bareAssertionErrorpointing into pytest's internals. That is the one payload this library exists to produce, so the floor is enforced rather than worked around.
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. Pymmary keeps its envelope recognizable but speaks pytest's own vocabulary rather than PHPUnit's.
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 pymmary-0.1.0.tar.gz.
File metadata
- Download URL: pymmary-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13dbf8a438485b28fddb6ceaa243f6f81dff1ffa96e56e00b98182a22cd41953
|
|
| MD5 |
ed50fd581eb5c15cb381b90865b6fb93
|
|
| BLAKE2b-256 |
6957c8f74d039b64ba8e4cd05e0b226818e3338f3a9623b7bdab3ffbd6e9e87d
|
Provenance
The following attestation bundles were made for pymmary-0.1.0.tar.gz:
Publisher:
release.yml on othercodes/pymmary
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymmary-0.1.0.tar.gz -
Subject digest:
13dbf8a438485b28fddb6ceaa243f6f81dff1ffa96e56e00b98182a22cd41953 - Sigstore transparency entry: 2356549266
- Sigstore integration time:
-
Permalink:
othercodes/pymmary@a3e700ba6d487d7249a9a6c44e574ae65a5ec3c1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/othercodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a3e700ba6d487d7249a9a6c44e574ae65a5ec3c1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymmary-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymmary-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4d33bf05f04f2c9b8f9637c97a0ec20d251ce25fa41d6003a2deb6731777143
|
|
| MD5 |
a3c582e36400b96f9514e7f99a95cfe0
|
|
| BLAKE2b-256 |
36bc136aec279c587bf42618f4be87aa82385e832285cd20ddc2f76e0f7121bf
|
Provenance
The following attestation bundles were made for pymmary-0.1.0-py3-none-any.whl:
Publisher:
release.yml on othercodes/pymmary
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymmary-0.1.0-py3-none-any.whl -
Subject digest:
c4d33bf05f04f2c9b8f9637c97a0ec20d251ce25fa41d6003a2deb6731777143 - Sigstore transparency entry: 2356549293
- Sigstore integration time:
-
Permalink:
othercodes/pymmary@a3e700ba6d487d7249a9a6c44e574ae65a5ec3c1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/othercodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a3e700ba6d487d7249a9a6c44e574ae65a5ec3c1 -
Trigger Event:
push
-
Statement type: