Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/compaction-workflow-guide.mdA 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.pythonA 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.pythonA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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