@wrongstack/core 0.8.2 → 0.8.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.
@@ -204,10 +204,16 @@ declare class AutoCompactionMiddleware {
204
204
  private readonly failureMode;
205
205
  private readonly policyProvider?;
206
206
  /**
207
- * Overhead factor applied to the rough message-token estimate to produce a
208
- * figure comparable to the real API request size (system prompt + tool defs).
209
- * Without this factor, raw message tokens undercount real load by 15-50% in
210
- * short conversations, causing premature compaction triggers.
207
+ * Calibration factor applied to the estimator output. The estimator is now
208
+ * expected to already include messages + system prompt + tool definitions
209
+ * (see `estimateRequestTokens.total`), so no overhead boost is needed. Kept
210
+ * as a constant so a future calibration against real provider tokenization
211
+ * (BPE vs the chars/3.5 rough estimator) can dial this without touching the
212
+ * threshold-check math.
213
+ *
214
+ * Historical note: was 1.3 when the estimator only counted messages — that
215
+ * double-counted system+tools once the estimator was upgraded, firing
216
+ * compaction ~30% earlier than intended (e.g. real 56% load showed as 73%).
211
217
  */
212
218
  private static readonly OVERHEAD_FACTOR;
213
219
  /**
@@ -1019,12 +1019,18 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
1019
1019
  failureMode;
1020
1020
  policyProvider;
1021
1021
  /**
1022
- * Overhead factor applied to the rough message-token estimate to produce a
1023
- * figure comparable to the real API request size (system prompt + tool defs).
1024
- * Without this factor, raw message tokens undercount real load by 15-50% in
1025
- * short conversations, causing premature compaction triggers.
1022
+ * Calibration factor applied to the estimator output. The estimator is now
1023
+ * expected to already include messages + system prompt + tool definitions
1024
+ * (see `estimateRequestTokens.total`), so no overhead boost is needed. Kept
1025
+ * as a constant so a future calibration against real provider tokenization
1026
+ * (BPE vs the chars/3.5 rough estimator) can dial this without touching the
1027
+ * threshold-check math.
1028
+ *
1029
+ * Historical note: was 1.3 when the estimator only counted messages — that
1030
+ * double-counted system+tools once the estimator was upgraded, firing
1031
+ * compaction ~30% earlier than intended (e.g. real 56% load showed as 73%).
1026
1032
  */
1027
- static OVERHEAD_FACTOR = 1.3;
1033
+ static OVERHEAD_FACTOR = 1;
1028
1034
  /**
1029
1035
  * Once a compaction attempt reduces nothing (preserveK protects everything,
1030
1036
  * no oversized tool_results remain to elide), retrying on every iteration