@adminforth/agent 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/toolCallEvents.ts +20 -2
- package/dist/agent/toolCallEvents.js +15 -2
- package/package.json +1 -1
package/agent/toolCallEvents.ts
CHANGED
|
@@ -26,19 +26,37 @@ const TOOL_MESSAGE_DEBUG_KEYS = new Set([
|
|
|
26
26
|
"response_metadata",
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
+
function getToolCallDebugPayload(outputRecord: Record<string, unknown>) {
|
|
30
|
+
const lcKwargs =
|
|
31
|
+
typeof outputRecord.lc_kwargs === "object" && outputRecord.lc_kwargs !== null
|
|
32
|
+
? outputRecord.lc_kwargs as Record<string, unknown>
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
if (lcKwargs && "tool_call_id" in lcKwargs) {
|
|
36
|
+
return lcKwargs;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if ("tool_call_id" in outputRecord) {
|
|
40
|
+
return outputRecord;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
function sanitizeToolCallOutputForDebug(output: unknown) {
|
|
30
47
|
if (typeof output !== "object" || output === null) {
|
|
31
48
|
return output;
|
|
32
49
|
}
|
|
33
50
|
|
|
34
51
|
const outputRecord = output as Record<string, unknown>;
|
|
52
|
+
const debugPayload = getToolCallDebugPayload(outputRecord);
|
|
35
53
|
|
|
36
|
-
if (!
|
|
54
|
+
if (!debugPayload) {
|
|
37
55
|
return output;
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
return Object.fromEntries(
|
|
41
|
-
Object.entries(
|
|
59
|
+
Object.entries(debugPayload).filter(([key]) => !TOOL_MESSAGE_DEBUG_KEYS.has(key)),
|
|
42
60
|
);
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -6,15 +6,28 @@ const TOOL_MESSAGE_DEBUG_KEYS = new Set([
|
|
|
6
6
|
"additional_kwargs",
|
|
7
7
|
"response_metadata",
|
|
8
8
|
]);
|
|
9
|
+
function getToolCallDebugPayload(outputRecord) {
|
|
10
|
+
const lcKwargs = typeof outputRecord.lc_kwargs === "object" && outputRecord.lc_kwargs !== null
|
|
11
|
+
? outputRecord.lc_kwargs
|
|
12
|
+
: null;
|
|
13
|
+
if (lcKwargs && "tool_call_id" in lcKwargs) {
|
|
14
|
+
return lcKwargs;
|
|
15
|
+
}
|
|
16
|
+
if ("tool_call_id" in outputRecord) {
|
|
17
|
+
return outputRecord;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
9
21
|
function sanitizeToolCallOutputForDebug(output) {
|
|
10
22
|
if (typeof output !== "object" || output === null) {
|
|
11
23
|
return output;
|
|
12
24
|
}
|
|
13
25
|
const outputRecord = output;
|
|
14
|
-
|
|
26
|
+
const debugPayload = getToolCallDebugPayload(outputRecord);
|
|
27
|
+
if (!debugPayload) {
|
|
15
28
|
return output;
|
|
16
29
|
}
|
|
17
|
-
return Object.fromEntries(Object.entries(
|
|
30
|
+
return Object.fromEntries(Object.entries(debugPayload).filter(([key]) => !TOOL_MESSAGE_DEBUG_KEYS.has(key)));
|
|
18
31
|
}
|
|
19
32
|
export function createToolCallTracker(params) {
|
|
20
33
|
var _a, _b;
|