@genesislcap/ai-assistant 15.5.0 → 15.6.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.
@@ -2796,6 +2796,9 @@ function estimateTokensSaved(origLen, stubLen) {
2796
2796
  function applyCondensation(history, policies, ctx, onCondensed) {
2797
2797
  if (policies.size === 0) return history;
2798
2798
  const triggersOf = (entry) => Array.isArray(entry.policy.on) ? entry.policy.on : [entry.policy.on];
2799
+ const batchCalls = Math.max(1, Math.floor(ctx.batchCalls ?? 1));
2800
+ const asOf = batchCalls === 1 ? ctx.modelCall : Math.floor(ctx.modelCall / batchCalls) * batchCalls;
2801
+ const withinBatch = (entry) => batchCalls === 1 || entry.iteration <= asOf;
2799
2802
  const latestByKey = /* @__PURE__ */ new Map();
2800
2803
  const nameById = /* @__PURE__ */ new Map();
2801
2804
  for (const msg of history) {
@@ -2803,7 +2806,7 @@ function applyCondensation(history, policies, ctx, onCondensed) {
2803
2806
  for (const tc of msg.toolCalls) {
2804
2807
  nameById.set(tc.id, tc.name);
2805
2808
  const entry = policies.get(tc.id);
2806
- if (!entry) continue;
2809
+ if (!entry || !withinBatch(entry)) continue;
2807
2810
  for (const t of triggersOf(entry)) {
2808
2811
  if (t.kind === "superseded") latestByKey.set(t.by, tc.id);
2809
2812
  }
@@ -2815,7 +2818,7 @@ function applyCondensation(history, policies, ctx, onCondensed) {
2815
2818
  // past the last allowed view: turns:1 → seen once, then gone. Monotonic
2816
2819
  // clock, so this holds across turn boundaries too.
2817
2820
  case "age":
2818
- return ctx.modelCall - entry.iteration > trig.turns;
2821
+ return asOf - entry.iteration > trig.turns;
2819
2822
  case "turnEnd":
2820
2823
  return ctx.turn > entry.turn;
2821
2824
  case "agentEnd":
@@ -2829,7 +2832,7 @@ function applyCondensation(history, policies, ctx, onCondensed) {
2829
2832
  return latestByKey.get(trig.by) !== toolCallId;
2830
2833
  }
2831
2834
  };
2832
- const firstFired = (toolCallId, entry) => triggersOf(entry).find((t) => triggerFires(toolCallId, entry, t));
2835
+ const firstFired = (toolCallId, entry) => withinBatch(entry) ? triggersOf(entry).find((t) => triggerFires(toolCallId, entry, t)) : void 0;
2833
2836
  return history.map((msg) => {
2834
2837
  if (msg.toolCalls?.length) {
2835
2838
  let changed = false;
@@ -3210,11 +3213,13 @@ var ChatDriver = class _ChatDriver extends EventTarget {
3210
3213
  primerHistory,
3211
3214
  maxToolIterations = DEFAULT_MAX_TOOL_ITERATIONS,
3212
3215
  maxFoldOperations = DEFAULT_MAX_FOLD_OPERATIONS,
3216
+ condenseBatchCalls = 1,
3213
3217
  maxTurnSnapshots = DEFAULT_MAX_TURN_SNAPSHOTS,
3214
3218
  sessionKey = "",
3215
3219
  activityBus = NOOP_ACTIVITY_BUS
3216
3220
  } = config;
3217
3221
  this.maxToolIterations = maxToolIterations;
3222
+ this.condenseBatchCalls = condenseBatchCalls;
3218
3223
  this.sessionKey = sessionKey;
3219
3224
  this.activityBus = activityBus;
3220
3225
  if (typeof toolHandlers === "function") {
@@ -4453,7 +4458,8 @@ Output format (strict):
4453
4458
  activationEnded: (activation) => activation < this.currentActivation,
4454
4459
  // A call's phase has ended once the app declared a later phase epoch
4455
4460
  // current via `endPhase()`.
4456
- phaseEnded: (phaseEpoch) => phaseEpoch < this.currentPhaseEpoch
4461
+ phaseEnded: (phaseEpoch) => phaseEpoch < this.currentPhaseEpoch,
4462
+ batchCalls: this.condenseBatchCalls
4457
4463
  },
4458
4464
  (detail) => recordMetaEvent(this.sessionKey, "context.condensed", detail)
4459
4465
  );