Task: make a given text score "Human" on Pangram 4 while keeping its facts
You are an agent with shell access, an LLM you can call for rewrites, and a Pangram API key. Follow this process exactly. Do not skip the scoring steps: every edit decision must be made by Pangram's score, never by your own judgement of what "sounds human". Your judgement of that is wrong for this detector.
Inputs
INPUT_TEXT: the text to transform (works best at 80 to 200 words; split longer texts into sections of that size and run each separately).PANGRAM_API_KEYBUDGET: maximum scoring calls (default 150). One call costs one credit per 400 words.
The scoring call
POST https://text.external-api.pangram.com/task with header x-api-key: <key>, JSON body {"text": <text>, "model": "pangram-4"}. The response contains task_id. Poll GET https://text.external-api.pangram.com/task/<task_id> every 2 seconds until stage is STAGE_SUCCESS. From that response take:
- prediction_short: "AI", "Mixed" or "Human". The goal is "Human".
- windows[]: each has ai_assistance_score from 0 to 1. Define SCORE = the maximum ai_assistance_score across windows. Lower is better. Empirically, "Human" needs SCORE at or below about 0.35.
Cache every result keyed by the exact text. Identical text always returns an identical score, so never score the same string twice.
Rules that hold throughout
- Never paraphrase a sentence you are not currently testing. Every sentence outside the one being replaced stays byte-for-byte identical.
- Never add typos, slang, fragments everywhere, lowercase, or "casual" filler. Those raise the score and trigger a separate humanizer detector.
- Never delete a concrete fact (a number, a named thing, a timeframe, an outcome). Opinions, lessons, attributions and summaries may be deleted.
- Never insert unicode tricks (zero-width characters, homoglyphs). They are normalised away.
Step 1: baseline
Split INPUT_TEXT into sentences, keeping paragraph boundaries. If there is a greeting line, keep it as is. Score the full text. Record SCORE_0. If prediction_short is already "Human", stop and output the text.
Step 2: classify sentences (one LLM call, no scoring cost)
Ask the rewrite LLM which sentences contain no concrete fact (no number, named thing, part, timeframe or outcome) and only report, attribute, generalise, evaluate or conclude. Those are DELETABLE.
Step 3: rank sentences by deletion impact (n scoring calls, done once)
For each sentence i, build the text with sentence i removed and score it. Sort sentences by the resulting score, lowest first. This ranking is reused in later rounds; do not recompute it every round (see Step 5 for the one case where you do).
Step 4: delete what can be deleted (no extra scoring calls)
Walk the ranking. Delete every DELETABLE sentence whose deletion score is below the current SCORE, re-scoring the running text after each deletion. These scores were already paid for in Step 3, so this step is almost free. Stop if prediction_short becomes "Human".
Step 5: replace, one sentence at a time, chosen by score
Keep a counter per sentence of consecutive rounds with no accepted edit. Repeat until prediction_short is "Human" or BUDGET is exhausted:
1. ACTIVE = the first 4 sentences in the ranking that still exist and have a counter below 2.
2. For each ACTIVE sentence, ask the rewrite LLM for exactly three alternatives using the CANDIDATE PROMPT below, giving it the full current text and the sentence.
3. Substitute each alternative into the full text and score all three.
4. Accept the lowest-scoring alternative only if it is lower than the current SCORE; reset that sentence's counter. Otherwise leave the sentence unchanged and increment its counter.
5. At the end of the round, if SCORE fell by less than 0.05 over the whole round, or if ACTIVE was empty, the ranking is stale: recompute Step 3 once and reset all counters. On a 130-word text this happens about once per run and is what unlocks the sentences the first ranking underrated.
Step 6: finish
If the text is a message or email and has no sign-off, append a two-line sign-off ("Cheers" then a first name) and score once more. Keep it only if SCORE did not rise. Output: the final text, its SCORE and prediction_short, the number of scoring calls used, and a list of every accepted edit (original sentence, replacement, score before, score after).
CANDIDATE PROMPT (send verbatim to the rewrite LLM, followed by the full text and the target sentence)
You rewrite ONE sentence from a text. Output exactly 3 alternative versions of that sentence, one per line, no numbering, no commentary. Every version must keep the same concrete facts (numbers, named parts, timeframes, outcomes) and still fit the surrounding text: 1. a short main clause with the facts attached in parentheses, e.g. "They fixed the faults (loose ridge pointing, a leaking vent flashing)." 2. a version under eight words, dropping any opinion but keeping the facts. 3. a version with no reporting, attribution or evaluating verb (no "found", "said", "told", "saw", "suggested", "mattered", "my view is") and no word like "overall", "key", "real", "important". Do not add casual filler, slang, typos, or extra hedging. Do not change the other sentences.
Expected outcome
Measured on two 130-word texts, with a check that the five-candidate, re-rank-every-round version reaches the same label: - GPT-5.5 roof email, 0.997: 68 scoring calls to 0.170 "Human" (the earlier version needed 127 to reach 0.251). - Restaurant email, 0.834: 22 scoring calls to 0.345 "Human" (the earlier version needed 78 to reach 0.152). At $0.05 per 100 words billed in 100-word units, that is $2 to $7 per 130-word text. Expect 20 to 70 calls per 130 words; the cost scales with word count and sentence count, so split texts over 200 words into sections and run each separately. The quality cost is unchanged: one to three sentences in the output will be terser than the original (a parenthetical, a noun-phrase list, or a telegraphic opener). If the text must read naturally, add a readability check that rejects a candidate before it is scored; that roughly doubles the calls.