@kernel.chat/kbot 3.99.24 → 3.99.26
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 +22 -2
- package/package.json +3 -2
package/dist/agent.js
CHANGED
|
@@ -112,6 +112,21 @@ let weakModelWarningShown = false;
|
|
|
112
112
|
// ── Local-first execution ──
|
|
113
113
|
async function tryLocalFirst(message) {
|
|
114
114
|
const lower = message.toLowerCase().trim();
|
|
115
|
+
// Pure-arithmetic short-circuit. When the whole message reduces to a single
|
|
116
|
+
// "what is a op b" / bare "a op b" / "compute a op b" query, return the
|
|
117
|
+
// computed answer directly — never involve an LLM. Eval on 2026-04-20
|
|
118
|
+
// showed gemma4:latest ignoring an injected MATH GUARD block ("123 % 7 = 4"
|
|
119
|
+
// prepended to the message, answer still "2"). If we already have the
|
|
120
|
+
// answer deterministically, there is no reason to ask the model.
|
|
121
|
+
if (/^(?:what\s+is|what['']s|compute|calculate|evaluate)\s+[-\d.\s+*×/÷%]+\??$/i.test(lower)
|
|
122
|
+
|| /^[-\d.\s+*×/÷%]+\??$/.test(lower)) {
|
|
123
|
+
const { extractArithmetic } = await import('./math-guard.js');
|
|
124
|
+
const exprs = extractArithmetic(message);
|
|
125
|
+
if (exprs.length === 1) {
|
|
126
|
+
const r = exprs[0].result;
|
|
127
|
+
return Number.isInteger(r) ? r.toString() : Number.parseFloat(r.toFixed(6)).toString();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
115
130
|
// Only match simple "read <single-filepath>" — reject anything with trailing
|
|
116
131
|
// conversational text. Prevents "Read package.json and tell me X" from
|
|
117
132
|
// feeding the whole prompt to read_file as a filename.
|
|
@@ -1331,10 +1346,15 @@ Always quote file paths that contain spaces. Never reference internal system nam
|
|
|
1331
1346
|
description: t.description,
|
|
1332
1347
|
input_schema: t.input_schema,
|
|
1333
1348
|
}));
|
|
1334
|
-
// Build messages with RLM-style context management
|
|
1349
|
+
// Build messages with RLM-style context management. Guards (math,
|
|
1350
|
+
// identity) are also injected into the system context for long-turn
|
|
1351
|
+
// coherence, but we repeat them here because small local models
|
|
1352
|
+
// (4B-class) ignore system context for deterministic queries.
|
|
1353
|
+
const guardPreamble = mathGuardSnippet + (mathGuardSnippet && identityGuardSnippet ? '\n' : '') + identityGuardSnippet;
|
|
1354
|
+
const guardedUserContent = guardPreamble ? guardPreamble + '\n' + message : message;
|
|
1335
1355
|
const rawMessages = [
|
|
1336
1356
|
...getPreviousMessages(memSession),
|
|
1337
|
-
{ role: 'user', content:
|
|
1357
|
+
{ role: 'user', content: guardedUserContent },
|
|
1338
1358
|
...loopMessages,
|
|
1339
1359
|
];
|
|
1340
1360
|
// Auto-compact conversation history — entropy-aware compression
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kernel.chat/kbot",
|
|
3
|
-
"version": "3.99.
|
|
3
|
+
"version": "3.99.26",
|
|
4
4
|
"description": "Open-source terminal AI agent. 787+ tools, 35 agents, 20 providers. Dreams, learns, watches your system. Controls your phone. Fully local, fully sovereign. MIT.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"dev": "tsx src/cli.ts",
|
|
41
41
|
"start": "node dist/cli.js",
|
|
42
42
|
"test": "vitest run",
|
|
43
|
-
"typecheck": "tsc --noEmit"
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"eval": "tsx eval/run.ts"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
46
47
|
"ai-agent",
|