Skip to content

Commit ac857d4

Browse files
Copilotaeschli
andauthored
Fix: Honor deprecated infer: false in custom agent visibility (#297003)
* Initial plan * fix: honor deprecated infer:false in custom agent visibility Co-authored-by: aeschli <6461412+aeschli@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aeschli <6461412+aeschli@users.noreply.github.com>
1 parent d17f65c commit ac857d4

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export class PromptsService extends Disposable implements IPromptsService {
711711
}
712712
const visibility = {
713713
userInvocable: ast.header.userInvocable !== false,
714-
agentInvocable: ast.header.infer === true || ast.header.disableModelInvocation !== true,
714+
agentInvocable: ast.header.infer !== undefined ? ast.header.infer === true : ast.header.disableModelInvocation !== true,
715715
} satisfies ICustomAgentVisibility;
716716

717717
let model = ast.header.model;

src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,60 @@ suite('PromptsService', () => {
13381338
);
13391339
});
13401340

1341+
test('header with infer: false sets agentInvocable to false', async () => {
1342+
const rootFolderName = 'custom-agents-infer-false';
1343+
const rootFolder = `/${rootFolderName}`;
1344+
const rootFolderUri = URI.file(rootFolder);
1345+
1346+
workspaceContextService.setWorkspace(testWorkspace(rootFolderUri));
1347+
1348+
await mockFiles(fileService, [
1349+
{
1350+
path: `${rootFolder}/.github/agents/agent-infer-false.agent.md`,
1351+
contents: [
1352+
'---',
1353+
'description: \'Agent with infer: false.\'',
1354+
'infer: false',
1355+
'---',
1356+
'I should not be invocable by the model.',
1357+
]
1358+
},
1359+
{
1360+
path: `${rootFolder}/.github/agents/agent-infer-true.agent.md`,
1361+
contents: [
1362+
'---',
1363+
'description: \'Agent with infer: true.\'',
1364+
'infer: true',
1365+
'---',
1366+
'I should be invocable by the model.',
1367+
]
1368+
},
1369+
{
1370+
path: `${rootFolder}/.github/agents/agent-no-infer.agent.md`,
1371+
contents: [
1372+
'---',
1373+
'description: \'Agent without infer.\'',
1374+
'---',
1375+
'I should default to being invocable by the model.',
1376+
]
1377+
}
1378+
]);
1379+
1380+
const result = (await service.getCustomAgents(CancellationToken.None)).map(agent => ({ ...agent, uri: URI.from(agent.uri) }));
1381+
1382+
const inferFalseAgent = result.find(a => a.name === 'agent-infer-false');
1383+
assert.ok(inferFalseAgent, 'Should find agent with infer: false');
1384+
assert.strictEqual(inferFalseAgent.visibility.agentInvocable, false, 'infer: false should set agentInvocable to false');
1385+
1386+
const inferTrueAgent = result.find(a => a.name === 'agent-infer-true');
1387+
assert.ok(inferTrueAgent, 'Should find agent with infer: true');
1388+
assert.strictEqual(inferTrueAgent.visibility.agentInvocable, true, 'infer: true should set agentInvocable to true');
1389+
1390+
const noInferAgent = result.find(a => a.name === 'agent-no-infer');
1391+
assert.ok(noInferAgent, 'Should find agent without infer');
1392+
assert.strictEqual(noInferAgent.visibility.agentInvocable, true, 'missing infer should default agentInvocable to true');
1393+
});
1394+
13411395
test('agents from user data folder', async () => {
13421396
const rootFolderName = 'custom-agents-user-data';
13431397
const rootFolder = `/${rootFolderName}`;

0 commit comments

Comments
 (0)