Skip to main content

Catch brittle prompts before production does — brittleness score and CI gate for LLM prompts under paraphrase

Project description

prompt-shield

Catch brittle prompts before production does.

prompt-shield runs your LLM function against semantically-equivalent paraphrases of your test inputs. If outputs diverge, your prompt is brittle — and production will find it before you do.

Install

pip install prompt-shield

Quick Start

from prompt_shield import BrittlenessRunner

def my_llm(user_input: str) -> str:
    return call_my_llm(user_input)  # your LLM function

runner = BrittlenessRunner(llm_function=my_llm)
result = runner.run(
    test_inputs=["What is the return policy?"],
    prompt_name="support_prompt",
)

print(result.verdict)   # ROBUST / CONDITIONAL / BRITTLE
print(result.score)     # BrittlenessScore (0.0–1.0)
print(result.certificate.to_markdown())

Three Stress Levels

Based on Matthew 7:24-27 (Two Builders) — three storm vectors:

Level Vector Example
lexical Rain — synonym substitution "What is" → "What's the meaning of"
syntactic Streams — structural transformation "What is X?" → "Tell me about X"
semantic Wind — full meaning reformulation "How do I cancel?" → "I'd like to end my subscription"

CLI

# Run audit
shield run --config shield.yaml

# CI gate (exit 0 = pass, 1 = brittle)
shield ci --config shield.yaml

# History
shield report --store ./shield.db

Verdicts

Verdict BrittlenessScore Meaning
ROBUST ≤ 0.15 Prompt handles paraphrase variation
CONDITIONAL 0.15–0.30 Some sensitivity — review fault lines
BRITTLE > 0.30 Prompt relies on surface form — fix before deploying

Biblical Pattern

PAT-048 (Daniel 5:25-28 — TEKEL): The prompt is weighed on the scales. PAT-049 (Matthew 7:24-27 — Two Builders): Three storm levels stress-test every prompt. PAT-050 (Proverbs 17:3 — The Crucible): The BrittleCertificate is the crucible output.

License

MIT

Project details


Download files

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

Source Distribution

prompt_brittleness-0.1.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

prompt_brittleness-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prompt_brittleness-0.1.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for prompt_brittleness-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8e6faa8c391ed283c85490f6a430dec0f583e1359ca4d4d01615c7fb3804a05
MD5 477b55953ef2398fd09dd124bbcc7fc0
BLAKE2b-256 e3476574dad60671b201d26d1ce5009b1c5ba5711573cb50d20989acd0987732

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prompt_brittleness-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c5b36dfcc9fa9a2d9ccec2a24823dff392ef615fd702dd780bec4267f5ee1ba
MD5 eebd92f1a8c8fbd242b999be77c52cf9
BLAKE2b-256 7e344378a09d3fb279fc3e1cd8727d41b832f153e79e7c09105e402b4f0f58eb

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