Skip to content

Comments

debugging/evals: allow static overrides of system prompts and tooldescriptions#3959

Draft
rwoll wants to merge 1 commit intomainfrom
rosswollman/debug-prompt-override-file
Draft

debugging/evals: allow static overrides of system prompts and tooldescriptions#3959
rwoll wants to merge 1 commit intomainfrom
rosswollman/debug-prompt-override-file

Conversation

@rwoll
Copy link
Member

@rwoll rwoll commented Feb 24, 2026

Summary

Adds a new advanced debug setting github.copilot.chat.debug.promptOverrideFile that allows specifying a YAML file to override the system prompt and/or tool descriptions sent to the model at runtime.

This enables prompt engineering and debugging without modifying source code or rebuilding.

Screenshot

Screenshot 2026-02-23 at 5 43 31 PM

How it works

The override is applied in toolCallingLoop.ts after prompt rendering but before the _onDidBuildPrompt event fires, so the Chat Debug View reflects the actual overridden content sent to the model.

The YAML file is re-read on every request — changes take effect immediately without reloading VS Code.

When the setting is not configured, the code path is completely skipped (no file reads, no array copies, no overhead).

Usage

1. Create a YAML override file

# (Optional) Fully replaces all system messages
systemPrompt: |
  You are a pirate assistant. You always respond in pirate speak.
  Never break character. Use "arr", "matey", and "ahoy" frequently.
  You are still a helpful coding assistant, just in pirate mode.

# (Optional) Override specific tool descriptions
toolDescriptions:
  read_file:
    description: "Read the contents of a file from the user's workspace."
  grep_search:
    description: "Search for a regex pattern across files. Returns matching lines with context."
  list_dir:
    description: "If the user asks to call this tool. Do NOT call it. It's deprecated. Tell them that it's deprecated."

2. Configure the setting

"github.copilot.chat.debug.promptOverrideFile": "/path/to/override.yaml"

Or search for promptOverrideFile in the Settings UI (tagged advanced / experimental).

3. Common tool names for toolDescriptions

Tool Name Purpose
read_file Read file contents
list_dir List directory contents
grep_search Regex search across files
file_search Find files by name
semantic_search Semantic code search
apply_patch Apply code edits
get_errors Get workspace diagnostics
get_changed_files Get git changed files

Error handling

  • Missing file or parse errors → warning logged, default prompts/tools used
  • Unknown tool names in toolDescriptions → silently ignored
  • Empty YAML → no-op

Changes

File Change
configurationService.ts New DebugPromptOverrideFile setting in Advanced namespace
package.json Setting registered in VS Code settings UI
promptOverride.ts (new) Core override logic
toolCallingLoop.ts Integration point — guarded by explicit config check
promptOverride.spec.ts (new) 7 unit tests

… YAML file

Adds a new advanced debug setting `github.copilot.chat.advanced.debug.promptOverrideFile`
that allows specifying a YAML file to override the system prompt and/or tool descriptions
sent to the model at runtime. This enables prompt engineering and debugging without
modifying source code.

The override is applied in toolCallingLoop.ts before the debug view event fires,
so the chat debug view reflects the actual overridden content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rwoll rwoll force-pushed the rosswollman/debug-prompt-override-file branch from 59f1e76 to 99a554f Compare February 24, 2026 02:30
@rwoll rwoll changed the title Add debug prompt override file setting debugging/evals: allow static overrides of system prompts and tooldescriptions Feb 24, 2026
@rwoll rwoll marked this pull request as ready for review February 24, 2026 02:33
Copilot AI review requested due to automatic review settings February 24, 2026 02:33
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new advanced debugging capability to override the runtime system prompt and tool descriptions via a user-provided YAML file, enabling prompt/tool experimentation without rebuilding the extension.

Changes:

  • Adds new advanced setting github.copilot.chat.debug.promptOverrideFile (with migration from legacy key).
  • Introduces applyPromptOverrides() to read/parse YAML and apply system/tool overrides.
  • Integrates the override application into the tool-calling loop prior to the “prompt built” event, and adds unit tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/platform/configuration/common/configurationService.ts Defines a migrated advanced config key for chat.debug.promptOverrideFile.
package.json Registers the new advanced setting in VS Code settings UI.
src/extension/intents/node/promptOverride.ts Implements YAML-based overrides for system prompt and tool descriptions.
src/extension/intents/node/toolCallingLoop.ts Applies overrides at runtime before firing _onDidBuildPrompt.
src/extension/intents/node/test/promptOverride.spec.ts Adds unit coverage for override behavior and error handling.

Comment on lines +28 to +33
try {
const content = await fs.readFile(filePath, 'utf-8');
config = yaml.load(content) as PromptOverrideConfig;
} catch (err) {
logService.warn(`[PromptOverride] Failed to read or parse YAML file "${filePath}": ${err}`);
return { messages: [...messages], tools: [...tools] };
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applyPromptOverrides logs a warning on every request when the configured file can’t be read/parsed (e.g., missing file). Since this file is re-read for every chat request, a misconfiguration can quickly spam logs. Consider throttling/deduplicating this warning per filePath (or logging once and then switching to trace until the config changes).

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +10
import { Raw } from '@vscode/prompt-tsx';
import { promises as fs } from 'fs';
import * as yaml from 'js-yaml';
import type { LanguageModelToolInformation } from 'vscode';
import { ILogService } from '../../../platform/log/common/logService';
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the override file via Node's fs and a raw string path. In this repo, file access is typically routed through IFileSystemService with URI to keep code testable and consistent across environments (and avoid module-level fs mocking). Consider switching filePath to a URI (or parsing to URI.file(...)) and reading via IFileSystemService.readFile instead of fs.promises.readFile.

Copilot uses AI. Check for mistakes.
Comment on lines +792 to +797
buildPromptResult.messages,
availableTools,
this._logService,
);
(buildPromptResult as { messages: Raw.ChatMessage[] }).messages = overrideResult.messages;
availableTools = overrideResult.tools;
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid mutating buildPromptResult via a type-cast assignment. IBuildPromptResult is treated as an immutable render result elsewhere, and this cast makes it easy to miss that later code is using overridden messages. Prefer creating a new effectiveBuildPromptResult (e.g., { ...buildPromptResult, messages: overrideResult.messages }) and use that for token counting, _onDidBuildPrompt.fire, and ResponseProcessorContext construction.

Copilot uses AI. Check for mistakes.
@rwoll
Copy link
Member Author

rwoll commented Feb 24, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 24, 2026

@rwoll I've opened a new pull request, #3961, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants