@compilr-dev/sdk 0.7.27 → 0.7.28

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/agent.js CHANGED
@@ -298,15 +298,17 @@ class CompilrAgentImpl {
298
298
  observationMask: contextManager ? observationMask : undefined,
299
299
  windowing: contextManager
300
300
  ? config?.context?.windowing !== false
301
- ? {
302
- // Scale windowing targets to model's context window:
303
- // targetHistoryTokens: 10% of context (e.g., 100K for 1M, 20K for 200K, 12.8K for 128K)
304
- // recentWindowTokens: 25% of target (e.g., 25K for 1M, 5K for 200K)
305
- targetHistoryTokens: Math.round(contextLimit * 0.10),
306
- recentWindowTokens: Math.round(contextLimit * 0.025),
307
- // User overrides take precedence
308
- ...(typeof config?.context?.windowing === 'object' ? config.context.windowing : {}),
309
- }
301
+ ? (() => {
302
+ const wCfg = typeof config?.context?.windowing === 'object' ? config.context.windowing : {};
303
+ const historyRatio = wCfg.targetHistoryRatio ?? 0.1;
304
+ const recentRatio = wCfg.recentWindowRatio ?? 0.025;
305
+ return {
306
+ // Derive from model context window, overridable with explicit values
307
+ targetHistoryTokens: wCfg.targetHistoryTokens ?? Math.round(contextLimit * historyRatio),
308
+ recentWindowTokens: wCfg.recentWindowTokens ?? Math.round(contextLimit * recentRatio),
309
+ enabled: wCfg.enabled,
310
+ };
311
+ })()
310
312
  : false
311
313
  : undefined,
312
314
  hooks: mergedHooks,
package/dist/config.d.ts CHANGED
@@ -110,10 +110,20 @@ export interface ContextConfig {
110
110
  * Smart windowing — programmatic context compaction.
111
111
  * Compacts old messages when history exceeds token budget.
112
112
  * Three zones: recent (intact), middle (truncated), old (event log).
113
- * When omitted, SDK defaults are used (60K target, 15K recent window).
113
+ *
114
+ * When omitted, targets are derived from the model's context window:
115
+ * targetHistoryTokens = contextLimit * targetHistoryRatio (default 0.10)
116
+ * recentWindowTokens = contextLimit * recentWindowRatio (default 0.025)
117
+ *
114
118
  * Set to false to disable windowing entirely.
119
+ * Set explicit targetHistoryTokens/recentWindowTokens to override proportional defaults.
115
120
  */
116
- windowing?: Partial<WindowingConfig> | false;
121
+ windowing?: (Partial<WindowingConfig> & {
122
+ /** Fraction of context window for target history. Default: 0.10 (10%) */
123
+ targetHistoryRatio?: number;
124
+ /** Fraction of context window for recent window. Default: 0.025 (2.5%) */
125
+ recentWindowRatio?: number;
126
+ }) | false;
117
127
  }
118
128
  /**
119
129
  * Usage information for the agent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.7.27",
3
+ "version": "0.7.28",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",