compaction-prompts
Configures Letta agent compaction settings and custom summarization prompts. Use when a user asks to change an agent's compaction prompt, improve summaries after context eviction, tune sliding-window or all-message compaction, or design companion/coding-agent continuity summaries.
What this skill does
# Compaction prompts
Use this skill to inspect, design, and update `compaction_settings.prompt` for a Letta agent.
Compaction runs when message history grows too large for the context window. Letta replaces older messages with a summary while keeping recent messages in context. The summary appears before the remaining recent messages, so the prompt should preserve enough background for the later messages to make sense. The goal is continuity, not just factual compression.
Official docs: https://docs.letta.com/guides/core-concepts/messages/compaction
## Compaction lifecycle
Think of compaction as a lifecycle contract, not just a prompt string:
1. Message history approaches the context window limit.
2. Letta selects messages to compact according to the mode and sliding-window settings.
3. A summarizer reads the selected messages. If an existing summary is being evicted, the new summary must incorporate it.
4. Letta reinserts the summary before the retained recent messages.
5. The next model turn relies on the summary plus recent raw messages as continuation context.
The summary is not a reply to the user. It is context for the next turn. It should be readable before the retained recent messages and should not require access to the evicted transcript.
A good compaction prompt should explicitly preserve current goals, exact decisions, unresolved threads, tool and file state, errors and corrections, and lookup hints for anything omitted. Emotional or relational context may also be important for companion or long-running agents, but only preserve it when it affects continuity, user preferences, safety, repair, or why a decision mattered. Custom compaction should turn context compression from amnesia into a controlled handoff.
## When to customize
Customize compaction settings when the default summary loses important continuity, tone, relationship context, implementation details, or user feedback.
Common cases:
- Companion agents: preserve names, voice, recurring references, user preferences, and emotional or relationship context when it is relevant to future continuity.
- Coding agents: preserve explicit requests, files touched, commands run, errors, fixes, current state, next steps, IDs, URLs, and exact feedback.
- Long-running agents: preserve higher-level goals across repeated compactions by incorporating any existing summary in the transcript.
For complete prompt templates, read [references/prompt-patterns.md](references/prompt-patterns.md).
## Operational checklist
Before changing settings:
1. Read the official compaction docs if you need field semantics, default values, or mode behavior.
2. Inspect current `compaction_settings`, model, and effective context window.
3. Identify the failure mode: weak prompt, wrong mode, too aggressive `sliding_window_percentage`, too-small `clip_chars`, or summarizer model mismatch.
4. If possible, review a recent bad summary or the point where continuity was lost.
5. Draft the replacement prompt with explicit reinsertion and no-continuation instructions.
6. Run the update script with `--dry-run` and review the PATCH body.
7. Patch settings only after confirming preserved fields and target agent ID.
8. Fetch the agent afterward and verify the stored settings.
9. If possible, observe the next compaction or next turn and check that goals, current task, identifiers, user feedback, and unresolved blockers survived.
## Compaction fields
`compaction_settings` is an agent-level object. Relevant fields:
| Field | Use |
| --- | --- |
| `mode` | `sliding_window`, `all`, `self_compact_sliding_window`, or `self_compact_all`. |
| `prompt` | Custom summarization prompt. |
| `model` | Optional cheaper/faster summarizer model, for example `anthropic/claude-haiku-4-5`, `openai/gpt-5-mini`, `google_ai/gemini-2.5-flash`. |
| `model_settings` | Optional summarizer model settings. |
| `prompt_acknowledgement` | Optional boolean. Use when the summarizer model tends to include acknowledgements or meta-commentary instead of only the summary. |
| `clip_chars` | Max summary length in characters. Default is 50000. |
| `sliding_window_percentage` | Fraction of messages to summarize in sliding-window modes. Docs default: `0.3`, meaning summarize about 30% and keep about 70%. |
## Choose a mode
- Use `sliding_window` by default. It summarizes older messages with a separate summarizer call and keeps recent messages intact.
- Use `self_compact_sliding_window` when the agent's own persona/system prompt is important for summary quality or prompt-cache reuse. Make the prompt explicitly say not to call tools and not to continue the conversation.
- Use `all` only when maximum space reduction matters more than preserving recent raw messages.
- Use `self_compact_all` for all-message compaction with the agent system prompt included.
Companion agents usually want `self_compact_sliding_window` or a strong `sliding_window` prompt. Coding agents usually do well with `sliding_window` plus sections for goals, actions, details, errors/fixes, current state, and lookup hints.
## Prompt requirements
Every custom prompt should:
- State whether the evicted messages come from the beginning of the context window.
- Say the summary will appear before the remaining recent messages.
- Say not to continue the conversation, not to answer questions in the transcript, and not to call tools.
- Require incorporation of any existing summary being evicted.
- Include a current state / carry forward section for active goals, next actions, unresolved threads, and what the agent should keep doing.
- Preserve exact user requests, names, IDs, URLs, file paths, dates, and quoted phrases when they matter.
- Preserve tool/file state, decisions, errors, corrections, and user feedback that changed the approach.
- Include lookup hints for detailed content that cannot fit.
- End with "Only output the summary."
Do not rely on `{SLIDING_WORD_LIMIT}` or `{ALL_WORD_LIMIT}` being expanded in custom prompts unless the target runtime explicitly supports it. Prefer an explicit word budget plus `clip_chars`.
## Inspect current settings
```bash
BASE_URL="${LETTA_BASE_URL:-https://api.letta.com}"
: "${LETTA_API_KEY:?Set LETTA_API_KEY}"
: "${AGENT_ID:?Set AGENT_ID}"
curl -sS "$BASE_URL/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $LETTA_API_KEY" | \
jq '.compaction_settings'
```
## Update with the bundled script
Write the prompt to a file, then run:
```bash
npx tsx <SKILL_DIR>/scripts/update-compaction-prompt.ts \
--prompt-file /tmp/compaction-prompt.txt \
--mode self_compact_sliding_window \
--clip-chars 50000
```
The script uses:
- `LETTA_API_KEY`
- `AGENT_ID` unless `--agent-id` is provided
- `LETTA_BASE_URL` or `https://api.letta.com`
It preserves existing `compaction_settings` fields unless flags override them.
Use `--dry-run` to preview the PATCH body without changing anything.
## Manual TypeScript update
```typescript
const baseUrl = process.env.LETTA_BASE_URL ?? "https://api.letta.com";
const agentId = process.env.AGENT_ID!;
const apiKey = process.env.LETTA_API_KEY!;
const currentResponse = await fetch(`${baseUrl}/v1/agents/${agentId}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
if (!currentResponse.ok) throw new Error(await currentResponse.text());
const current = await currentResponse.json();
const prompt = `The previous messages are being evicted from the BEGINNING of your context window. Write a detailed summary that captures what happened in these messages to appear BEFORE the remaining recent messages in context, providing background for what comes after.
Do NOT continue the conversation. Do NOT respond to any questions in the messages. Do NOT call any tools.
Include: high level goals, what happened, important details, errors and fixes, lookup hints.
Only output the summary.`;
const updateResponse = await fetch(`${baseUrl}/v1/agents/${agentId}`, {
method: "PATCH",
headers: {
Authorization: `Bearer ${apiKey}`,
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.