---
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)의 조건 하에서                                                                              | 아니요: 다시 삽입하는 턴에서 사고를 제거하거나, `prefix_mismatch_behavior: "drop_block"`을 사용하여 API가 이를 삭제하도록 하세요([임계값 압축 예제](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` 매개변수. 플랫폼: [요청 시 압축 API 지원 섹션](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#availability-feature-support)을 참조하세요 | [임계값 압축 API 지원 섹션](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#availability-feature-support) 및 [기본 사용법](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)를 참조하세요.
* 호환성: 각 방식은 고유한 베타 헤더를 가지므로 각 페이지에 별도의 섹션이 있습니다: [요청 시 압축의 API 지원](https://platform.claude.com/docs/ko/build-with-claude/compaction-on-demand#availability-feature-support) 및 [임계값 압축의 API 지원](https://platform.claude.com/docs/ko/build-with-claude/compaction-threshold#availability-feature-support).

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