Memory Compaction

Operating procedure for keeping a long-running agent coherent using the OpenAI Agents SDK memory and compaction primitives: three ways to trigger compaction (automatic, threshold-based, forced checkpoint), exact rules for what working state to preserve through a compaction, and what belongs in cross-run memory versus the reviewed output artifact. Trigger when building or operating an agent whose session spans many turns or evidence batches and risks context overflow, when deciding what to persist across sessions, or when wiring Compaction()/Memory() capabilities into a SandboxAgent.

10 stars 2 forksProductivity & Notes

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add Archive228/lab-skills --skill memory-compaction
Manual install
git clone --depth 1 https://github.com/Archive228/lab-skills.git /tmp/lab-skills
mkdir -p ~/.claude/skills
cp -r /tmp/lab-skills/skills/memory-compaction ~/.claude/skills/memory-compaction

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Memory & Compaction for Long-Running Agents

This skill gives you the OpenAI Agents SDK pattern for keeping a multi-turn, multi-batch agent coherent: **compaction** sustains the current session when context grows, **memory** carries reusable workflow lessons into future sessions, and a **generated, human-reviewed artifact** (a memo with citations) remains the only system of record. The three are deliberately separated — no single one of them (not conversation history, not memory, not agent reasoning) replaces human review of the cited output. The reference implementation is an evidence-review agent for compliance investigations, but the pattern applies wherever knowledge workers review evolving context and produce auditable outputs: support escalations under policy updates, security incident summaries, finance exception reconciliation, legal/procurement contract review, M&A diligence.

## When to use

Use this skill when:

- A single agent session must survive many turns or sequential evidence/document batches and will hit context limits mid-task.
- You are wiring a `SandboxAgent` with `Filesystem()` and `Shell()` capabilities and need to add `Compaction()` and/or `Memory()`.
- You must decide, at a phase boundary, what to keep in working context, what to promote to cross-run memory, and what to write into the output artifact.
- Repeated runs of the same *kind* of task should get better over time without replaying every prior interaction.

Do NOT use this pattern to:
Read the full skill on GitHub

Details

Skill name
memory-compaction
Path
skills/memory-compaction/SKILL.md
License
MIT
Repo updated
12 August 2026

FAQ

What does the Memory Compaction skill do?

Operating procedure for keeping a long-running agent coherent using the OpenAI Agents SDK memory and compaction primitives: three ways to trigger compaction (automatic, threshold-based, forced checkpoint), exact rules for what working state to preserve through a compaction, and what belongs in cross-run memory versus the reviewed output artifact. Trigger when building or operating an agent whose session spans many turns or evidence batches and risks context overflow, when deciding what to persist across sessions, or when wiring Compaction()/Memory() capabilities into a SandboxAgent.

How do I install the Memory Compaction skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add Archive228/lab-skills --skill memory-compaction. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Memory Compaction popular?

It lives in Archive228/lab-skills, which has 10 GitHub stars and 2 forks.

Related skills

Agent Design Fundamentals

10

Archive228/lab-skills

Decision rules for whether to build an LLM agent and how to architect it, distilled from OpenAI's "A Practical Guide to Building Agents": build/no-build criteria, model selection, tool design, single-agent vs multi-agent orchestration (manager pattern vs decentralized handoffs), layered guardrails, and human-in-the-loop triggers. Use when designing, reviewing, or refactoring an agent system — before choosing an architecture, adding more agents, defining tools, or shipping an agent to production without guardrails.

AI, LLMs & Agents

Agent Evals

10

Archive228/lab-skills

Build and maintain evaluation suites for AI agents: bootstrap 20-50 tasks from real failures, pick code-based vs model-based vs human graders by agent architecture (coding, conversational, research, computer-use), write unambiguous tasks with reference solutions, and keep suites alive via ownership and transcript reading. Use when creating evals from zero, adding graders or eval cases, debugging suspicious eval scores, or deciding pass@k vs pass^k metrics for an agent product.

AI, LLMs & Agents

Agent Failure Preflight

10

Archive228/lab-skills

Pre-deployment failure-mode gate for agentic AI systems, distilled from Microsoft AI Red Team's Taxonomy of Failure Modes in Agentic AI Systems v2.0 (grounded in 12 months of red-team engagements). Run it before shipping or materially changing an agent — adding tools/MCP servers/plugins, enabling persistent memory, adding sub-agents or orchestration, enabling computer use, or expanding permissions — to verify concrete controls against memory poisoning, HitL bypass, goal hijacking, supply-chain compromise, session context contamination, capability disclosure, and multi-agent cascade failures.

AI, LLMs & Agents

Mjml

5

JayOram/MJML-ai-knowledge

Author, compile, debug, and refactor MJML (Mailjet Markup Language) responsive email templates. Use this skill whenever the user is working with MJML — writing or editing .mjml files, building or fixing a responsive HTML email, using mj-* tags (mj-section, mj-column, mj-button, mj-hero, etc.), compiling MJML to HTML via the CLI or the mjml2html Node API, setting up shared partials with mj-include, or asking why an email renders wrong in Outlook/Gmail. Trigger it even when the user says "email template," "newsletter HTML," or "responsive email" without naming MJML explicitly, since MJML is usua

Productivity & Notes

Srt to Review Blueprint

9

bleakbelladonnals/asr-transcription-skills

把课程录音转写 SRT(含转写错误、碎片块、无说话人标签)+ 课堂笔记 + 面试旁听笔记,加工成课后复习蓝本:一份整体版 + 一份笔记补丁版(含术语表、行内纠错标注、存疑清单)。触发词:录音转写整理、srt 转蓝本、复习文档、转写纠错、笔记补充、课程录音整理。

Productivity & Notes

Slack API Readonly

9

kargnas/skills

Scrape Slack read-only via Web API (user token) into markdown for LLM. Use to FETCH Slack conversation directly — by channel, thread permalink, or search — without copy-paste. Real names, mrkdwn unwrapped, emoji/reactions kept, tz configurable; --files downloads images/attachments. Stdout-only otherwise. Formats pasted Slack text with the bundled cleaner.

Productivity & Notes

Browse the most popular Claude skills, all productivity & notes skills, or write your own with the skills generator.