PRODUCTION SCENARIO
Your customer-chat backend runs on the server-side compaction beta. After the first compaction the app stores the returned summary in its own database, keeps sending the full original message history, and drops the compaction block from messages. Requests keep hitting the context limit.
What must the backend change?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: Append the response, including the compaction block, to messages so earlier blocks are ignored
The compaction block is the marker that tells the API to ignore every content block before it, so it has to travel back with later requests, most simply by appending the entire response content to messages. Storing the summary elsewhere while resending the original history leaves the prompt exactly as long as it was, and the trigger cannot be set below 50,000 tokens.
Official Source: https://platform.claude.com/docs/en/build-with-claude/compaction ↗