feat: handle multiple dynamic context filenames in system prompt (#18598)

This commit is contained in:
N. Taylor Mullen
2026-02-09 16:37:08 -08:00
committed by GitHub
parent c9f9a7f67a
commit cc2798018b
3 changed files with 123 additions and 7 deletions
+9 -2
View File
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2025 Google LLC
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
@@ -28,6 +28,7 @@ import {
} from '../tools/tool-names.js';
import { resolveModel, isPreviewModel } from '../config/models.js';
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
import { getAllGeminiMdFilenames } from '../tools/memoryTool.js';
/**
* Orchestrates prompt generation by gathering context and building options.
@@ -56,6 +57,7 @@ export class PromptProvider {
const desiredModel = resolveModel(config.getActiveModel());
const isGemini3 = isPreviewModel(desiredModel);
const activeSnippets = isGemini3 ? snippets : legacySnippets;
const contextFilenames = getAllGeminiMdFilenames();
// --- Context Gathering ---
let planModeToolsList = PLAN_MODE_TOOLS.filter((t) =>
@@ -114,6 +116,7 @@ export class PromptProvider {
interactive: interactiveMode,
isGemini3,
hasSkills: skills.length > 0,
contextFilenames,
})),
subAgents: this.withSection('agentContexts', () =>
config
@@ -191,7 +194,11 @@ export class PromptProvider {
}
// --- Finalization (Shell) ---
const finalPrompt = activeSnippets.renderFinalShell(basePrompt, userMemory);
const finalPrompt = activeSnippets.renderFinalShell(
basePrompt,
userMemory,
contextFilenames,
);
// Sanitize erratic newlines from composition
const sanitizedPrompt = finalPrompt.replace(/\n{3,}/g, '\n\n');