@kolisachint/hoocode-agent 0.4.71 → 0.4.72

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.
@@ -21,12 +21,13 @@ import { sleep } from "../utils/sleep.js";
21
21
  import { loadAgentRegistry } from "./agent-registry.js";
22
22
  import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
23
23
  import { executeBashWithOperations } from "./bash-executor.js";
24
- import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
24
+ import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, serializeConversation, shouldCompact, } from "./compaction/index.js";
25
25
  import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
26
26
  import { exportSessionToHtml } from "./export-html/index.js";
27
27
  import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
28
28
  import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
29
29
  import { emitSessionShutdownEvent } from "./extensions/runner.js";
30
+ import { convertToLlm } from "./messages.js";
30
31
  import { expandPromptTemplate, tryExpandPromptTemplate } from "./prompt-templates.js";
31
32
  import { clearProviderExhaustion, isProviderQuotaError, markProviderExhausted } from "./provider-health.js";
32
33
  import { LocalInferenceRouter, resolveRoutingMode } from "./routing/local-inference.js";
@@ -283,7 +284,7 @@ export class AgentSession {
283
284
  changed = true;
284
285
  }
285
286
  }
286
- // Optionally compress large read/bash output before it enters context.
287
+ // Optionally compress large bash output before it enters context.
287
288
  // Only when local-inference tool-result routing is active; on any
288
289
  // failure the original (uncompressed) content is kept (fallback to raw).
289
290
  if (!resolvedIsError) {
@@ -301,7 +302,8 @@ export class AgentSession {
301
302
  /**
302
303
  * Compress a tool result via the local executor when routing is active and the
303
304
  * tool/size qualify. Returns the compressed content blocks, or undefined to
304
- * keep the original (no routing, not compressible, too small, or any failure).
305
+ * keep the original (no routing, not compressible, outside the size band, or
306
+ * any failure).
305
307
  */
306
308
  async _maybeCompressToolResult(toolName, content) {
307
309
  const router = this.localRouter;
@@ -1494,7 +1496,11 @@ export class AgentSession {
1494
1496
  async _compactWithRouting(preparation, primaryModel, apiKey, headers, customInstructions, signal) {
1495
1497
  const router = this.localRouter;
1496
1498
  const executor = router?.selectModel("summarization", primaryModel);
1497
- if (router && executor && executor !== primaryModel) {
1499
+ // Size band guards local inference globally: only route conversations within
1500
+ // the configured byte band to the executor. Oversized conversations are slow
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)) {
1498
1504
  try {
1499
1505
  if (!(await this._ensureExecutorServer(signal))) {
1500
1506
  throw new Error("executor server unavailable");