Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function parseSessionArtifactInput(rawArgs: unknown, toolName: string): I
throw new Error(`Invalid ${toolName} input: type must be one of ${SESSION_ARTIFACT_TYPES.join(', ')}.`);
}
if (typeof args['isArtifact'] !== 'boolean') {
throw new Error(`Invalid ${toolName} input: isArtifact must be a boolean — true for something this session produced, false for a reference.`);
throw new Error(`Invalid ${toolName} input: isArtifact must be a boolean — true for an artifact, false for a reference.`);
}

const artifactType = type as SessionArtifactType;
Expand Down
6 changes: 3 additions & 3 deletions src/vs/platform/agentHost/node/shared/artifactServerTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const addArtifactInputSchema: ToolDefinition['inputSchema'] = {
label: { type: 'string', description: 'Short label shown to the user.' },
isArtifact: {
type: 'boolean',
description: 'Required. `true` for an artifact — something this session produced, such as a pull request or issue it opened, a plan file it wrote outside the workspace, or another side effect of its work. `false` for a reference — something it did not produce but the user should look at, such as the pull request or commit that introduced a bug, or a website that matters for the task.',
description: 'Required. `true` for an artifact. An issue or pull request this session works on is an artifact even if the session did not create it; other artifacts are things the session produced, such as a plan file it wrote outside the workspace or another side effect of its work. `false` for a reference — something the session did not produce but the user should look at because of this task, such as the pull request or commit that introduced a bug, or a website that matters for the task.',
},
link: { type: 'string', description: 'URL of the pull request, issue, commit or website. Required for those kinds.' },
uri: { type: 'string', description: 'Absolute URI including its scheme. For a local file, pass a file URI such as `file:///C:/path/to/file`, not a plain file system path such as `C:\\path\\to\\file`. Required for the `file` and `resource` kinds.' },
Expand All @@ -50,7 +50,7 @@ export const artifactServerToolDefinitions: ToolDefinition[] = [
{
name: ArtifactServerToolName.AddArtifactOrReference,
title: 'Add Artifact or Reference',
description: 'Record an artifact or a reference so it is surfaced next to the chat input. An artifact is something this session produced that is not just an ordinary workspace edit: a pull request or issue it opened, a plan or report file it wrote outside the workspace, or another side effect of its work. A reference is something the session did not produce but the user should look at because of this task: the pull request or commit that introduced a bug, an issue it investigated, or a website worth reading. Set `isArtifact` accordingly. Do not record routine files you merely edited or sessions and chats created with session-management tools.',
description: 'Record an artifact or a reference so it is surfaced next to the chat input. An issue or pull request this session works on is an artifact even if the session did not create it. Other artifacts are notable results the session produced beyond ordinary workspace edits, such as a plan or report file it wrote outside the workspace. A reference is something the session did not produce but the user should look at because of this task: the pull request or commit that introduced a bug, an issue it investigated, or a website worth reading. Set `isArtifact` accordingly. Do not record routine files you merely edited or sessions and chats created with session-management tools.',
inputSchema: addArtifactInputSchema,
annotations: { readOnlyHint: false },
},
Expand Down Expand Up @@ -206,4 +206,4 @@ export function createArtifactServerToolGroup(accessor?: IArtifactServerToolAcce
* The instruction appended to every agent's host instructions while the
* artifact tools are enabled.
*/
export const ARTIFACT_TOOLS_INSTRUCTION = `Record the notable results of your work with \`${ArtifactServerToolName.AddArtifactOrReference}\` (types: ${SESSION_ARTIFACT_TYPES.join(', ')}; use \`${SessionArtifactType.Resource}\` when nothing else fits) so they are surfaced next to the chat input. Pass \`isArtifact: true\` for an artifact — something this session produced beyond ordinary workspace edits, such as a pull request or issue you opened, a plan or report file you wrote outside the workspace, or another side effect of your work. Pass \`isArtifact: false\` for a reference — something you did not produce but the user should look at because of this task, such as the pull request or commit that introduced a bug, an issue you investigated, or a website worth reading. Record each one once, and do not record routine files you merely edited, commits you create unless the user asks for them, or sessions and chats created with session-management tools.`;
export const ARTIFACT_TOOLS_INSTRUCTION = `Record the notable results of your work with \`${ArtifactServerToolName.AddArtifactOrReference}\` (types: ${SESSION_ARTIFACT_TYPES.join(', ')}; use \`${SessionArtifactType.Resource}\` when nothing else fits) so they are surfaced next to the chat input. Pass \`isArtifact: true\` for an artifact. An issue or pull request you work on is an artifact even if you did not create it; other artifacts are notable results you produced beyond ordinary workspace edits, such as a plan or report file you wrote outside the workspace. Pass \`isArtifact: false\` for a reference — something you did not produce but the user should look at because of this task, such as the pull request or commit that introduced a bug, an issue you investigated, or a website worth reading. Record each one once, and do not record routine files you merely edited, commits you create unless the user asks for them, or sessions and chats created with session-management tools.`;
21 changes: 21 additions & 0 deletions src/vs/platform/agentHost/test/node/artifactServerTools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ suite('Artifact Server Tools', () => {
});
});

test('classifies worked-on issues and pull requests as artifacts', () => {
const addDefinition = artifactServerToolDefinitions.find(definition => definition.name === ArtifactServerToolName.AddArtifactOrReference);
const sessionClassification = 'An issue or pull request this session works on is an artifact even if the session did not create it';
const instructionClassification = 'An issue or pull request you work on is an artifact even if you did not create it';

assert.deepStrictEqual({
definition: addDefinition?.description?.includes(sessionClassification),
input: addDefinition?.inputSchema?.properties?.isArtifact,
instruction: ARTIFACT_TOOLS_INSTRUCTION.includes(instructionClassification),
reference: ARTIFACT_TOOLS_INSTRUCTION.includes('something you did not produce but the user should look at because of this task'),
}, {
definition: true,
input: {
type: 'boolean',
description: 'Required. `true` for an artifact. An issue or pull request this session works on is an artifact even if the session did not create it; other artifacts are things the session produced, such as a plan file it wrote outside the workspace or another side effect of its work. `false` for a reference — something the session did not produce but the user should look at because of this task, such as the pull request or commit that introduced a bug, or a website that matters for the task.',
},
instruction: true,
reference: true,
});
});

test('rejects session-management links during execution', async () => {
const sessionUri = 'copilot:/caller';
const stateManager = store.add(new AgentHostStateManager(new NullLogService()));
Expand Down