@caupulican/pi-adaptative 0.81.1 → 0.81.2

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.
@@ -594,8 +594,8 @@ export class AgentSession {
594
594
  }
595
595
  throw new Error(formatNoApiKeyFoundMessage(model.provider));
596
596
  }
597
- // Summarizer model selection, request auth (with session-model fallback), and window-adapted
598
- // settings live in CompactionSupport (see compaction-support.ts). Same-signature delegations.
597
+ // Summarizer model/thinking selection, request auth (with session-model fallback), and
598
+ // window-adapted settings live in CompactionSupport (see compaction-support.ts).
599
599
  _getCompactionRequestAuth(model) {
600
600
  return this._compactionSupport.getRequestAuth(model);
601
601
  }
@@ -605,6 +605,9 @@ export class AgentSession {
605
605
  _resolveCompactionModel(sessionModel) {
606
606
  return this._compactionSupport.resolveModel(sessionModel);
607
607
  }
608
+ _resolveCompactionThinkingLevel(compactionModel, sessionModel) {
609
+ return this._compactionSupport.resolveThinkingLevel(this.thinkingLevel, compactionModel, sessionModel);
610
+ }
608
611
  /**
609
612
  * Install tool hooks once on the Agent instance.
610
613
  *
@@ -2142,6 +2145,7 @@ export class AgentSession {
2142
2145
  throw new Error(formatNoModelSelectedMessage());
2143
2146
  }
2144
2147
  const compactionModel = this._resolveCompactionModel(this.model);
2148
+ const compactionThinkingLevel = this._resolveCompactionThinkingLevel(compactionModel, this.model);
2145
2149
  const { apiKey, headers } = await this._getCompactionRequestAuth(compactionModel);
2146
2150
  const pathEntries = this.sessionManager.getBranch();
2147
2151
  const settings = this._getAdaptedCompactionSettings();
@@ -2186,7 +2190,7 @@ export class AgentSession {
2186
2190
  else {
2187
2191
  // Generate compaction result
2188
2192
  const compactionSignal = this._compactionAbortController.signal;
2189
- const result = await this._compactWithRetry(() => compact(preparation, compactionModel, apiKey, headers, customInstructions, compactionSignal, this.thinkingLevel, this.agent.streamFn, this._buildCompactionPreDigest()), compactionSignal);
2193
+ const result = await this._compactWithRetry(() => compact(preparation, compactionModel, apiKey, headers, customInstructions, compactionSignal, compactionThinkingLevel, this.agent.streamFn, this._buildCompactionPreDigest()), compactionSignal);
2190
2194
  summary = result.summary;
2191
2195
  firstKeptEntryId = result.firstKeptEntryId;
2192
2196
  tokensBefore = result.tokensBefore;
@@ -2398,9 +2402,9 @@ export class AgentSession {
2398
2402
  });
2399
2403
  return false;
2400
2404
  }
2401
- // Summarize with the cheap auxiliary model when available (cost guard, #30). If its auth
2402
- // turns out unusable at request time (e.g. expired token), fall back to the session model —
2403
- // the one manual /compact demonstrably works with — before giving up.
2405
+ // Summarize with the configured/default compaction model. If its auth turns out unusable at
2406
+ // request time (e.g. expired token), fall back to the session model — the one manual /compact
2407
+ // demonstrably works with — before giving up.
2404
2408
  const resolvedCompaction = await this._resolveCompactionModelAndAuth(this._resolveCompactionModel(this.model), this.model);
2405
2409
  if (resolvedCompaction.failure) {
2406
2410
  this._emit({
@@ -2414,6 +2418,7 @@ export class AgentSession {
2414
2418
  return false;
2415
2419
  }
2416
2420
  const compactionModel = resolvedCompaction.model;
2421
+ const compactionThinkingLevel = this._resolveCompactionThinkingLevel(compactionModel, this.model);
2417
2422
  const apiKey = resolvedCompaction.apiKey;
2418
2423
  const headers = resolvedCompaction.headers;
2419
2424
  const pathEntries = this.sessionManager.getBranch();
@@ -2469,7 +2474,7 @@ export class AgentSession {
2469
2474
  else {
2470
2475
  // Generate compaction result
2471
2476
  const autoCompactionSignal = this._autoCompactionAbortController.signal;
2472
- const compactResult = await this._compactWithRetry(() => compact(preparation, compactionModel, apiKey, headers, undefined, autoCompactionSignal, this.thinkingLevel, this.agent.streamFn, this._buildCompactionPreDigest()), autoCompactionSignal);
2477
+ const compactResult = await this._compactWithRetry(() => compact(preparation, compactionModel, apiKey, headers, undefined, autoCompactionSignal, compactionThinkingLevel, this.agent.streamFn, this._buildCompactionPreDigest()), autoCompactionSignal);
2473
2478
  summary = compactResult.summary;
2474
2479
  firstKeptEntryId = compactResult.firstKeptEntryId;
2475
2480
  tokensBefore = compactResult.tokensBefore;