How VS Code Copilot Chat Compacts Your Conversation VS Code Copilot Chat uses a compaction mechanism to summarize older conversation history when the agent session exceeds the LLM's context window, triggered automatically or via the /compact command. The process relies on the budget-aware prompt renderer @vscode/prompt-tsx, which prunes low-priority content and escalates to compaction when pruning fails. LLMs have limited context windows. When an agent session grows too long, VS Code Copilot Chat uses compaction to summarize older history while keeping recent work verbatim. I traced exactly how it works from the source. Note The standalone microsoft/vscode-copilot-chat repo was archived in May 2026 . The agent code now lives in the main microsoft/vscode https://github.com/microsoft/vscode repo under extensions/copilot/ , and it has changed since the standalone repo froze. Everything below is traced against the current extensions/copilot source. Source files all under extensions/copilot/ : src/extension/intents/node/agentIntent.ts — budget math, trigger logic src/extension/prompts/node/agent/summarizedConversationHistory.tsx — prompt, LLM call, history selection, re-insertion src/extension/prompts/node/agent/backgroundSummarizer.ts — the async state machine and thresholds src/extension/prompts/node/agent/simpleSummarizedHistoryPrompt.tsx — the Simple-mode fallback Note Microsoft moves fast. Treat line numbers as approximate and the thresholds as true the day I looked. First, what is @vscode/prompt-tsx ? Compaction makes no sense until you understand the renderer underneath it. @vscode/prompt-tsx https://github.com/microsoft/vscode-prompt-tsx the repo pins ^0.4.0-alpha.8 is a budget-aware prompt renderer . Instead of concatenating strings into a messages array, you author the entire prompt as a tree of TSX components — a PromptElement — and the renderer flattens it into the ChatMessage that goes to the model, fitting it to the token budget for you . Here’s the actual agent prompt, lightly trimmed agentPrompt.tsx : return < {baseInstructions}