Changesets · Branches · Tags · Compare
| Changeset | a47569a560cb3b16062fc4872245c5032927142d87721502cabeb29210f3cf21 |
|---|---|
| Author | adarshramiyer <adarsh.r.iyer@gmail.com> · 2025-06-25 18:30 -07:00 |
| Committer | adarshramiyer <adarsh.r.iyer@gmail.com> · 2025-06-25 18:30 -07:00 |
| Parents | 93242962278a |
4 files changed
modified gui/src/redux/slices/sessionSlice.ts +23 −0
| @@ -18,7 +18,9 @@ | ||
| 18 | 18 | RuleWithSource, |
| 19 | 19 | Session, |
| 20 | 20 | SessionMetadata, |
| 21 | + ToolCallState, | |
| 21 | 22 | } from "core"; |
| 23 | +import { safeParseToolCallArgs } from "core/tools/parseArgs"; | |
| 22 | 24 | import { NEW_SESSION_TITLE } from "core/util/constants"; |
| 23 | 25 | import { renderChatMessage } from "core/util/messageContent"; |
| 24 | 26 | import { findUriInDirs, getUriPathBasename } from "core/util/uri"; |
| @@ -28,6 +30,25 @@ | ||
| 28 | 30 | import { streamResponseThunk } from "../thunks/streamResponse"; |
| 29 | 31 | import { findCurrentToolCall, findToolCall } from "../util"; |
| 30 | 32 | |
| 33 | +const getIdeMessenger = () => (window as any).ideMessenger; | |
| 34 | + | |
| 35 | +const logToolUsage = (toolCallState: ToolCallState, success: boolean) => { | |
| 36 | + const ideMessenger = getIdeMessenger(); | |
| 37 | + if (ideMessenger) { | |
| 38 | + ideMessenger.post("devdata/log", { | |
| 39 | + name: "toolUsage", | |
| 40 | + data: { | |
| 41 | + toolCallId: toolCallState.toolCallId, | |
| 42 | + functionName: toolCallState.toolCall.function.name, | |
| 43 | + functionArgs: toolCallState.toolCall.function.arguments, | |
| 44 | + parsedArgs: safeParseToolCallArgs(toolCallState.toolCall), | |
| 45 | + succeeded: success, | |
| 46 | + output: toolCallState.output || [], | |
| 47 | + }, | |
| 48 | + }); | |
| 49 | + } | |
| 50 | +}; | |
| 51 | + | |
| 31 | 52 | // We need this to handle reorderings (e.g. a mid-array deletion) of the messages array. |
| 32 | 53 | // The proper fix is adding a UUID to all chat messages, but this is the temp workaround. |
| 33 | 54 | export type ChatHistoryItemWithMessageId = ChatHistoryItem & { |
| @@ -559,6 +580,7 @@ | ||
| 559 | 580 | ); |
| 560 | 581 | if (toolCallState) { |
| 561 | 582 | toolCallState.status = "errored"; |
| 583 | + logToolUsage(toolCallState, false); | |
| 562 | 584 | } |
| 563 | 585 | }, |
| 564 | 586 | acceptToolCall: ( |
| @@ -573,6 +595,7 @@ | ||
| 573 | 595 | ); |
| 574 | 596 | if (toolCallState) { |
| 575 | 597 | toolCallState.status = "done"; |
| 598 | + logToolUsage(toolCallState, true); | |
| 576 | 599 | } |
| 577 | 600 | }, |
| 578 | 601 | setToolCallCalling: ( |
modified packages/config-yaml/src/schemas/data/index.ts +8 −0
| @@ -42,6 +42,11 @@ | ||
| 42 | 42 | tokensGeneratedEventSchema_0_2_0, |
| 43 | 43 | tokensGeneratedEventSchema_0_2_0_noCode, |
| 44 | 44 | } from "./tokensGenerated/v0.2.0.js"; |
| 45 | +import { toolUsageEventAllSchema } from "./toolUsage/index.js"; | |
| 46 | +import { | |
| 47 | + toolUsageEventSchema_0_2_0, | |
| 48 | + toolUsageEventSchema_0_2_0_noCode, | |
| 49 | +} from "./toolUsage/v0.2.0.js"; | |
| 45 | 50 | |
| 46 | 51 | const semverRegex = |
| 47 | 52 | /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/; |
| @@ -72,6 +77,7 @@ | ||
| 72 | 77 | tokensGenerated: tokensGeneratedEventAllSchema, |
| 73 | 78 | chatInteraction: chatInteractionEventAllSchema, |
| 74 | 79 | editInteraction: editInteractionEventAllSchema, |
| 80 | + toolUsage: toolUsageEventAllSchema, | |
| 75 | 81 | }); |
| 76 | 82 | |
| 77 | 83 | // Version and level specific schemas are organized here |
| @@ -97,6 +103,7 @@ | ||
| 97 | 103 | tokensGenerated: tokensGeneratedEventSchema_0_2_0, |
| 98 | 104 | chatInteraction: chatInteractionEventSchema_0_2_0, |
| 99 | 105 | editInteraction: editInteractionEventSchema_0_2_0, |
| 106 | + toolUsage: toolUsageEventSchema_0_2_0, | |
| 100 | 107 | }, |
| 101 | 108 | noCode: { |
| 102 | 109 | autocomplete: autocompleteEventSchema_0_2_0_noCode, |
| @@ -104,6 +111,7 @@ | ||
| 104 | 111 | tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode, |
| 105 | 112 | chatInteraction: chatInteractionEventSchema_0_2_0_noCode, |
| 106 | 113 | editInteraction: editInteractionEventSchema_0_2_0_noCode, |
| 114 | + toolUsage: toolUsageEventSchema_0_2_0_noCode, | |
| 107 | 115 | }, |
| 108 | 116 | }, |
| 109 | 117 | }; |
modified packages/config-yaml/src/schemas/data/toolUsage/index.ts +1 −0
| @@ -6,5 +6,6 @@ | ||
| 6 | 6 | functionName: z.string(), |
| 7 | 7 | functionArgs: z.string(), |
| 8 | 8 | parsedArgs: z.any(), |
| 9 | + succeeded: z.boolean(), | |
| 9 | 10 | output: z.array(z.any()).optional(), |
| 10 | 11 | }); |
modified packages/config-yaml/src/schemas/data/toolUsage/v0.2.0.ts +2 −1
| @@ -14,10 +14,11 @@ | ||
| 14 | 14 | functionName: true, |
| 15 | 15 | functionArgs: true, |
| 16 | 16 | parsedArgs: true, |
| 17 | + succeeded: true, | |
| 17 | 18 | output: true, |
| 18 | 19 | }); |
| 19 | 20 | |
| 20 | -export const autocompleteEventSchema_0_2_0_noCode = | |
| 21 | +export const toolUsageEventSchema_0_2_0_noCode = | |
| 21 | 22 | toolUsageEventSchema_0_2_0.omit({ |
| 22 | 23 | functionArgs: true, |
| 23 | 24 | parsedArgs: true, |