From d7aa797a94c3a8138835a6cdfebecad05f203898 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 28 Feb 2026 13:17:47 -0800 Subject: [PATCH] Remove directory structure from system prompt Remove the getDirectoryStructure() function and its embedding in the system prompt. This was walking up to 500 files and embedding them as a static tree in every API request, adding ~3,500-5,000 tokens per call. The LLM already has tools (listFiles, Glob, Grep) to discover files on demand, making the embedded tree redundant. Claude Code does not include directory structure in its system prompt for the same reason. This also improves prompt cache hit rates since the system prompt no longer varies by project directory contents. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue --- extensions/cli/src/systemMessage.test.ts | 1 - extensions/cli/src/systemMessage.ts | 41 ------------------------ 2 files changed, 42 deletions(-) diff --git a/extensions/cli/src/systemMessage.test.ts b/extensions/cli/src/systemMessage.test.ts index e419d0bac..1ebab348b 100644 --- a/extensions/cli/src/systemMessage.test.ts +++ b/extensions/cli/src/systemMessage.test.ts @@ -46,7 +46,6 @@ describe("constructSystemMessage", () => { expect(result).toContain("You are an agent in the Continue CLI"); expect(result).toContain(""); - expect(result).toContain(''); expect(result).toContain(''); }); diff --git a/extensions/cli/src/systemMessage.ts b/extensions/cli/src/systemMessage.ts index b3277975e..6e3a74762 100644 --- a/extensions/cli/src/systemMessage.ts +++ b/extensions/cli/src/systemMessage.ts @@ -2,14 +2,10 @@ import { execSync } from "child_process"; import * as fs from "fs"; import * as path from "path"; -import pkg from "ignore-walk"; -import { Minimatch } from "minimatch"; - import { processRule } from "./hubLoader.js"; import { PermissionMode } from "./permissions/types.js"; import { serviceContainer } from "./services/ServiceContainer.js"; import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js"; -const { WalkerSync } = pkg; /** * Check if current directory is a git repository @@ -23,39 +19,6 @@ function isGitRepo(): boolean { } } -/** - * Get basic directory structure - */ -function getDirectoryStructure(): string { - try { - const walker = new WalkerSync({ - path: process.cwd(), - includeEmpty: false, - follow: false, - ignoreFiles: [".gitignore", ".continueignore", ".customignore"], - }); - - (walker.ignoreRules as any)[".customignore"] = [ - new Minimatch(".git/*", { - matchBase: true, - dot: true, - flipNegate: true, - nocase: true, - }), - ]; - - const files = walker.start().result as string[]; - - const filteredFiles = files - .slice(0, 500) - .map((file: string) => `./${file}`); - - return filteredFiles.join("\n") || "No structure available"; - } catch { - return "Directory structure not available"; - } -} - /** * Get git status */ @@ -89,10 +52,6 @@ Today's date: ${new Date().toISOString().split("T")[0]} As you answer the user's questions, you can use the following context: -Below is a snapshot of this project's file structure at the start of the conversation. This snapshot will NOT update during the conversation. It skips over .gitignore patterns. - -${getDirectoryStructure()} - This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation. ${getGitStatus()}