feat: add autoAttachReferences option to chat session extension point (#302508)

* feat: add autoAttachReferences option to chat session extension point

This allows us to opt-in/out in to auto-attaching references.

Some external agents will manage auto attaching references by themselves, this allows them to do so without Core injecting stuff automatically.

* fix: treat autoAttachReferences as enabled by default, fix description

Address PR review feedback:
- Only skip instruction auto-attachment when autoAttachReferences is
  explicitly false, preserving existing behavior for session types that
  don't specify the flag.
- Update schema description to accurately reflect what the flag controls
  (instruction files only, not implicit context) and correct the default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update autoAttachReferences default to false and improve description
This commit is contained in:
Tyler James Leonhardt
2026-03-17 15:02:58 -07:00
committed by GitHub
parent b97d411665
commit 874449ab44
3 changed files with 15 additions and 0 deletions

View File

@@ -216,6 +216,11 @@ const extensionPoint = ExtensionsRegistry.registerExtensionPoint<IChatSessionsEx
description: localize('chatSessionsExtPoint.requiresCustomModels', 'When set, the chat session will show a filtered model picker that prefers custom models. This enables the use of standard model picker with contributed sessions.'),
type: 'boolean',
default: false
},
autoAttachReferences: {
description: localize('chatSessionsExtPoint.autoAttachReferences', 'Whether to automatically attach instruction files to chat requests for this session type.'),
type: 'boolean',
default: false
}
},
required: ['type', 'name', 'displayName', 'description'],

View File

@@ -2714,6 +2714,11 @@ export class ChatWidget extends Disposable implements IChatWidget {
* - instructions referenced in an already included instruction file
*/
private async _autoAttachInstructions({ attachedContext }: IChatRequestInputOptions): Promise<void> {
const contribution = this._lockedAgent ? this.chatSessionsService.getChatSessionContribution(this._lockedAgent.id) : undefined;
if (!contribution?.autoAttachReferences) {
this.logService.debug(`ChatWidget#_autoAttachInstructions: skipped, autoAttachReferences is disabled`);
return;
}
this.logService.debug(`ChatWidget#_autoAttachInstructions: prompt files are always enabled`);
const enabledTools = this.input.currentModeKind === ChatModeKind.Agent ? this.input.selectedToolsModel.userSelectedTools.get() : undefined;
const enabledSubAgents = this.input.currentModeKind === ChatModeKind.Agent ? this.input.currentModeObs.get().agents?.get() : undefined;

View File

@@ -94,6 +94,11 @@ export interface IChatSessionsExtensionPoint {
*/
readonly customAgentTarget?: Target;
readonly requiresCustomModels?: boolean;
/**
* Decides whether to automatically attach instruction files to chat requests
* for this session type. Defaults to false when not specified.
*/
readonly autoAttachReferences?: boolean;
}
export interface IChatSessionItem {