billion-context-pi 0.1.74-pr.355.310 → 0.1.74-pr.405.312

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/config.d.ts CHANGED
@@ -357,5 +357,11 @@ export declare function mergeCompress(global?: CompressSettings, provider?: Comp
357
357
  * at any level. The Pi adapter keys providers by name (ctx.model.provider),
358
358
  * not URL — it never sees the upstream URL the way the proxy does. */
359
359
  export declare function resolveCompress(compress: CompressConfig | undefined, provider: string | undefined, modelId: string | undefined): CompressSettings;
360
+ /** Effective nudge growth band for a context window when the user has not set
361
+ * `nudgeGrowthTokens`: `min(50000, max(8000, window / 3))` — the 5w default
362
+ * wherever the window can sustain it (150K and up, and unknown windows), a
363
+ * third of the window only where that computes smaller than 5w (a 50K window
364
+ * gets ~16.7K, re-arming every ~16.7K of growth). */
365
+ export declare function scaleNudgeGrowthToWindow(limit: number): number;
360
366
  export declare function resolveConfig(adapter: AdapterConfig, liveContextLimit: number, provider?: string, modelId?: string): Config;
361
367
  export declare function parsePercent(v: number | string): number;
package/dist/index.js CHANGED
@@ -5642,10 +5642,17 @@ function resolveCompress(compress, provider, modelId) {
5642
5642
  const model = prov && modelId ? prov.models?.[modelId] : void 0;
5643
5643
  return mergeCompress(compress, prov, model);
5644
5644
  }
5645
+ var KERNEL_GROWTH_DEFAULT = 5e4;
5646
+ var ADAPTIVE_GROWTH_WINDOW_MAX = 15e4;
5647
+ var ADAPTIVE_GROWTH_MIN = 8e3;
5648
+ function scaleNudgeGrowthToWindow(limit) {
5649
+ if (!Number.isFinite(limit) || limit <= 0 || limit >= ADAPTIVE_GROWTH_WINDOW_MAX) return KERNEL_GROWTH_DEFAULT;
5650
+ return Math.min(KERNEL_GROWTH_DEFAULT, Math.max(ADAPTIVE_GROWTH_MIN, Math.round(limit / 3)));
5651
+ }
5645
5652
  function resolveConfig(adapter, liveContextLimit, provider, modelId) {
5646
5653
  const envLimit = process.env.ACP_MODEL_CONTEXT_LIMIT;
5647
5654
  const envLimitNum = envLimit ? Number(envLimit) : NaN;
5648
- const FALLBACK_LIMIT = 15e4;
5655
+ const FALLBACK_LIMIT = ADAPTIVE_GROWTH_WINDOW_MAX;
5649
5656
  const limit = !Number.isNaN(envLimitNum) && envLimitNum > 0 ? envLimitNum : adapter.modelContextLimit && adapter.modelContextLimit > 0 ? adapter.modelContextLimit : liveContextLimit > 0 ? liveContextLimit : FALLBACK_LIMIT;
5650
5657
  const config = defaultConfig(limit, {
5651
5658
  protectedTools: adapter.protectedTools ?? [],
@@ -5662,6 +5669,10 @@ function resolveConfig(adapter, liveContextLimit, provider, modelId) {
5662
5669
  if (c.nudgeGrowthTokens !== void 0) {
5663
5670
  config.nudge.growthFloor = c.nudgeGrowthTokens;
5664
5671
  config.nudge.growthCap = c.nudgeGrowthTokens;
5672
+ } else {
5673
+ const scaled = scaleNudgeGrowthToWindow(limit);
5674
+ config.nudge.growthFloor = scaled;
5675
+ config.nudge.growthCap = scaled;
5665
5676
  }
5666
5677
  if (c.minPressureBenefitTokens !== void 0) {
5667
5678
  config.nudge.minPressureBenefitTokens = c.minPressureBenefitTokens;