Skip to main content

promptmin

PyPI version License: MIT

Prompt minimizer for LLM evals — shrink a prompt to the smallest input that still reproduces a failure using delta debugging (ddmin).

Why?

  • Fast debugging: minimal repros beat 300-line prompts
  • Cheaper CI: fewer tokens, fewer moving parts
  • Safer iteration: smaller diffs, clearer "what changed"
  • Handles flakiness: stability modes (strict / k-of-n) and --confirm-final

Installation

This package is a Python wrapper that shells out to the promptmin Node CLI.

# 1. Install the CLI
npm install -g promptmin

# 2. Install the Python wrapper
pip install promptmin

Usage

Python API

from promptmin import minimize

result = minimize(
    prompt_path="prompts/support.md",
    config_path="promptmin.config.json",
    target="test:refund_policy_01",
    budget_runs=60
)

print(f"Minimized: {result.minimized_path}")
print(f"Report: {result.report_path}")

CLI

promptmin-py minimize \
  --prompt prompts/support.md \
  --config promptmin.config.json \
  --target test:refund_policy_01 \
  --budget-runs 60

Config example

{
  "runner": {
    "type": "openai_responses",
    "model": "gpt-4.1-mini"
  },
  "tests": [{
    "id": "refund_policy_01",
    "input": { "user": "Can I get a refund?" },
    "assert": { "type": "regex_not_match", "pattern": "competitor" }
  }]
}

Requires OPENAI_API_KEY for the openai_responses runner, or use local_command to run your own eval script.

Artifacts

After minimization, you get:

  • baseline.prompt / minimized.prompt — before and after
  • diff.patch — what was removed
  • report.md / meta.json — summary and metadata

Options

Flag Description
--strategy ddmin (default) or greedy
--granularity sections, blocks, sentences, or lines
--stability-mode strict or kofn for flaky tests
--confirm-final Re-verify the final minimized prompt
--no-trace-output Disable trace logging (for sensitive prompts)

Links

License

MIT

Metadata

Release files for promptmin 1.0.2

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

Source distribution (sdist)

Source distribution for promptmin 1.0.2
File Size Uploaded
promptmin-1.0.2.tar.gz 4.5 kB Details

Built distribution (wheel)

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

Total release size: 9.6 kB

Release files / promptmin-1.0.2.tar.gz

Download URL promptmin-1.0.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8cb4bb315aecb6bf0cbd8c9cd229bb86b7a0542cb00be4802805284469e5fd6d
BLAKE2b-256 checksum
How to use checksums
6add468e6e6e1642ce4eeead12ea4a677b7b5990efcb2676921161ae46fcbc4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / promptmin-1.0.2-py3-none-any.whl

Download URL promptmin-1.0.2-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab527321a7f684ba4879052506bb5f676a6c879ed5de57c6c1627cd40c5a4e9f
BLAKE2b-256 checksum
How to use checksums
7cf205cc6ab4766817ee21cc8fdae452dad8696535864848ff0c6e7bbdbf1162
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

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