# Prompt cleanup

> Two lossless reductions ACOG makes to requests: whitespace and invisible-character cleanup, and removal of duplicated retrieval chunks.

Product: AI Cost Optimizer Gateway (ACOG). Web version: https://tessarac.com/docs/acog/optimize/request-cleanup. Last updated: 2026-10-16.

Input tokens are billed whether or not they carry meaning. ACOG removes two kinds that do not.

## Prompt simplification

Collapses redundant whitespace and removes invisible characters (zero-width spaces and similar) from message text. It never rewrites, paraphrases or removes any of your words, and leaves code blocks untouched, because whitespace there can matter.

On by default. Turn it off under **Admin → Gateway settings → Prompt simplification**.

## Duplicate retrieval chunks

Retrieval pipelines often pass the same passage more than once. When a later chunk in a message's content array, or in a top-level `documents` or `context` array, repeats an earlier one exactly or up to whitespace, ACOG drops the repeat and keeps the first occurrence in place. What the request asks for does not change.

## When they run

Both run on requests from active organizations (not in [pass-through](https://tessarac.com/docs/acog/get-started/how-acog-saves-money.md#pass-through-mode)), on the compatible endpoints and the native routes alike, wherever ACOG can read the request body as a conversation. A body it cannot read that way is forwarded exactly as sent.
