---
name: rewrite
description: Use Pain in the Agent when the user asks to rewrite or humanize prose, compare a rewrite, or check AI writing signals. Do not trigger for every writing task.
---

Use the supplied text only. The hosted service receives it and stores it under
https://painintheagent.com/privacy/. Do not gather additional files or include
secrets. If no text was provided, ask which draft to process.

Call `get_limits` when the account allowance or input size is uncertain. The
account's character balance is shared by the rewrite tools across the website, API and MCP; detector checks are free with a separate daily limit. Do not split an oversized document
or launch a batch without the user asking for that scope.

To remove a watermark without humanizing, call `start_rewrite` once. Full paid runs include one meaning check
by a second model; it reports warnings without editing the rewrite. Free runs skip this check
(`review_method` is `not_run`). `slop_removal` is accepted for compatibility and has
no effect; to remove formulaic AI phrasing use `start_humanize`. For the remote server, generate a UUID
`run_id` before the call and reuse it for the same input after a lost response.
The local package generates its own ID; save the returned `run_id` and keep
that local MCP process running. Remote jobs continue after disconnecting.
For a watermark-free AI rewrite, use `start_humanize` with text and run_id.
Watermark-free rewriting is always included; optional `watermark_removal` remains
accepted for compatibility. For source comparison, use `start_watermark_comparison` with
source_text, candidate_text and run_id. For AI writing signals, use
`start_ai_detection` with text and run_id; it needs at least 80 words of English
or Russian. Rewrites spend characters from the account balance; comparison and AI detection use the
separate free daily limit. The published local
package exposes rewriting; use remote MCP for the additional operations.

Check `get_result` (or `get_rewrite`) after the suggested interval, normally 15 seconds. Status
reads do not start model work or consume rewrite quota.

If a connection fails, retrieve the same ID. Never automatically submit the
text under a new ID. An interrupted run may not have a saved result. Explain
that outcome before deciding whether another run is appropriate.

Return the rewritten text and any fidelity notes. For paid `start_rewrite`, `review_method: model` describes
an attempted meaning check. Inspect `review_status`: `unavailable` means it did not finish reliably, even if
`review` is empty. `not_run` means no check was attempted, including in older saved results. A successful check
can still miss errors. Compare claims, conditions and numbers with the source
before replacing a file or publishing. The Humanizer replaces the wording
throughout, the strongest available removal approach supported by published
SynthID research. Best effort: the ChatGPT, Claude and Gemini watermark detectors are
not public, so complete removal cannot be verified. A rewrite
is not evidence of authorship.
AI detection results (`ai_assessment`) carry `origin`, a trained classifier's
0-100 score and decision band calibrated on a balanced research sample; it is
not a share of AI-written words or proof of authorship, and an unavailable
score stays null. They also list explicit writing patterns: quoted passages
with explanations plus literal wording matches, and
`ai_assessment.coverage.percent`, the share of source words inside those
highlights. Humanize results carry the same detector twice: `ai_assessment`
for the input and `ai_assessment_after` for the returned text, plus
`deep_passes`. The Watermark-free AI Humanizer rewrites highlighted passages
first and replaces wording throughout while the score stays high. Every Humanizer run rewrites the text and
spends characters; only a result identical to the input (`review_method` `exact_match`, `charged` false)
is free.
`comparison_metrics` contains measured word counts, stock phrases and word
5-gram novelty for rewrites and comparisons. Keep its method version when
reporting the figures. These fields need no additional processing run.

The remote MCP endpoint is https://painintheagent.com/mcp. Interactive clients
can use its OAuth discovery and ask the user to sign in and select permissions.
For an agent claim flow, read https://painintheagent.com/auth.md; the user must
enter the claim code and approve on the service-owned page. Do not approve on
the user's behalf. Connections and keys are managed at
https://painintheagent.com/integrations/.

For key-based access, the operator supplies
`PAININTHEAGENT_API_KEY` through the client's environment or secret settings.
Do not request a key in chat, print it, or write it to a project file. Respect
`PAININTHEAGENT_BASE_URL` when an API gateway is configured; failures must not
cause a fallback to a different endpoint or credential.
