@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.mjs
CHANGED
|
@@ -2140,12 +2140,10 @@ function safeStringify(value) {
|
|
|
2140
2140
|
if (typeof value === "string") return value;
|
|
2141
2141
|
try {
|
|
2142
2142
|
const serialized = JSON.stringify(value);
|
|
2143
|
-
|
|
2144
|
-
return serialized;
|
|
2145
|
-
}
|
|
2143
|
+
return typeof serialized === "string" ? serialized : String(value);
|
|
2146
2144
|
} catch {
|
|
2145
|
+
return String(value);
|
|
2147
2146
|
}
|
|
2148
|
-
return String(value);
|
|
2149
2147
|
}
|
|
2150
2148
|
function summarizeObject(value) {
|
|
2151
2149
|
if (value == null) return "null";
|
|
@@ -2189,11 +2187,10 @@ function resolveToolResponsePolicy(toolName, output, config) {
|
|
|
2189
2187
|
} else if (classification === "redundant") {
|
|
2190
2188
|
retentionPolicy = byTool || "drop";
|
|
2191
2189
|
}
|
|
2190
|
+
const summary = summarizeObject(output);
|
|
2192
2191
|
if (retentionPolicy === "keep_full") {
|
|
2193
|
-
|
|
2194
|
-
return { classification, retentionPolicy, content: serialized, rawOutput: output, summary: summary2, tokenCount };
|
|
2192
|
+
return { classification, retentionPolicy, content: serialized, rawOutput: output, summary, tokenCount };
|
|
2195
2193
|
}
|
|
2196
|
-
const summary = summarizeObject(output);
|
|
2197
2194
|
if (retentionPolicy === "keep_structured") {
|
|
2198
2195
|
return { classification, retentionPolicy, content: summary, rawOutput: output, summary, tokenCount };
|
|
2199
2196
|
}
|
|
@@ -2496,7 +2493,15 @@ function createToolsNode(initialTools, opts) {
|
|
|
2496
2493
|
status: "success"
|
|
2497
2494
|
});
|
|
2498
2495
|
}
|
|
2499
|
-
|
|
2496
|
+
let toolMessageContent = responsePolicy.content;
|
|
2497
|
+
if (responsePolicy.retentionPolicy === "summarize_archive") {
|
|
2498
|
+
toolMessageContent = `ARCHIVED_TOOL_RESPONSE [executionId=${executionId}]: ${responsePolicy.summary}
|
|
2499
|
+
Use get_tool_response with executionId "${executionId}" to retrieve the full output.`;
|
|
2500
|
+
} else if (responsePolicy.retentionPolicy === "drop") {
|
|
2501
|
+
toolMessageContent = `DROPPED_TOOL_RESPONSE [executionId=${executionId}]: ${responsePolicy.summary}
|
|
2502
|
+
Use get_tool_response with executionId "${executionId}" to retrieve the full output.`;
|
|
2503
|
+
}
|
|
2504
|
+
appended.push({ role: "tool", content: toolMessageContent, tool_call_id: tc.id || `${tc.name}_${appended.length}`, name: tc.name });
|
|
2500
2505
|
onEvent?.({ type: "tool_call", phase: "success", name: toolName, id: tc.id, args, result: output, durationMs });
|
|
2501
2506
|
onProgress?.({ stage: "tools", message: `Tool ${tc.name} completed`, detail: { durationMs } });
|
|
2502
2507
|
if (needsApproval && approvalEntry) {
|
|
@@ -3055,8 +3060,8 @@ function createAgent(opts) {
|
|
|
3055
3060
|
}
|
|
3056
3061
|
}
|
|
3057
3062
|
let maxTok;
|
|
3058
|
-
if (opts.summarization && typeof opts.summarization === "object"
|
|
3059
|
-
maxTok = opts.summarization.maxTokens;
|
|
3063
|
+
if (opts.summarization && typeof opts.summarization === "object") {
|
|
3064
|
+
maxTok = opts.summarization.summaryTriggerTokens || opts.summarization.maxTokens;
|
|
3060
3065
|
}
|
|
3061
3066
|
if (maxTok === void 0) {
|
|
3062
3067
|
maxTok = 5e4;
|
|
@@ -4205,7 +4210,7 @@ function createContextTools(stateRef, opts) {
|
|
|
4205
4210
|
}
|
|
4206
4211
|
const getTool = createTool({
|
|
4207
4212
|
name: "get_tool_response",
|
|
4208
|
-
description: "RETRIEVE tool execution response
|
|
4213
|
+
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.",
|
|
4209
4214
|
schema: z.object({ executionId: z.string().describe("Tool execution id") }),
|
|
4210
4215
|
func: async ({ executionId }) => {
|
|
4211
4216
|
const matchesExecution = (t) => t?.executionId === executionId || t?.tool_call_id === executionId;
|