@kolisachint/hoocode-agent 0.4.71 → 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.
- package/CHANGELOG.md +28 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +3 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +26 -16
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/routing/local-inference.d.ts +37 -7
- package/dist/core/routing/local-inference.d.ts.map +1 -1
- package/dist/core/routing/local-inference.js +44 -8
- package/dist/core/routing/local-inference.js.map +1 -1
- package/dist/core/routing/tool-result-prompts.d.ts +7 -6
- package/dist/core/routing/tool-result-prompts.d.ts.map +1 -1
- package/dist/core/routing/tool-result-prompts.js +7 -11
- package/dist/core/routing/tool-result-prompts.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -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
|
|
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,
|
|
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,21 +1496,29 @@ 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);
|
|
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
|
+
// Only serialize to measure size when routing is actually engaged (avoids
|
|
1503
|
+
// needless work on the common primary-only path).
|
|
1497
1504
|
if (router && executor && executor !== primaryModel) {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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);
|
|
1501
1521
|
}
|
|
1502
|
-
const { apiKey: exKey, headers: exHeaders } = await this._getRequiredRequestAuth(executor);
|
|
1503
|
-
return await compact(preparation, executor, exKey, exHeaders, customInstructions, signal,
|
|
1504
|
-
// Executor runs without thinking (validated config); summary quality
|
|
1505
|
-
// relies on /no_think via the model's promptSuffix compat setting.
|
|
1506
|
-
"off");
|
|
1507
|
-
}
|
|
1508
|
-
catch (error) {
|
|
1509
|
-
if (signal.aborted)
|
|
1510
|
-
throw error;
|
|
1511
|
-
logLocalInferenceFallback("summarization", error);
|
|
1512
1522
|
}
|
|
1513
1523
|
}
|
|
1514
1524
|
return compact(preparation, primaryModel, apiKey, headers, customInstructions, signal, this.thinkingLevel);
|