@cognipeer/agent-sdk 0.4.2 → 0.4.4

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 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
- if (typeof serialized === "string") {
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
- const summary2 = "";
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
  }
@@ -3073,8 +3070,8 @@ function createAgent(opts) {
3073
3070
  }
3074
3071
  }
3075
3072
  let maxTok;
3076
- if (opts.summarization && typeof opts.summarization === "object" && opts.summarization.maxTokens) {
3077
- maxTok = opts.summarization.maxTokens;
3073
+ if (opts.summarization && typeof opts.summarization === "object") {
3074
+ maxTok = opts.summarization.summaryTriggerTokens || opts.summarization.maxTokens;
3078
3075
  }
3079
3076
  if (maxTok === void 0) {
3080
3077
  maxTok = 5e4;