feat: model in tool call stats

This commit is contained in:
Nate 2025-09-10 18:36:29 -07:00
parent 0b7b6c41bb
commit 794e64647d
2 changed files with 8 additions and 3 deletions

View file

@ -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,

View file

@ -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,