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 @@ -3,7 +3,7 @@
* Will be deleted or merged.
*/

import * as path from 'path'

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Do not import Node.js builtin module "path"

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "path"
import {
ChatTriggerType,
GenerateAssistantResponseCommandInput,
Expand Down Expand Up @@ -641,6 +641,10 @@
})
break
}

if (toolUse.name) {
this.#telemetryController.emitToolUseSuggested(toolUse, session.conversationId || '')
}
} catch (err) {
// If we did not approve a tool to be used or the user stopped the response, bubble this up to interrupt agentic loop
if (CancellationError.isUserCancelled(err) || err instanceof ToolApprovalException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
RelevancyVoteType,
isClientTelemetryEvent,
} from './clientTelemetry'
import { UserIntent } from '@amzn/codewhisperer-streaming'
import { ToolUse, UserIntent } from '@amzn/codewhisperer-streaming'
import { TriggerContext } from '../contexts/triggerContext'

import { CredentialsProvider, Logging } from '@aws/language-server-runtimes/server-interface'
Expand Down Expand Up @@ -166,6 +166,19 @@ export class ChatTelemetryController {
}
}

public emitToolUseSuggested(toolUse: ToolUse, conversationId: string) {
this.#telemetry.emitMetric({
name: ChatTelemetryEventName.ToolUseSuggested,
data: {
[CONVERSATION_ID_METRIC_KEY]: conversationId,
cwsprChatConversationType: 'AgenticChatWithToolUse',
credentialStartUrl: this.#credentialsProvider.getConnectionMetadata()?.sso?.startUrl,
cwsprToolName: toolUse.name ?? '',
cwsprToolUseId: toolUse.toolUseId ?? '',
},
})
}

public emitAddMessageMetric(tabId: string, metric: Partial<CombinedConversationEvent>) {
const conversationId = this.getConversationId(tabId)
// Store the customization value associated with the message
Expand Down
12 changes: 11 additions & 1 deletion server/aws-lsp-codewhisperer/src/shared/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export enum ChatTelemetryEventName {
RunCommand = 'amazonq_runCommand',
MessageResponseError = 'amazonq_messageResponseError',
ModifyCode = 'amazonq_modifyCode',
ToolUseSuggested = 'amazonq_toolUseSuggested',
}

export interface ChatTelemetryEventMap {
Expand All @@ -178,6 +179,15 @@ export interface ChatTelemetryEventMap {
[ChatTelemetryEventName.RunCommand]: RunCommandEvent
[ChatTelemetryEventName.MessageResponseError]: MessageResponseErrorEvent
[ChatTelemetryEventName.ModifyCode]: ModifyCodeEvent
[ChatTelemetryEventName.ToolUseSuggested]: ToolUseSuggestedEvent
}

export type ToolUseSuggestedEvent = {
credentialStartUrl?: string
cwsprChatConversationId: string
cwsprChatConversationType: ChatConversationType
cwsprToolName: string
cwsprToolUseId: string
}

export type ModifyCodeEvent = {
Expand Down Expand Up @@ -242,7 +252,7 @@ export enum ChatInteractionType {
ClickBodyLink = 'clickBodyLink',
}

export type ChatConversationType = 'Chat' | 'Assign' | 'Transform' | 'AgenticChat'
export type ChatConversationType = 'Chat' | 'Assign' | 'Transform' | 'AgenticChat' | 'AgenticChatWithToolUse'

export type InteractWithMessageEvent = {
credentialStartUrl?: string
Expand Down
Loading