@kolisachint/hoocode-agent 0.4.72 → 0.4.73

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.
@@ -1499,22 +1499,26 @@ export class AgentSession {
1499
1499
  // Size band guards local inference globally: only route conversations within
1500
1500
  // the configured byte band to the executor. Oversized conversations are slow
1501
1501
  // locally and can OOM small machines, so they fall back to the primary model.
1502
- const conversationBytes = Buffer.byteLength(serializeConversation(convertToLlm(preparation.messagesToSummarize)), "utf8");
1503
- if (router && executor && executor !== primaryModel && router.withinSizeBand(conversationBytes)) {
1504
- try {
1505
- if (!(await this._ensureExecutorServer(signal))) {
1506
- throw new Error("executor server unavailable");
1502
+ // Only serialize to measure size when routing is actually engaged (avoids
1503
+ // needless work on the common primary-only path).
1504
+ if (router && executor && executor !== primaryModel) {
1505
+ const conversationBytes = Buffer.byteLength(serializeConversation(convertToLlm(preparation.messagesToSummarize)), "utf8");
1506
+ if (router.withinSizeBand(conversationBytes)) {
1507
+ try {
1508
+ if (!(await this._ensureExecutorServer(signal))) {
1509
+ throw new Error("executor server unavailable");
1510
+ }
1511
+ const { apiKey: exKey, headers: exHeaders } = await this._getRequiredRequestAuth(executor);
1512
+ return await compact(preparation, executor, exKey, exHeaders, customInstructions, signal,
1513
+ // Executor runs without thinking (validated config); summary quality
1514
+ // relies on /no_think via the model's promptSuffix compat setting.
1515
+ "off");
1516
+ }
1517
+ catch (error) {
1518
+ if (signal.aborted)
1519
+ throw error;
1520
+ logLocalInferenceFallback("summarization", error);
1507
1521
  }
1508
- const { apiKey: exKey, headers: exHeaders } = await this._getRequiredRequestAuth(executor);
1509
- return await compact(preparation, executor, exKey, exHeaders, customInstructions, signal,
1510
- // Executor runs without thinking (validated config); summary quality
1511
- // relies on /no_think via the model's promptSuffix compat setting.
1512
- "off");
1513
- }
1514
- catch (error) {
1515
- if (signal.aborted)
1516
- throw error;
1517
- logLocalInferenceFallback("summarization", error);
1518
1522
  }
1519
1523
  }
1520
1524
  return compact(preparation, primaryModel, apiKey, headers, customInstructions, signal, this.thinkingLevel);