---
title: 압축 개요
url: https://platform.claude.com/docs/ko/build-with-claude/compaction
description: 압축의 기능, 온디맨드 압축과 토큰 임계값 기반 압축의 차이점, 그리고 작업에 맞는 페이지를 알아보세요.
---

"Compaction"(압축)은 대화의 오래된 턴을 Claude가 서버에서 작성한 요약으로 대체하므로, 요약 코드를 직접 작성할 필요가 없습니다. 압축은 긴 대화나 에이전트 작업이 "context window"(컨텍스트 윈도우) 안에 머물도록 하며, 대화가 길어질수록 응답 품질이 저하되므로 활성 컨텍스트를 작게 유지해 줍니다.

이 개요를 건너뛰려면 [온디맨드 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand)부터 시작하여 애플리케이션에 압축을 추가하세요. 온디맨드 압축과 [토큰 임계값 기반 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold)은 모두 베타 단계이지만, 온디맨드 압축이 더 일반적인 사용 사례를 다룹니다. 오래된 도구 결과나 오래된 사고 블록을 요약하는 대신 규칙에 따라 지우려면 [컨텍스트 편집](https://platform.claude.com/docs/ko/build-with-claude/context-editing)을 참조하세요.

## 압축 방식 선택하기

온디맨드 압축을 사용할 수 있는 경우에는 항상 온디맨드 압축을 사용하세요.

|                                                                                                                 | [온디맨드 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand)                                                                             | [토큰 임계값 기반 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold)                                                                                                                        | 자체 요약기([클라이언트에서 압축](https://platform.claude.com/docs/ko/build-with-claude/preserved-thinking#custom-compaction-on-the-client)) |
| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **압축 시점을 결정하는 주체**                                                                                              | 사용자(요청을 보내는 방식)                                                                                                                                                   | API(입력 토큰이 설정한 트리거에 도달할 때)                                                                                                                                                                                        | 사용자                                                                                                                            |
| **작성해야 하는 코드**                                                                                                  | 요약을 요청하고 이를 교체해 넣는 [압축 루프](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#compact-in-a-loop)                                          | 일반 요청에 추가하는 매개변수 하나                                                                                                                                                                                               | 요약 호출, 해당 프롬프트, 기록 재작성                                                                                                         |
| **이후 다시 보내는 내용**                                                                                                | 반환된 블록을 요약 대상 메시지 대신 `messages`의 맨 앞에 배치                                                                                                                          | 평소처럼 응답을 추가합니다. 블록 이전의 내용은 API가 삭제합니다                                                                                                                                                                             | 직접 작성한 메시지 형태의 요약                                                                                                              |
| **최근 턴을 원문 그대로 유지**                                                                                             | 예: [최근 턴을 유지하는 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-keep-recent-turns)                                                            | 예, [압축 후 일시 중지](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#pausing-after-compaction)한 뒤 해당 턴을 다시 삽입하는 방식으로 가능                                                                     | 예                                                                                                                              |
| **백그라운드 실행**                                                                                                    | 예: [백그라운드 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-background)                                                                        | 아니요: 임계값에 도달한 요청 내에서 실행됩니다                                                                                                                                                                                        | 예, 자체 코드에서 실행                                                                                                                  |
| **유지된 턴의 사고 보존**([보존된 사고](https://platform.claude.com/docs/ko/build-with-claude/preserved-thinking)를 지원하는 모델에서) | 예, [압축과 보존된 사고](https://platform.claude.com/docs/ko/build-with-claude/compaction-thinking-blocks)에 설명된 조건에서 가능                                                    | 아니요: Claude Fable 5.1, Claude Opus 5.5, Claude Sonnet 5.5, Claude Haiku 5.5에서는 다시 삽입하는 턴의 사고를 제거하거나 삭제해야 합니다([임계값 압축 예제](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#examples) 참조) | 아니요: 해당 사고는 [검사를 통과하지 못합니다](https://platform.claude.com/docs/ko/build-with-claude/preserved-thinking#keep-tail-compaction)     |
| **베타 헤더, 매개변수, 플랫폼**                                                                                            | `compact-2026-09-04` 및 최상위 `compaction` 매개변수. 플랫폼: [온디맨드 호환성 목록](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#compatibility)을 참조하세요 | [임계값 호환성 목록](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#compatibility) 및 [기본 사용법](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#basic-usage)을 참조하세요  | 없음. 자체 코드에서 실행됩니다                                                                                                              |
| **선택해야 하는 경우**                                                                                                  | 애플리케이션이 압축 시점을 제어해야 하거나, 요약이 작성되는 동안 일시 중지할 수 없거나, 최근 턴과 그 사고를 유지해야 하는 경우                                                                                         | 일반 요청 내에서 API가 컨텍스트를 관리하기를 원하는 경우                                                                                                                                                                                 | 이미 자체 요약기를 운영하고 있으며, 그 요약기가 전체 기록을 요약으로 대체하는 경우                                                                                |

## 온디맨드 압축 옵션

[온디맨드 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand)은 애플리케이션이 대기하는 동안 전체 대화를 요약하는 루프를 보여줍니다. 이 목록의 처음 두 페이지는 해당 루프의 실행 방식을 변경하며, 둘을 함께 사용할 수 있습니다. 세 번째 페이지는 사고 블록을 다시 보내면서 둘 중 하나를 사용하는 경우에 해당합니다.

* [최근 턴을 유지하는 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-keep-recent-turns): 마지막 몇 개의 턴이 원문 그대로 Claude에 전달되어야 하는 경우. 요약은 오래된 턴만 다룹니다.
* [백그라운드 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-background): 요약을 위해 대화를 일시 중지할 수 없는 경우. 작업이 계속되는 동안 요청이 실행되며, 블록이 도착하면 교체해 넣습니다.
* [압축과 보존된 사고](https://platform.claude.com/docs/ko/build-with-claude/compaction-thinking-blocks): 보존된 사고를 지원하는 모델에서 사고 블록을 다시 보내면서 최근 턴을 유지하거나 백그라운드에서 압축하는 경우. 그렇지 않다면 건너뛰세요.
* [자체 요약 프롬프트 작성하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#write-your-own-summarization-prompt): 기본 요약이 이후 턴에 필요한 내용을 누락하는 경우. 사용자의 프롬프트가 기본 프롬프트를 대체합니다.
* [다시 압축하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#compact-again): 이미 압축 블록으로 시작하는 대화가 다시 길어지는 경우.

다음 주제는 다른 페이지에서 확인하세요:

* [요약 요청하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#request-a-summary)는 온디맨드 압축 페이지에 있습니다.
* [요약에서 이어서 진행하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#continue-from-the-summary)는 온디맨드 압축 페이지에 있습니다. 유지하는 턴에서 사고가 유효하게 유지되는 조건은 [압축과 보존된 사고](https://platform.claude.com/docs/ko/build-with-claude/compaction-thinking-blocks)에 있습니다.
* 요약이 반환되지 않는 경우: 온디맨드 압축 페이지의 [요약 누락 또는 오류 처리하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#when-no-summary-comes-back)를 참조하세요.
* API의 다른 부분과의 관계: 온디맨드 압축 페이지의 [제한 사항 및 다른 기능과의 상호작용](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#how-it-fits-with-the-rest-of-the-api)을 참조하세요.
* 사용량 이해하기: 온디맨드 압축의 경우 [압축 사용량 계산하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#understanding-usage)를, 임계값 압축의 경우 [사용량 이해하기](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#understanding-usage)를 참조하세요.
* 호환성: 각 방식마다 고유한 베타 헤더가 있으므로 각 페이지에 별도의 목록이 있습니다. [온디맨드 호환성 목록](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#compatibility) 또는 [임계값 호환성 목록](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#compatibility)을 참조하세요.

임계값 압축은 별도의 페이지에서 다룹니다: [토큰 임계값 기반 압축](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold).
