Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check agent experiment when submitting request, too
Browse files Browse the repository at this point in the history
roblourens committed Jan 31, 2025
1 parent 5a67fc1 commit 16fb7d3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/vs/workbench/contrib/chat/common/chatServiceImpl.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import { Progress } from '../../../../platform/progress/common/progress.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js';
import { IExtensionService } from '../../../services/extensions/common/extensions.js';
import { ChatAgentLocation, IChatAgent, IChatAgentCommand, IChatAgentData, IChatAgentHistoryEntry, IChatAgentRequest, IChatAgentResult, IChatAgentService } from './chatAgents.js';
import { ChatModel, ChatRequestModel, ChatRequestRemovalReason, IChatModel, IChatRequestModel, IChatRequestVariableData, IChatResponseModel, IExportableChatData, ISerializableChatData, ISerializableChatDataIn, ISerializableChatsData, normalizeSerializableChatData, toChatHistoryContent, updateRanges } from './chatModel.js';
@@ -138,7 +139,8 @@ export class ChatService extends Disposable implements IChatService {
@IChatSlashCommandService private readonly chatSlashCommandService: IChatSlashCommandService,
@IChatVariablesService private readonly chatVariablesService: IChatVariablesService,
@IChatAgentService private readonly chatAgentService: IChatAgentService,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWorkbenchAssignmentService private readonly experimentService: IWorkbenchAssignmentService,
) {
super();

@@ -687,6 +689,7 @@ export class ChatService extends Disposable implements IChatService {
const agent = (detectedAgent ?? agentPart?.agent ?? defaultAgent)!;
const command = detectedCommand ?? agentSlashCommandPart?.command;
await this.extensionService.activateByEvent(`onChatParticipant:${agent.id}`);
await this.checkAgentAllowed(agent);

// Recompute history in case the agent or command changed
const history = this.getHistoryEntriesFromModel(requests, model.sessionId, location, agent.id);
@@ -811,6 +814,15 @@ export class ChatService extends Disposable implements IChatService {
};
}

private async checkAgentAllowed(agent: IChatAgentData): Promise<void> {
if (agent.isToolsAgent) {
const enabled = await this.experimentService.getTreatment<boolean>('chatAgentEnabled');
if (enabled === false) {
throw new Error('Agent is currently disabled');
}
}
}

private attachmentKindsForTelemetry(variableData: IChatRequestVariableData): string[] {
// TODO this shows why attachments still have to be cleaned up somewhat
return variableData.variables.map(v => {

0 comments on commit 16fb7d3

Please sign in to comment.