@cognipeer/agent-sdk 0.4.1 → 0.4.3
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/dist/index.cjs +16 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +16 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2150,12 +2150,10 @@ function safeStringify(value) {
|
|
|
2150
2150
|
if (typeof value === "string") return value;
|
|
2151
2151
|
try {
|
|
2152
2152
|
const serialized = JSON.stringify(value);
|
|
2153
|
-
|
|
2154
|
-
return serialized;
|
|
2155
|
-
}
|
|
2153
|
+
return typeof serialized === "string" ? serialized : String(value);
|
|
2156
2154
|
} catch {
|
|
2155
|
+
return String(value);
|
|
2157
2156
|
}
|
|
2158
|
-
return String(value);
|
|
2159
2157
|
}
|
|
2160
2158
|
function summarizeObject(value) {
|
|
2161
2159
|
if (value == null) return "null";
|
|
@@ -2199,11 +2197,10 @@ function resolveToolResponsePolicy(toolName, output, config) {
|
|
|
2199
2197
|
} else if (classification === "redundant") {
|
|
2200
2198
|
retentionPolicy = byTool || "drop";
|
|
2201
2199
|
}
|
|
2200
|
+
const summary = summarizeObject(output);
|
|
2202
2201
|
if (retentionPolicy === "keep_full") {
|
|
2203
|
-
|
|
2204
|
-
return { classification, retentionPolicy, content: serialized, rawOutput: output, summary: summary2, tokenCount };
|
|
2202
|
+
return { classification, retentionPolicy, content: serialized, rawOutput: output, summary, tokenCount };
|
|
2205
2203
|
}
|
|
2206
|
-
const summary = summarizeObject(output);
|
|
2207
2204
|
if (retentionPolicy === "keep_structured") {
|
|
2208
2205
|
return { classification, retentionPolicy, content: summary, rawOutput: output, summary, tokenCount };
|
|
2209
2206
|
}
|
|
@@ -2506,7 +2503,15 @@ function createToolsNode(initialTools, opts) {
|
|
|
2506
2503
|
status: "success"
|
|
2507
2504
|
});
|
|
2508
2505
|
}
|
|
2509
|
-
|
|
2506
|
+
let toolMessageContent = responsePolicy.content;
|
|
2507
|
+
if (responsePolicy.retentionPolicy === "summarize_archive") {
|
|
2508
|
+
toolMessageContent = `ARCHIVED_TOOL_RESPONSE [executionId=${executionId}]: ${responsePolicy.summary}
|
|
2509
|
+
Use get_tool_response with executionId "${executionId}" to retrieve the full output.`;
|
|
2510
|
+
} else if (responsePolicy.retentionPolicy === "drop") {
|
|
2511
|
+
toolMessageContent = `DROPPED_TOOL_RESPONSE [executionId=${executionId}]: ${responsePolicy.summary}
|
|
2512
|
+
Use get_tool_response with executionId "${executionId}" to retrieve the full output.`;
|
|
2513
|
+
}
|
|
2514
|
+
appended.push({ role: "tool", content: toolMessageContent, tool_call_id: tc.id || `${tc.name}_${appended.length}`, name: tc.name });
|
|
2510
2515
|
onEvent?.({ type: "tool_call", phase: "success", name: toolName, id: tc.id, args, result: output, durationMs });
|
|
2511
2516
|
onProgress?.({ stage: "tools", message: `Tool ${tc.name} completed`, detail: { durationMs } });
|
|
2512
2517
|
if (needsApproval && approvalEntry) {
|
|
@@ -3065,8 +3070,8 @@ function createAgent(opts) {
|
|
|
3065
3070
|
}
|
|
3066
3071
|
}
|
|
3067
3072
|
let maxTok;
|
|
3068
|
-
if (opts.summarization && typeof opts.summarization === "object"
|
|
3069
|
-
maxTok = opts.summarization.maxTokens;
|
|
3073
|
+
if (opts.summarization && typeof opts.summarization === "object") {
|
|
3074
|
+
maxTok = opts.summarization.summaryTriggerTokens || opts.summarization.maxTokens;
|
|
3070
3075
|
}
|
|
3071
3076
|
if (maxTok === void 0) {
|
|
3072
3077
|
maxTok = 5e4;
|
|
@@ -4215,7 +4220,7 @@ function createContextTools(stateRef, opts) {
|
|
|
4215
4220
|
}
|
|
4216
4221
|
const getTool = createTool({
|
|
4217
4222
|
name: "get_tool_response",
|
|
4218
|
-
description: "RETRIEVE tool execution response
|
|
4223
|
+
description: "RETRIEVE the full output of a tool execution whose response was archived or dropped. When a tool response appears as 'ARCHIVED_TOOL_RESPONSE [executionId=xxx]' or 'DROPPED_TOOL_RESPONSE [executionId=xxx]', pass that exact executionId to this tool to get the complete data. You can also pass the tool_call_id from your original tool call.",
|
|
4219
4224
|
schema: zod.z.object({ executionId: zod.z.string().describe("Tool execution id") }),
|
|
4220
4225
|
func: async ({ executionId }) => {
|
|
4221
4226
|
const matchesExecution = (t) => t?.executionId === executionId || t?.tool_call_id === executionId;
|