<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Context Management on dotnetuniversity</title>
        <link>https://dotnetuniversity.com/tags/context-management/</link>
        <description>Recent content in Context Management on dotnetuniversity</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Fri, 21 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://dotnetuniversity.com/tags/context-management/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>MCP Context Mode: Session Memory and Context Management for GitHub Copilot</title>
        <link>https://dotnetuniversity.com/mcp-context-mode-session-memory-and-context-management-for-github-copilot/</link>
        <pubDate>Fri, 21 Aug 2026 00:00:00 +0000</pubDate>
        
        <guid>https://dotnetuniversity.com/mcp-context-mode-session-memory-and-context-management-for-github-copilot/</guid>
        <description>&lt;img src="https://dotnetuniversity.com/mcp-context-mode-session-memory-and-context-management-for-github-copilot/tyler-lagalo-10u9BcaOLjs-unsplash.jpg" alt="Featured image of post MCP Context Mode: Session Memory and Context Management for GitHub Copilot" /&gt;&lt;p&gt;Every Copilot session has a limited context window. As a coding task grows, the conversation fills with file contents, terminal output, tool calls, errors, and decisions. When the context is compacted, Copilot can lose the details that explain what has already been investigated and what still needs to be done.&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/mksglu/context-mode&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Context Mode&lt;/a&gt; is an MCP server and context-management tool designed for this problem. It keeps large tool output outside the model&amp;rsquo;s context, indexes useful project and session data locally, and retrieves relevant information when it is needed. Its documentation lists VSCode Copilot as a supported platform.&lt;/p&gt;
&lt;p&gt;Context Mode focuses on the history of coding work and on controlling how much raw data reaches the model.&lt;/p&gt;
&lt;div class=&#34;mermaid&#34;&gt;%%{init: {&#39;theme&#39;: &#39;base&#39;}}%%
flowchart LR
    A[VS Code Copilot&lt;br/&gt;Agent mode] --&gt;|prompts + tool events| B[Context Mode&lt;br/&gt;MCP tools + hooks]
    B --&gt;|store and index| C[(Local SQLite + FTS5&lt;br/&gt;session history + project index)]
    C --&gt;|search relevant data| D[Focused context&lt;br/&gt;snippets + next steps]
    D --&gt;|restore context| A

    E[Large inputs&lt;br/&gt;logs · files · APIs] --&gt;|process outside chat| B
    B --&gt;|return only useful data| F[Compact output&lt;br/&gt;less context pressure]
    F --&gt; A

    classDef copilot fill:#dbeafe,stroke:#2563eb,stroke-width:3px,color:#172b4d
    classDef mode fill:#fce7f3,stroke:#db2777,stroke-width:3px,color:#5e163d
    classDef storage fill:#dcfce7,stroke:#16a34a,stroke-width:3px,color:#24592b
    classDef result fill:#fef3c7,stroke:#d97706,stroke-width:3px,color:#604e12
    classDef input fill:#f3f4f6,stroke:#6b7280,stroke-width:3px,color:#344054
    classDef output fill:#fee2e2,stroke:#dc2626,stroke-width:3px,color:#7a2825

    class A copilot
    class B mode
    class C storage
    class D result
    class E input
    class F output

    linkStyle 0 stroke:#2563eb,stroke-width:3px
    linkStyle 1 stroke:#db2777,stroke-width:3px
    linkStyle 2 stroke:#16a34a,stroke-width:3px
    linkStyle 3 stroke:#d97706,stroke-width:3px
    linkStyle 4 stroke:#6b7280,stroke-width:3px
    linkStyle 5 stroke:#dc2626,stroke-width:3px
    linkStyle 6 stroke:#dc2626,stroke-width:3px&lt;/div&gt;
&lt;p&gt;The diagram shows the central idea: Copilot sends prompts and tool events to Context Mode, Context Mode stores or indexes the useful data locally, and only relevant snippets or summaries return to Copilot.&lt;/p&gt;
&lt;h2 id=&#34;what-you-will-build&#34;&gt;What You Will Build
&lt;/h2&gt;&lt;p&gt;You will investigate one small API exception to see how Context Mode stores useful project context and retrieves it in a later Copilot session:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Session 1: Investigate the GET /api/todos exception and fix its cause.
&lt;p&gt;Session 2: What caused the exception, which file changed, and what test is missing?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In Session 1, Context Mode indexes the API log and records useful work. In Session 2, it retrieves the relevant result instead of making you repeat the investigation.&lt;/p&gt;
&lt;h2 id=&#34;use-context-mode-in-vscode&#34;&gt;Use Context Mode in VSCode
&lt;/h2&gt;&lt;p&gt;There are two parts to a VSCode Copilot setup:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add Context Mode as an MCP server so Copilot can call &lt;code&gt;ctx_*&lt;/code&gt; tools.&lt;/li&gt;
&lt;li&gt;Enable the Context Mode Copilot integration if you want automatic session capture and context restoration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The MCP server alone gives Copilot context-processing tools. It does not automatically turn every existing Copilot conversation into searchable history.&lt;/p&gt;
&lt;h3 id=&#34;prerequisites&#34;&gt;Prerequisites
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;VSCode with GitHub Copilot Chat and agent mode enabled.&lt;/li&gt;
&lt;li&gt;Node.js 20 or later and &lt;code&gt;npx&lt;/code&gt; available in the integrated terminal.&lt;/li&gt;
&lt;li&gt;A project folder where you can test the integration without exposing secrets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;add-the-mcp-server&#34;&gt;Add the MCP Server
&lt;/h3&gt;&lt;p&gt;Open the Command Palette, run &lt;code&gt;MCP: Open Workspace Folder MCP Configuration&lt;/code&gt;, and create or edit &lt;code&gt;.vscode/mcp.json&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;
&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;
&lt;pre tabindex=&#34;0&#34; style=&#34;color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 1
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 2
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 3
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 4
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 5
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 6
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 7
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 8
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt; 9
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt;10
&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f849c&#34;&gt;11
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;
&lt;pre tabindex=&#34;0&#34; style=&#34;color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#cba6f7&#34;&gt;&amp;#34;servers&amp;#34;&lt;/span&gt;: {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#cba6f7&#34;&gt;&amp;#34;context-mode&amp;#34;&lt;/span&gt;: {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#cba6f7&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#a6e3a1&#34;&gt;&amp;#34;npx&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#cba6f7&#34;&gt;&amp;#34;args&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#a6e3a1&#34;&gt;&amp;#34;-y&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#a6e3a1&#34;&gt;&amp;#34;context-mode&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            ]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The package and configuration options can change, so check the &lt;a class=&#34;link&#34; href=&#34;https://github.com/mksglu/context-mode&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Context Mode repository&lt;/a&gt; when installing a newer version. After saving the file, use the MCP server controls in VSCode to start or restart &lt;code&gt;context-mode&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;verify-the-connection&#34;&gt;Verify the Connection
&lt;/h3&gt;&lt;p&gt;Open Copilot Chat in agent mode and send this prompt:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Use Context Mode to run ctx doctor and report whether the MCP server,
runtime, SQLite/FTS5 search, and Copilot integration are ready.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You should see a &lt;code&gt;context-mode&lt;/code&gt; tool call and a diagnostic result. If Copilot does not offer the tool, restart the MCP server and reload the VSCode window.&lt;/p&gt;
&lt;h2 id=&#34;a-simple-scenario-fix-an-api-exception&#34;&gt;A Simple Scenario: Fix an API Exception
&lt;/h2&gt;&lt;p&gt;Assume a small ASP.NET Core Todo API returns HTTP 500 from &lt;code&gt;GET /api/todos&lt;/code&gt;. The application writes this exception to &lt;code&gt;app.log&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;exception-block&#34;&gt;
&lt;div class=&#34;exception-block__header&#34;&gt;API Exception&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;System.NullReferenceException: Object reference not set to an instance of an object.
    at TodoService.GetAll() in TodoService.cs:line 42&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You want Copilot to find the exception in Session 1 and remember the fix in Session 2.&lt;/p&gt;
&lt;h3 id=&#34;session-1-index-the-api-log&#34;&gt;Session 1: Index the API Log
&lt;/h3&gt;&lt;p&gt;Send this prompt to Copilot:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Use Context Mode to index app.log.
Do not print the full file.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Context Mode chunks &lt;code&gt;app.log&lt;/code&gt; and stores searchable content locally. The useful result is a small confirmation, not the complete log.&lt;/p&gt;
&lt;h3 id=&#34;session-1-find-the-exception&#34;&gt;Session 1: Find the Exception
&lt;/h3&gt;&lt;p&gt;Now ask Copilot to search the indexed log:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Search the indexed app.log for the exception from GET /api/todos.
Explain the likely cause and identify the file to fix.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Context Mode searches the index and returns only the matching exception. Copilot can reason about the failure without loading the entire log.&lt;/p&gt;
&lt;h3 id=&#34;session-2-retrieve-the-previous-work&#34;&gt;Session 2: Retrieve the Previous Work
&lt;/h3&gt;&lt;p&gt;Close the first chat, start a new Copilot session, and send:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Continue the Todo API investigation from the previous session.
What caused the exception, which file changed, and what test is missing?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When the Copilot integration and hooks are active, Context Mode restores the relevant session context instead of replaying the complete conversation. Copilot can answer with the exception cause, changed file, and missing test.&lt;/p&gt;
&lt;h3 id=&#34;check-context-savings&#34;&gt;Check Context Savings
&lt;/h3&gt;&lt;p&gt;Finish with this prompt:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;Use Context Mode to show ctx stats for this session.
How much output was processed, and how much context was saved?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The exact numbers depend on file size, tool output, query shape, and the active adapter. Treat benchmark values from the repository as examples, not as a guarantee for every project.&lt;/p&gt;
&lt;h2 id=&#34;the-context-window-problem&#34;&gt;The Context Window Problem
&lt;/h2&gt;&lt;p&gt;A coding agent receives more than your written prompt. It also receives tool input and tool output:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;File contents&lt;/li&gt;
&lt;li&gt;Directory listings&lt;/li&gt;
&lt;li&gt;Git history&lt;/li&gt;
&lt;li&gt;Build and test output&lt;/li&gt;
&lt;li&gt;API responses&lt;/li&gt;
&lt;li&gt;Logs&lt;/li&gt;
&lt;li&gt;Browser or Playwright snapshots&lt;/li&gt;
&lt;li&gt;Results from other MCP servers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Large responses consume context quickly. Reading fifty files directly may leave less room for reasoning about the implementation. Context Mode moves data processing closer to the tool call and returns a smaller result to the model.&lt;/p&gt;
&lt;p&gt;For example, instead of placing a large log file into the conversation, an agent can process it and return only matching errors, counts, or summaries. Instead of loading an entire document, it can index the document and retrieve relevant sections later.&lt;/p&gt;
&lt;h2 id=&#34;core-capabilities&#34;&gt;Core Capabilities
&lt;/h2&gt;&lt;h3 id=&#34;1-session-continuity&#34;&gt;1. Session Continuity
&lt;/h3&gt;&lt;p&gt;Context Mode records useful events from a coding session, including prompts, decisions, tool activity, errors, and task progress. When a session is resumed or the context is compacted, it can restore relevant working state instead of forcing Copilot to start from an empty context.&lt;/p&gt;
&lt;p&gt;The restored context can answer questions such as:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Copilot Prompt&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;What caused the Todo API exception?
Which file did we change?
What test is still missing?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Session continuity is project-oriented. It is intended to help an agent continue development work, not to reproduce every message exactly as a chat export.&lt;/p&gt;
&lt;h3 id=&#34;2-local-session-storage&#34;&gt;2. Local Session Storage
&lt;/h3&gt;&lt;p&gt;Context Mode stores session and indexed-content data locally in SQLite. Its search layer uses SQLite FTS5 and BM25 ranking to find relevant text. This gives the agent searchable history without requiring a separate database server.&lt;/p&gt;
&lt;p&gt;The repository documents storage under a Context Mode data directory, with project-scoped content and session data. The exact location can vary by adapter and configuration, so inspect the installed version before backing up or changing retention behavior.&lt;/p&gt;
&lt;h3 id=&#34;3-context-reduction&#34;&gt;3. Context Reduction
&lt;/h3&gt;&lt;p&gt;Context Mode can run code, process files, batch operations, and inspect large outputs while returning only standard output or relevant matches. This reduces the amount of raw data added to the model context.&lt;/p&gt;
&lt;p&gt;Its MCP tools include capabilities for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Running code in a sandboxed subprocess&lt;/li&gt;
&lt;li&gt;Processing a file without returning its full contents&lt;/li&gt;
&lt;li&gt;Running multiple commands or searches in one operation&lt;/li&gt;
&lt;li&gt;Indexing local files and directories&lt;/li&gt;
&lt;li&gt;Fetching and indexing web pages&lt;/li&gt;
&lt;li&gt;Searching indexed content&lt;/li&gt;
&lt;li&gt;Fetching only selected observations or snippets&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is useful for repositories, logs, CSV files, API responses, and documentation that are too large to paste into a chat.&lt;/p&gt;
&lt;h3 id=&#34;4-full-text-retrieval&#34;&gt;4. Full-Text Retrieval
&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;ctx_index&lt;/code&gt; tool chunks content while preserving useful structure such as headings and code blocks. The &lt;code&gt;ctx_search&lt;/code&gt; tool then searches indexed content and returns focused snippets rather than an entire document.&lt;/p&gt;
&lt;p&gt;Search supports relevance ranking, stemming, substring matching, proximity ranking, fuzzy correction, and smart snippets. These features make it possible to ask for a concept without knowing the exact wording used in the original file.&lt;/p&gt;
&lt;h3 id=&#34;5-web-and-document-retrieval&#34;&gt;5. Web and Document Retrieval
&lt;/h3&gt;&lt;p&gt;Context Mode can fetch a URL, convert it to searchable content, and index it. A later query can retrieve relevant sections without placing the entire web page in the conversation.&lt;/p&gt;
&lt;p&gt;It also supports cache behavior for previously indexed URLs. This can avoid repeated downloads and reduce repeated context usage for stable documentation.&lt;/p&gt;
&lt;h3 id=&#34;6-tool-routing&#34;&gt;6. Tool Routing
&lt;/h3&gt;&lt;p&gt;On supported platforms, hooks can guide or enforce routing of large operations through Context Mode. The purpose is to prevent a large file, log, or external MCP response from consuming the context window unnecessarily.&lt;/p&gt;
&lt;p&gt;This is stronger than a system prompt alone. A prompt can tell the model to use a context tool, while a hook can intercept tool activity and redirect or block selected operations, depending on the platform integration.&lt;/p&gt;
&lt;h3 id=&#34;7-statistics-and-diagnostics&#34;&gt;7. Statistics and Diagnostics
&lt;/h3&gt;&lt;p&gt;Context Mode provides utility commands for inspecting its operation:&lt;/p&gt;
&lt;div class=&#34;copilot-prompt context-mode-tool&#34;&gt;
&lt;div class=&#34;copilot-prompt__header&#34;&gt;Context Mode Commands&lt;/div&gt;
&lt;div class=&#34;copilot-prompt__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre&gt;&lt;code data-lang=&#34;text&#34;&gt;ctx stats    -&gt; context savings and session statistics
ctx doctor   -&gt; runtime, hook, SQLite, and installation diagnostics
ctx index    -&gt; index a file or directory
ctx search   -&gt; search indexed content
ctx purge    -&gt; remove indexed content&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These commands help verify that the integration is active and show how much context has been saved.&lt;/p&gt;
&lt;h2 id=&#34;how-session-continuity-works&#34;&gt;How Session Continuity Works
&lt;/h2&gt;&lt;p&gt;A simplified flow looks like this:&lt;/p&gt;
&lt;div class=&#34;mermaid&#34;&gt;%%{init: {&#39;theme&#39;: &#39;base&#39;}}%%
graph LR
    A[Copilot prompt] --&gt; B[Context Mode hooks]
    B --&gt; C[Session and tool events]
    C --&gt; D[(Local SQLite and FTS5)]
    D --&gt; E[Relevant context retrieval]
    E --&gt; F[Copilot continues task]

    classDef copilot fill:#dbeafe,stroke:#2563eb,stroke-width:3px,color:#1e3a8a
    classDef mode fill:#fce7f3,stroke:#db2777,stroke-width:3px,color:#5e163d
    classDef events fill:#fef3c7,stroke:#d97706,stroke-width:3px,color:#78350f
    classDef storage fill:#dcfce7,stroke:#16a34a,stroke-width:3px,color:#14532d
    class A,F copilot
    class B mode
    class C events
    class D storage
    class E copilot

    linkStyle 0 stroke:#2563eb,stroke-width:3px
    linkStyle 1 stroke:#db2777,stroke-width:3px
    linkStyle 2 stroke:#d97706,stroke-width:3px
    linkStyle 3 stroke:#16a34a,stroke-width:3px
    linkStyle 4 stroke:#2563eb,stroke-width:3px&lt;/div&gt;
&lt;p&gt;During a long task, Context Mode captures useful session events. Before compaction, it can create a resumable snapshot. When the agent starts or resumes again, the integration retrieves relevant project and session context and makes it available to the model.&lt;/p&gt;
&lt;p&gt;The important detail is selective retrieval. The entire previous conversation does not need to be inserted into the new context window. The agent searches for the current task and receives the most relevant observations.&lt;/p&gt;
&lt;h2 id=&#34;what-context-mode-does-not-do&#34;&gt;What Context Mode Does Not Do
&lt;/h2&gt;&lt;p&gt;Context Mode is not a complete archive of every Copilot chat stored by GitHub. It cannot recover sessions that happened before it was installed or before its integration was enabled.&lt;/p&gt;
&lt;p&gt;It also does not guarantee that every Copilot event is captured on every platform. Hook support, session-start behavior, compaction handling, and context injection depend on the client adapter and the installed version. Verify the integration with its diagnostic command before relying on it for important work.&lt;/p&gt;
&lt;p&gt;Automatic history capture also requires privacy discipline. Prompts, file paths, tool inputs, command output, and source code can contain secrets or personal information. Configure exclusions, avoid indexing sensitive files, and inspect the local data directory before sharing or committing it.&lt;/p&gt;
&lt;h2 id=&#34;when-to-use-context-mode&#34;&gt;When to Use Context Mode
&lt;/h2&gt;&lt;p&gt;Context Mode is a strong fit when:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A coding task spans many Copilot interactions.&lt;/li&gt;
&lt;li&gt;Context compaction causes repeated explanations.&lt;/li&gt;
&lt;li&gt;Tool output is larger than the useful answer.&lt;/li&gt;
&lt;li&gt;You need to search project history or indexed documentation.&lt;/li&gt;
&lt;li&gt;You want local session storage and FTS5 search.&lt;/li&gt;
&lt;li&gt;You use VSCode Copilot or another supported coding-agent client.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;Context Mode gives coding agents a second layer of memory: searchable working history and context management. It can preserve prompts, decisions, tool activity, errors, and next steps while keeping large raw outputs outside the model&amp;rsquo;s context.&lt;/p&gt;
&lt;p&gt;For VSCode Copilot, Context Mode is most useful when Copilot needs to continue a complicated coding task, search previous project activity, or work with large files and tool responses without filling the context window.&lt;/p&gt;
&lt;h2 id=&#34;reference&#34;&gt;Reference
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/mksglu/context-mode&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Context Mode source code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://contextmode.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Context Mode documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
