Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chat.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,10 @@ class ChatAgentSettingContribution extends Disposable implements IWorkbenchContr
const treatmentId = this.entitlementService.entitlement === ChatEntitlement.Free ?
'chatAgentMaxRequestsFree' :
'chatAgentMaxRequestsPro';
this.experimentService.getTreatment<number>(treatmentId).then(value => {
Promise.all([
this.experimentService.getTreatment<number>(treatmentId),
this.experimentService.getTreatment<number>('chatAgentMaxRequestsLimit')
]).then(([value, maxLimit]) => {
const defaultValue = value ?? (this.entitlementService.entitlement === ChatEntitlement.Free ? 25 : 25);
const node: IConfigurationNode = {
id: 'chatSidebar',
Expand All @@ -972,6 +975,7 @@ class ChatAgentSettingContribution extends Disposable implements IWorkbenchContr
type: 'number',
markdownDescription: nls.localize('chat.agent.maxRequests', "The maximum number of requests to allow per-turn when using an agent. When the limit is reached, will ask to confirm to continue."),
default: defaultValue,
maximum: maxLimit,
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The maxLimit value from the experiment service can be undefined if the treatment is not set. When maximum: undefined is set in the configuration schema, it should either be omitted from the properties object or have a fallback value. Consider handling this case explicitly:

const configProperty: IConfigurationPropertySchema = {
	type: 'number',
	markdownDescription: nls.localize('chat.agent.maxRequests', "The maximum number of requests to allow per-turn when using an agent. When the limit is reached, will ask to confirm to continue."),
	default: defaultValue,
};
if (maxLimit !== undefined) {
	configProperty.maximum = maxLimit;
}

This ensures the maximum property is only added when a valid limit is available from the experiment.

See below for a potential fix:

						'chat.agent.maxRequests': (() => {
							const prop: any = {
								type: 'number',
								markdownDescription: nls.localize('chat.agent.maxRequests', "The maximum number of requests to allow per-turn when using an agent. When the limit is reached, will ask to confirm to continue."),
								default: defaultValue,
							};
							if (maxLimit !== undefined) {
								prop.maximum = maxLimit;
							}
							return prop;
						})(),

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

This won't actually work as-is because this only drives a validation warning, it won't limit the real value. The setting is read in the extension and we would have to enforce it there.

},
}
};
Expand Down
Loading