openai · OpenAI Platform Docs
Compaction
Teaches how to implement context compaction using both automatic server-side settings and a standalone endpoint to manage token limits in long-running conversations.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Compaction
Teaches how to implement context compaction using both automatic server-side settings and a standalone endpoint to manage token limits in long-running conversations.
When To Use
Use when you need to reduce context size and costs in long-running interactions while preserving necessary conversation state and reasoning.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/compaction-workflow-guide.md | A guide explaining how to use compaction to reduce context size and manage long-running interactions in OpenAI API conversations. | Questions about a guide explaining how to use compaction to reduce context size and manage long-running interactions in OpenAI API co... |
examples/compaction-openai-compaction-python-context-management.python | A Python code example demonstrating how to use the compaction context management parameter within a client response request to manage conversation history. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the compaction context management parameter within a client response r... |
examples/compaction-openai-compaction.python | A Python code example demonstrating how to use the client.responses.compact method to compress a conversation window. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the client.responses.compact method to compress a conversation window. |
What This Skill Covers
- To support long-running interactions, you can use compaction to reduce context size while preserving state needed for subsequent turns.
- Main sections:
Overview,Server-side compaction,User journey,Example user flow,Standalone compact endpoint.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.openai.com/api/docs/guides/compaction.md
