letta/compaction-prompts/SKILL.md
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.
npx skillsauth add letta-ai/skills compaction-promptsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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
Think of compaction as a lifecycle contract, not just a prompt string:
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.
Customize compaction settings when the default summary loses important continuity, tone, relationship context, implementation details, or user feedback.
Common cases:
For complete prompt templates, read references/prompt-patterns.md.
Before changing settings:
compaction_settings, model, and effective context window.sliding_window_percentage, too-small clip_chars, or summarizer model mismatch.--dry-run and review the PATCH body.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%. |
sliding_window by default. It summarizes older messages with a separate summarizer call and keeps recent messages intact.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.all only when maximum space reduction matters more than preserving recent raw messages.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.
Every custom prompt should:
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.
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'
Write the prompt to a file, then run:
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_KEYAGENT_ID unless --agent-id is providedLETTA_BASE_URL or https://api.letta.comIt preserves existing compaction_settings fields unless flags override them.
Use --dry-run to preview the PATCH body without changing anything.
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}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
compaction_settings: {
...(current.compaction_settings ?? {}),
mode: "self_compact_sliding_window",
prompt,
clip_chars: 50000,
},
}),
});
if (!updateResponse.ok) throw new Error(await updateResponse.text());
When using curl, inspect first and preserve existing fields. Sending a partial compaction_settings object may reset omitted fields depending on server behavior.
prompt_file=/tmp/compaction-prompt.txt
current=$(curl -sS "$BASE_URL/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $LETTA_API_KEY")
jq -n \
--arg prompt "$(cat "$prompt_file")" \
--argjson current "$(printf '%s' "$current" | jq '.compaction_settings // {}')" \
'{ compaction_settings: ($current + {
mode: "self_compact_sliding_window",
prompt: $prompt,
clip_chars: 50000
}) }' > /tmp/compaction-patch.json
curl -sS -X PATCH "$BASE_URL/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $LETTA_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @/tmp/compaction-patch.json
curl -sS "$BASE_URL/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $LETTA_API_KEY" | \
jq '{id, model, compaction_settings}'
tools
Test any GUI app or change on a Daytona Windows remote desktop sandbox. Use to launch a GUI program, sync a local project, take a screenshot, record a video, or share a clickable live-desktop link with a teammate. Generic — the only dependency is Daytona. For Linux, use remote-desktop-testing-linux.
tools
Test any GUI app or change on a Daytona Linux (Ubuntu xfce4 + noVNC) remote desktop sandbox. Use to launch a GUI program, sync a local project, take a screenshot, record a video, or share a clickable live-desktop link with a teammate. Generic — the only dependency is Daytona. For Windows, use remote-desktop-testing-windows.
testing
Configures Letta agents' own runtime behavior, including model, context window, system prompt, reasoning, conversation overrides, compaction settings, and compaction prompts. Use when an agent or user asks to self-modify, tune summarization/compaction, change identity/system instructions, adjust model settings, or test conversation-scoped overrides.
development
Sets Letta Desktop and Letta Code agent profile images by writing profile.png into an agent MemFS repository. Use when the user asks to add, change, generate, or fix an agent avatar, profile picture, profile image, or Desktop agent photo.