Elffuss BraidHub

kikocis/continue public

finished out tool usage dev data logging
Changeseta47569a560cb3b16062fc4872245c5032927142d87721502cabeb29210f3cf21
Authoradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-06-25 18:30 -07:00
Committeradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-06-25 18:30 -07:00
Parents93242962278a

Browse the files at this changeset

4 files changed

modified gui/src/redux/slices/sessionSlice.ts +23 −0
@@ -18,7 +18,9 @@
1818 RuleWithSource,
1919 Session,
2020 SessionMetadata,
21+ ToolCallState,
2122 } from "core";
23+import { safeParseToolCallArgs } from "core/tools/parseArgs";
2224 import { NEW_SESSION_TITLE } from "core/util/constants";
2325 import { renderChatMessage } from "core/util/messageContent";
2426 import { findUriInDirs, getUriPathBasename } from "core/util/uri";
@@ -28,6 +30,25 @@
2830 import { streamResponseThunk } from "../thunks/streamResponse";
2931 import { findCurrentToolCall, findToolCall } from "../util";
3032
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+
3152 // We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
3253 // The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
3354 export type ChatHistoryItemWithMessageId = ChatHistoryItem & {
@@ -559,6 +580,7 @@
559580 );
560581 if (toolCallState) {
561582 toolCallState.status = "errored";
583+ logToolUsage(toolCallState, false);
562584 }
563585 },
564586 acceptToolCall: (
@@ -573,6 +595,7 @@
573595 );
574596 if (toolCallState) {
575597 toolCallState.status = "done";
598+ logToolUsage(toolCallState, true);
576599 }
577600 },
578601 setToolCallCalling: (
modified packages/config-yaml/src/schemas/data/index.ts +8 −0
@@ -42,6 +42,11 @@
4242 tokensGeneratedEventSchema_0_2_0,
4343 tokensGeneratedEventSchema_0_2_0_noCode,
4444 } 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";
4550
4651 const semverRegex =
4752 /^(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 @@
7277 tokensGenerated: tokensGeneratedEventAllSchema,
7378 chatInteraction: chatInteractionEventAllSchema,
7479 editInteraction: editInteractionEventAllSchema,
80+ toolUsage: toolUsageEventAllSchema,
7581 });
7682
7783 // Version and level specific schemas are organized here
@@ -97,6 +103,7 @@
97103 tokensGenerated: tokensGeneratedEventSchema_0_2_0,
98104 chatInteraction: chatInteractionEventSchema_0_2_0,
99105 editInteraction: editInteractionEventSchema_0_2_0,
106+ toolUsage: toolUsageEventSchema_0_2_0,
100107 },
101108 noCode: {
102109 autocomplete: autocompleteEventSchema_0_2_0_noCode,
@@ -104,6 +111,7 @@
104111 tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode,
105112 chatInteraction: chatInteractionEventSchema_0_2_0_noCode,
106113 editInteraction: editInteractionEventSchema_0_2_0_noCode,
114+ toolUsage: toolUsageEventSchema_0_2_0_noCode,
107115 },
108116 },
109117 };
modified packages/config-yaml/src/schemas/data/toolUsage/index.ts +1 −0
@@ -6,5 +6,6 @@
66 functionName: z.string(),
77 functionArgs: z.string(),
88 parsedArgs: z.any(),
9+ succeeded: z.boolean(),
910 output: z.array(z.any()).optional(),
1011 });
modified packages/config-yaml/src/schemas/data/toolUsage/v0.2.0.ts +2 −1
@@ -14,10 +14,11 @@
1414 functionName: true,
1515 functionArgs: true,
1616 parsedArgs: true,
17+ succeeded: true,
1718 output: true,
1819 });
1920
20-export const autocompleteEventSchema_0_2_0_noCode =
21+export const toolUsageEventSchema_0_2_0_noCode =
2122 toolUsageEventSchema_0_2_0.omit({
2223 functionArgs: true,
2324 parsedArgs: true,