Skip to content

Commit 2673e1f

Browse files
authored
Implement copilot token flag for agent mode (microsoft#257892)
* Implement copilot token flag for agent mode * include account tag
1 parent 77b9e36 commit 2673e1f

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/vs/base/common/policy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export type PolicyName = string;
88
export enum PolicyTag {
99
Account = 'ACCOUNT',
1010
MCP = 'MCP',
11-
Preview = 'PREVIEW'
11+
Preview = 'PREVIEW',
12+
Agent = 'AGENT',
1213
}
1314

1415
export interface IPolicy {

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ configurationRegistry.registerConfiguration({
385385
policy: {
386386
name: 'ChatAgentMode',
387387
minimumVersion: '1.99',
388+
tags: [PolicyTag.Account, PolicyTag.Agent]
388389
}
389390
},
390391
[ChatConfiguration.EnableMath]: {

src/vs/workbench/services/accounts/common/defaultAccount.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface IDefaultAccount {
4949
readonly completions: number;
5050
};
5151
readonly limited_user_reset_date?: string;
52+
readonly chat_agent_enabled?: boolean;
5253
}
5354

5455
interface IChatEntitlementsResponse {
@@ -250,6 +251,7 @@ export class DefaultAccountManagementContribution extends Disposable implements
250251
return {
251252
// Editor preview features are disabled if the flag is present and set to 0
252253
chat_preview_features_enabled: tokenMap.get('editor_preview_features') !== '0',
254+
chat_agent_enabled: tokenMap.get('chat_agent_enabled') !== '0',
253255
// MCP is disabled if the flag is present and set to 0
254256
mcp: tokenMap.get('mcp') !== '0',
255257
};

src/vs/workbench/services/policies/common/accountPolicyService.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import { IDefaultAccountService } from '../../accounts/common/defaultAccount.js'
1313
interface IAccountPolicy {
1414
readonly chatPreviewFeaturesEnabled: boolean;
1515
readonly mcpEnabled: boolean;
16+
readonly chatAgentEnabled: boolean;
1617
}
1718

1819
export class AccountPolicyService extends AbstractPolicyService implements IPolicyService {
1920
private accountPolicy: IAccountPolicy = {
2021
chatPreviewFeaturesEnabled: true,
21-
mcpEnabled: true
22+
mcpEnabled: true,
23+
chatAgentEnabled: true
2224
};
2325
constructor(
2426
@ILogService private readonly logService: ILogService,
@@ -30,12 +32,14 @@ export class AccountPolicyService extends AbstractPolicyService implements IPoli
3032
.then(account => {
3133
this._update({
3234
chatPreviewFeaturesEnabled: account?.chat_preview_features_enabled ?? true,
33-
mcpEnabled: account?.mcp ?? true
35+
mcpEnabled: account?.mcp ?? true,
36+
chatAgentEnabled: account?.chat_agent_enabled ?? true
3437
});
3538
this._register(this.defaultAccountService.onDidChangeDefaultAccount(
3639
account => this._update({
3740
chatPreviewFeaturesEnabled: account?.chat_preview_features_enabled ?? true,
38-
mcpEnabled: account?.mcp ?? true
41+
mcpEnabled: account?.mcp ?? true,
42+
chatAgentEnabled: account?.chat_agent_enabled ?? true
3943
})
4044
));
4145
});
@@ -84,6 +88,9 @@ export class AccountPolicyService extends AbstractPolicyService implements IPoli
8488
else if (hasAllTags(policy, [PolicyTag.Account, PolicyTag.MCP])) {
8589
updateIfNeeded(key, policy, this.accountPolicy?.mcpEnabled);
8690
}
91+
else if (hasAllTags(policy, [PolicyTag.Account, PolicyTag.Agent])) {
92+
updateIfNeeded(key, policy, this.accountPolicy?.chatAgentEnabled);
93+
}
8794
}
8895

8996
if (updated.length) {

0 commit comments

Comments
 (0)