diff --git a/gui/src/redux/thunks/callToolById.ts b/gui/src/redux/thunks/callToolById.ts index 32898f30e..2fee37ca5 100644 --- a/gui/src/redux/thunks/callToolById.ts +++ b/gui/src/redux/thunks/callToolById.ts @@ -11,10 +11,10 @@ import { setToolCallCalling, updateToolCallOutput, } from "../slices/sessionSlice"; +import { DEFAULT_TOOL_SETTING } from "../slices/uiSlice"; import { ThunkApiType } from "../store"; import { findToolCallById, logToolUsage } from "../util"; import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; -import { DEFAULT_TOOL_SETTING } from "../slices/uiSlice"; export const callToolById = createAsyncThunk< void, @@ -43,14 +43,15 @@ export const callToolById = createAsyncThunk< DEFAULT_TOOL_SETTING; const isAutoApproved = toolPolicy === "allowedWithoutPermission"; + const selectedChatModel = selectSelectedChatModel(state); + posthog.capture("gui_tool_call_decision", { + model: selectedChatModel, decision: isAutoApproved ? "auto_accept" : "accept", toolName: toolCallState.toolCall.function.name, toolCallId: toolCallId, }); - const selectedChatModel = selectSelectedChatModel(state); - if (!selectedChatModel) { throw new Error("No model selected"); } @@ -129,6 +130,7 @@ export const callToolById = createAsyncThunk< // Capture telemetry for tool call execution outcome with duration const duration_ms = Date.now() - startTime; posthog.capture("gui_tool_call_outcome", { + model: selectedChatModel, succeeded: errorMessage === undefined, toolName: toolCallState.toolCall.function.name, errorMessage: errorMessage, diff --git a/gui/src/redux/thunks/cancelToolCall.ts b/gui/src/redux/thunks/cancelToolCall.ts index 48d498e0d..141ee3229 100644 --- a/gui/src/redux/thunks/cancelToolCall.ts +++ b/gui/src/redux/thunks/cancelToolCall.ts @@ -1,5 +1,6 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import posthog from "posthog-js"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { cancelToolCall as cancelToolCallAction, updateToolCallOutput, @@ -19,6 +20,7 @@ export const cancelToolCallThunk = createAsyncThunk< ThunkApiType >("chat/cancelToolCall", async ({ toolCallId }, { dispatch, getState }) => { const state = getState(); + const selectedChatModel = selectSelectedChatModel(state); const continueAfterToolRejection = state.config.config.ui?.continueAfterToolRejection; const toolCallState = findToolCallById(state.session.history, toolCallId); @@ -26,6 +28,7 @@ export const cancelToolCallThunk = createAsyncThunk< if (toolCallState) { // Track tool call rejection posthog.capture("gui_tool_call_decision", { + model: selectedChatModel, decision: "reject", toolName: toolCallState.toolCall.function.name, toolCallId: toolCallId,