@kenkaiiii/gg-agent 5.22.0 → 5.22.2

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
@@ -1199,16 +1199,22 @@ function capToolResults(toolResults, maxToolResultChars) {
1199
1199
  const max = Math.min(maxToolResultChars, hardMax);
1200
1200
  for (const toolResult of toolResults) {
1201
1201
  if (typeof toolResult.content !== "string" || toolResult.content.length <= max) continue;
1202
+ const originalChars = toolResult.content.length;
1202
1203
  const headChars = Math.floor(max * 0.7);
1203
1204
  const tailChars = max - headChars;
1204
1205
  const head = toolResult.content.slice(0, headChars);
1205
1206
  const tail = toolResult.content.slice(-tailChars);
1206
- const omitted = toolResult.content.length - headChars - tailChars;
1207
+ const omitted = originalChars - headChars - tailChars;
1207
1208
  toolResult.content = head + `
1208
1209
 
1209
1210
  [... ${omitted} characters omitted ...]
1210
1211
 
1211
1212
  ` + tail;
1213
+ toolResult.capped = {
1214
+ originalChars,
1215
+ keptChars: toolResult.content.length,
1216
+ scope: "per-result"
1217
+ };
1212
1218
  }
1213
1219
  }
1214
1220
  function capTurnToolResults(toolResults, maxTurnToolResultChars) {
@@ -1229,14 +1235,20 @@ function capTurnToolResults(toolResults, maxTurnToolResultChars) {
1229
1235
  continue;
1230
1236
  }
1231
1237
  remaining -= fairShare;
1238
+ const originalChars = toolResult.content.length;
1232
1239
  const headChars = Math.floor(fairShare * 0.7);
1233
1240
  const tailChars = fairShare - headChars;
1234
- const omitted = toolResult.content.length - fairShare;
1241
+ const omitted = originalChars - fairShare;
1235
1242
  toolResult.content = toolResult.content.slice(0, headChars) + `
1236
1243
 
1237
1244
  [... ${omitted} characters trimmed: this turn's combined tool results exceeded the per-turn budget. Re-run this call alone with narrower filters or offset/limit if you need the omitted content ...]
1238
1245
 
1239
1246
  ` + (tailChars > 0 ? toolResult.content.slice(-tailChars) : "");
1247
+ toolResult.capped = {
1248
+ originalChars: toolResult.capped?.originalChars ?? originalChars,
1249
+ keptChars: toolResult.content.length,
1250
+ scope: "per-turn"
1251
+ };
1240
1252
  }
1241
1253
  }
1242
1254
  function normalizeToolResult(raw) {