@compilr-dev/sdk 0.7.26 → 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
@@ -121,8 +121,10 @@ class CompilrAgentImpl {
121
121
  }
122
122
  // Build context manager if configured
123
123
  let contextManager;
124
+ const contextLimit = config?.context
125
+ ? (config.context.contextLimit ?? getContextWindow(config.model))
126
+ : getContextWindow(config?.model);
124
127
  if (config?.context) {
125
- const contextLimit = config.context.contextLimit ?? getContextWindow(config.model);
126
128
  contextManager = new ContextManager({
127
129
  provider,
128
130
  config: {
@@ -296,9 +298,17 @@ class CompilrAgentImpl {
296
298
  observationMask: contextManager ? observationMask : undefined,
297
299
  windowing: contextManager
298
300
  ? config?.context?.windowing !== false
299
- ? {
300
- ...(typeof config?.context?.windowing === 'object' ? config.context.windowing : {}),
301
- }
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
+ })()
302
312
  : false
303
313
  : undefined,
304
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.26",
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",