mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-11 14:04:49 -05:00
* fix: filter images from telemetry render to prevent supportsVision crash (fixes #315729) The sendInvokedToolTelemetry function renders tool results in a fire-and-forget async call to count tokens. This async render can outlive the parent PromptRenderer's DI tree, which is disposed after the parent render completes (PromptRenderer.render() line 133). When PrimitiveToolResult is instantiated during the telemetry render after the parent DI is disposed, @IPromptEndpoint resolves to undefined, causing 'Cannot read properties of undefined (reading supportsVision)' in PrimitiveToolResult.onImage(). Fix: filter out image data parts before passing content to the telemetry renderer. Images trigger onImage() which accesses this.endpoint.supportsVision — the only code path that crashes. Images contribute ~1 token each in the tokenizer, so the impact on token counting is minimal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: make IPromptEndpoint and IAuthenticationService optional in PrimitiveToolResult Address review feedback from @connor4312: these DI services should not be expected to be available when PrimitiveToolResult is rendered in the fire-and-forget telemetry context where the parent DI tree may be disposed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Bryan Chen <41454397+bryanchen-d@users.noreply.github.com>