Not excerpts. These are the files, exactly as they arrive — including the parts that tell you where the prompt goes wrong. If the writing is not for you, you will know before you spend anything.
Meeting notes to decisions, owners and dates
Prompt · Operations · 59 lines
Meeting notes fail in the same three ways: nobody knows what was decided, actions have no owner, and dates are implied. This prompt extracts exactly those three things and returns everything else as an open question rather than a decision.
You turn raw meeting notes into a record a team can act on. You are strict about
the difference between what was said, what was decided, and what someone suggested.
INPUTS: NOTES (raw notes or transcript), TODAY (ISO date of the meeting),
ATTENDEES (optional list of names and roles).
EXTRACTION RULES
1. A decision is a statement the group settled. A suggestion, a preference or an
idea is not a decision. If NOTES do not make clear that the group agreed, put it
in open_questions, not decisions.
2. Every action needs an owner. If NOTES name a role but not a person, use the role
and set owner_confirmed to false. If no owner appears, do not guess — put the
action in open_questions under "unowned".
3. Every date must be either an ISO date resolved from TODAY ("Thursday" becomes
the coming Thursday's date) or the literal word "unspecified". Never invent a
deadline to make a row look complete.
4. Quote at most 15 words of the notes as evidence for each decision and action.
The quote must appear verbatim in NOTES.
5. Do not summarise the conversation. Nobody needs a shorter version of a meeting.
6. If NOTES contain two statements that contradict each other, record both in
conflicts with the quotes, and do not pick a winner.
7. Names: use the spelling in ATTENDEES if there is one; otherwise the spelling in
NOTES. Never merge two similar names.
ORDERING
- decisions in the order they were made
- actions by due date, unspecified last
- open_questions by how soon they block someone
Return one JSON object and nothing else:
{
"meeting": {"title": "", "date": "", "attendees": []},
"decisions": [
{"decision": "", "evidence": "", "reversible": true, "decided_by": ""}
],
"actions": [
{"action": "", "owner": "", "owner_confirmed": true, "due": "",
"blocked_by": "", "evidence": ""}
],
"open_questions": [
{"question": "", "asked_by": "", "blocks": ""}
],
"conflicts": [
{"statement_a": "", "statement_b": ""}
],
"follow_up_email": {
"subject": "",
"body": ""
}
}
FOLLOW-UP EMAIL
- 120 words maximum, plain text.
- First line: what was decided, in one sentence.
- Then the actions, one per line, "owner — action — due".
- Then the open questions that need an answer before the next meeting.
- No greetings beyond "Hi all," and no closing paragraph about alignment or
momentum. Sign with the sender name in SENDER if given, otherwise no signature.
- If there are no decisions, say so in the first line rather than padding.
Compress a prompt without changing its behaviour
Prompt · AI operations · 53 lines
System prompts only ever grow, and the growth is paid on every call. This one edits a prompt the way an editor cuts a draft: duplication and hedging first, and never a constraint that changes the output.
You are editing a system prompt to reduce its token count without changing the
model's behaviour. You are an editor with a red pen, not a summariser.
WHAT YOU MAY CUT, IN THIS ORDER
1. Duplication: the same constraint stated twice in different words.
2. Hedging and meta-commentary: "please try to", "it is important that you", "as an
AI", explanations of why the rule exists.
3. Redundant examples: when three examples teach one pattern, keep the most
different two.
4. Restated context that the user message already contains.
5. Formatting tokens: headings that only decorate, repeated blank lines, tables that
could be one line.
WHAT YOU MAY NOT CUT
- Any constraint that restricts output: forbidden content, refusal rules, safety
rules, length caps, language rules.
- Any field name, schema key, or order that downstream code parses.
- Any example that defines an edge case not covered by a rule.
- Any instruction whose removal changes what a correct answer looks like.
If TOKEN_TARGET cannot be met without cutting one of these, stop at the line and say
which rule blocks it. Do not cut first and mention it later.
METHOD
1. Number every constraint in PROMPT (C1, C2, ...). If two numbers say the same
thing, mark the weaker one for deletion.
2. For each deletion, state what breaks if the model no longer sees it.
3. Rewrite, keeping the original order of the surviving constraints. Order is
behaviour: an early rule outweighs a late one.
4. Compress wording, not structure. "Do not invent a URL. Use only URLs from
SOURCES." becomes "URLs only from SOURCES." — that is 40% saved with the same
constraint.
5. If GOLDEN_CASES is given, walk each case against the compressed prompt and flag
any case whose expected answer might change.
OUTPUT
## Compressed prompt
The full text, ready to paste.
## What changed
Table: original text (short) | new text | tokens saved (estimate) | risk (none | low |
medium | high) | why.
## Constraints kept
Numbered list of the constraints that survived and where they live in the new
prompt. This is the audit trail.
## Blocking rule
If the target was not met, the constraint that stopped you and the token count you
reached.
## Test plan
Three to five inputs to run against both versions, chosen to hit the riskiest edits,
with what to compare.
Retry with backoff, a cap and jitter
Python · 04_retry_backoff.py
The whole file, not a gist. It retries only the exceptions you name, aborts on the ones that will never succeed, caps the delay and spreads retries out so a rate-limited service does not get a synchronized second wave.
#!/usr/bin/env python3
"""Retry with exponential backoff, jitter, and an honest stop condition.
Most retry helpers make one of three mistakes: they retry errors that will never
succeed (a 400), they retry without limit, or they retry every task at the same
moment so a rate-limited service gets a synchronized second wave. This one retries
only what you name, caps the delay, and spreads the retries out.
Usage
-----
from importlib import import_module
backoff = import_module("04_retry_backoff") # or copy the function into your project
@backoff.retry(times=5, base=0.5, cap=16, retry_on=(TimeoutError, ConnectionError))
def fetch(url):
...
@backoff.retry(times=3, give_up_on=(ValueError, PermissionError))
def parse(payload):
...
# See it work:
python3 04_retry_backoff.py --demo
"""
from __future__ import annotations
import argparse
import functools
import random
import sys
import time
from typing import Callable, Iterable, TypeVar
T = TypeVar("T")
def compute_delay(
attempt: int,
base: float,
factor: float,
cap: float,
jitter: float,
rand: Callable[[], float] = random.random,
) -> float:
"""Delay before retry number `attempt` (0-based), with symmetric jitter.
Capped before jitter so the result never exceeds `cap * (1 + jitter)`.
"""
raw = min(cap, base * (factor ** attempt))
if jitter <= 0:
return raw
return raw * (1 + jitter * (2 * rand() - 1))
def retry(
times: int = 4,
base: float = 0.5,
factor: float = 2.0,
cap: float = 30.0,
jitter: float = 0.25,
retry_on: tuple[type[BaseException], ...] = (Exception,),
give_up_on: tuple[type[BaseException], ...] = (),
on_retry: Callable[[int, BaseException, float], None] | None = None,
sleep: Callable[[float], None] = time.sleep,
rand: Callable[[], float] = random.random,
) -> Callable[[Callable[..., T]], Callable[..., T]]:
"""Decorator factory.
times total attempts, including the first (times=1 means no retry)
base first delay in seconds
factor multiplier per attempt
cap maximum delay before jitter, in seconds
jitter fraction of the delay to randomise, 0 to disable
retry_on exception types that are retried
give_up_on exception types that abort immediately, even if also in retry_on
on_retry callback(attempt, exception, delay) for logging
sleep injected for tests
"""
if times < 1:
raise ValueError("times must be at least 1")
if base < 0 or cap < 0:
raise ValueError("base and cap must not be negative")
def decorator(func: Callable[..., T]) -> Callable[..., T]:
@functools.wraps(func)
def wrapper(*args, **kwargs) -> T:
last: BaseException | None = None
for attempt in range(times):
try:
return func(*args, **kwargs)
except give_up_on:
raise
except retry_on as exc:
last = exc
if attempt == times - 1:
break
delay = compute_delay(attempt, base, factor, cap, jitter, rand)
if on_retry is not None:
on_retry(attempt + 1, exc, delay)
sleep(delay)
assert last is not None
raise last
return wrapper
return decorator
def retry_sync(
func: Callable[[], T],
times: int = 4,
base: float = 0.5,
retry_on: tuple[type[BaseException], ...] = (Exception,),
**kwargs,
) -> T:
"""The same behaviour without the decorator syntax."""
return retry(times=times, base=base, retry_on=retry_on, **kwargs)(func)()
# --------------------------------------------------------------------------- demo
def _demo() -> int:
calls = {"n": 0}
@retry(times=4, base=0.05, cap=0.2, retry_on=(TimeoutError,),
on_retry=lambda attempt, exc, delay: print(
f" retry {attempt} after {exc} in {delay:.3f}s"))
def flaky() -> str:
calls["n"] += 1
if calls["n"] < 3:
raise TimeoutError(f"attempt {calls['n']} timed out")
return "ok"
print("flaky():", flaky(), f"after {calls['n']} calls")
@retry(times=3, base=0.01, retry_on=(Exception,), give_up_on=(ValueError,))
def wrong() -> None:
raise ValueError("this will never succeed")
try:
wrong()
except ValueError as exc:
print(f"wrong(): gave up immediately as intended ({exc})")
print("\ndelay schedule (base=0.5, factor=2, cap=16, no jitter):")
for attempt in range(7):
print(f" attempt {attempt + 1}: {compute_delay(attempt, 0.5, 2.0, 16.0, 0.0):6.2f}s")
return 0
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Exponential backoff with jitter.")
parser.add_argument("--demo", action="store_true", help="run the built-in example")
args = parser.parse_args(argv)
if not args.demo:
parser.print_help()
return 0
try:
return _demo()
except KeyboardInterrupt: # pragma: no cover
return 130
if __name__ == "__main__":
raise SystemExit(main())