Skip to content

Commit 0b6ee2b

Browse files
authored
chat: expose toolResultError as boolean flag (#298320)
* chat: expose toolResultError as boolean flag Converts toolResultError to support both string and boolean types, allowing it to be used as a simple error flag when the specific error message is not needed. The conversion to boolean is safe because the only usage is in a truthy check. - Updates IToolResult interface to accept string | boolean for toolResultError - Adds conversion logic in extHostTypeConverters for boolean mapping - Passes the error flag through the main thread language model tools Refs #298226 (Commit message generated by Copilot) * fix
1 parent 4a32ff3 commit 0b6ee2b

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/vs/workbench/api/browser/mainThreadLanguageModelTools.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export class MainThreadLanguageModelTools extends Disposable implements MainThre
6666
// Only return content and metadata to EH
6767
const out: Dto<IToolResult> = {
6868
content: result.content,
69-
toolMetadata: result.toolMetadata
69+
toolMetadata: result.toolMetadata,
70+
toolResultError: result.toolResultError,
7071
};
7172
return toolResultHasBuffers(result) ? new SerializableObjectWithBuffers(out) : out;
7273
}

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,6 +3873,9 @@ export namespace LanguageModelToolResult {
38733873
if (result.toolMetadata !== undefined) {
38743874
toolResult.toolMetadata = result.toolMetadata;
38753875
}
3876+
if (result.toolResultError) {
3877+
toolResult.hasError = !!result.toolResultError;
3878+
}
38763879
return toolResult;
38773880
}
38783881

@@ -3938,6 +3941,7 @@ export namespace LanguageModelToolResult {
39383941
toolResultMessage: MarkdownString.fromStrict(result.toolResultMessage),
39393942
toolResultDetails: detailsDto,
39403943
toolMetadata: result.toolMetadata,
3944+
toolResultError: result.hasError,
39413945
};
39423946

39433947
return hasBuffers ? new SerializableObjectWithBuffers(dto) : dto;

src/vs/workbench/contrib/chat/common/tools/languageModelToolsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export interface IToolResult {
265265
content: (IToolResultPromptTsxPart | IToolResultTextPart | IToolResultDataPart)[];
266266
toolResultMessage?: string | IMarkdownString;
267267
toolResultDetails?: Array<URI | Location> | IToolResultInputOutputDetails | IToolResultOutputDetails;
268-
toolResultError?: string;
268+
toolResultError?: string | boolean;
269269
toolMetadata?: unknown;
270270
/** Whether to ask the user to confirm these tool results. Overrides {@link IToolConfirmationMessages.confirmResults}. */
271271
confirmResults?: boolean;

src/vs/workbench/contrib/chat/test/browser/tools/languageModelToolsService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3905,7 +3905,7 @@ suite('LanguageModelToolsService', () => {
39053905

39063906
// Verify error result returned
39073907
assert.ok(result.toolResultError);
3908-
assert.ok(result.toolResultError.includes('Destructive operations require approval'));
3908+
assert.ok((result.toolResultError as string).includes('Destructive operations require approval'));
39093909
assert.strictEqual(result.content[0].kind, 'text');
39103910
assert.ok((result.content[0] as IToolResultTextPart).value.includes('Tool execution denied'));
39113911

0 commit comments

Comments
 (0)