jeopi-ai 16.7.5 → 16.7.6
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 +7 -0
- package/package.json +4 -4
- package/src/utils/thinking-loop.ts +38 -7
- package/src/utils/tool-call-loop-guard.ts +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.7.6] - 2026-11-21
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Keep `guardThinkingLoopStream` armed across multi-block `thinking` and `text` parts separated by whitespace-only text deltas (such as Gemini Cloud Code Assist `\n` separators), disarming only after visible non-whitespace text or a tool call, and trigger `ThinkingLoopDetector` after 3 consecutive identical segments.
|
|
10
|
+
- Normalize volatile error metadata (ISO timestamps, UUIDs, request/trace IDs, durations) in `ToolCallLoopGuard` and stall consecutive `isError` streaks on the same call signature even when error details vary.
|
|
11
|
+
|
|
5
12
|
## [16.7.2] - 2026-11-20
|
|
6
13
|
|
|
7
14
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "jeopi-ai",
|
|
4
|
-
"version": "16.7.
|
|
4
|
+
"version": "16.7.6",
|
|
5
5
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
6
6
|
"homepage": "https://github.com/akillness/jeopi",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@bufbuild/protobuf": "^2.12.0",
|
|
41
|
-
"jeopi-catalog": "16.7.
|
|
42
|
-
"jeopi-utils": "16.7.
|
|
43
|
-
"jeopi-wire": "16.7.
|
|
41
|
+
"jeopi-catalog": "16.7.6",
|
|
42
|
+
"jeopi-utils": "16.7.6",
|
|
43
|
+
"jeopi-wire": "16.7.6",
|
|
44
44
|
"arktype": "2.2.3",
|
|
45
45
|
"zod": "^4"
|
|
46
46
|
},
|
|
@@ -67,7 +67,9 @@ const SEGMENT_SIMILARITY = 0.8;
|
|
|
67
67
|
const SEGMENT_MIN_COUNT = 8;
|
|
68
68
|
/** Near-duplicate cluster size (current + matches) that trips the loop. */
|
|
69
69
|
const SEGMENT_MIN_CLUSTER = 4;
|
|
70
|
-
|
|
70
|
+
/** Consecutive identical normalized segments that trip an exact-block loop
|
|
71
|
+
* without waiting for SEGMENT_MIN_COUNT (e.g. multi-block thinking loops). */
|
|
72
|
+
const CONSECUTIVE_EXACT_MIN = 3;
|
|
71
73
|
/** Recent segments whose pooled unigram vocabulary is the novelty baseline for
|
|
72
74
|
* progress-lexicon stall detection. */
|
|
73
75
|
const LEX_NOVELTY_WINDOW = 8;
|
|
@@ -158,7 +160,9 @@ export class ThinkingLoopDetector {
|
|
|
158
160
|
* only broken by a *new* reference, so filler repeating one fixed
|
|
159
161
|
* path/identifier every paragraph is still caught. */
|
|
160
162
|
#anchorWindow: Set<string>[] = [];
|
|
161
|
-
|
|
163
|
+
/** Most recent normalized substantial segment and its consecutive run length. */
|
|
164
|
+
#lastNorm = "";
|
|
165
|
+
#consecutiveExact = 0;
|
|
162
166
|
push(delta: string): string | null {
|
|
163
167
|
if (!delta) return null;
|
|
164
168
|
|
|
@@ -221,6 +225,16 @@ export class ThinkingLoopDetector {
|
|
|
221
225
|
const normalized = normalizeSegment(segment);
|
|
222
226
|
if (normalized.length < SEGMENT_MIN_NORM_CHARS) return null;
|
|
223
227
|
|
|
228
|
+
const exact = segment.trim();
|
|
229
|
+
if (exact === this.#lastNorm) {
|
|
230
|
+
this.#consecutiveExact++;
|
|
231
|
+
} else {
|
|
232
|
+
this.#lastNorm = exact;
|
|
233
|
+
this.#consecutiveExact = 1;
|
|
234
|
+
}
|
|
235
|
+
if (this.#consecutiveExact >= CONSECUTIVE_EXACT_MIN) {
|
|
236
|
+
return `repeated identical segment ${this.#consecutiveExact}× consecutively`;
|
|
237
|
+
}
|
|
224
238
|
// (a) Near-duplicate trigram cluster: the same paragraph reused with
|
|
225
239
|
// cosmetic wording drift (high word-trigram overlap).
|
|
226
240
|
const fingerprint = trigramShingles(normalized);
|
|
@@ -377,20 +391,37 @@ export function guardThinkingLoopStream(
|
|
|
377
391
|
void (async () => {
|
|
378
392
|
let thinkingArmed = true;
|
|
379
393
|
let textArmed = checkAssistantContent;
|
|
394
|
+
let sawVisibleText = false;
|
|
395
|
+
let sawToolCall = false;
|
|
380
396
|
try {
|
|
381
397
|
for await (const event of inner) {
|
|
382
398
|
let detail: string | null = null;
|
|
383
|
-
if (
|
|
399
|
+
if (event.type === "thinking_start") {
|
|
400
|
+
if (!sawVisibleText && !sawToolCall) {
|
|
401
|
+
thinkingArmed = true;
|
|
402
|
+
}
|
|
403
|
+
} else if (thinkingArmed && event.type === "thinking_delta") {
|
|
384
404
|
detail = thinkingDetector.push(event.delta);
|
|
385
405
|
} else if (thinkingArmed && event.type === "thinking_end") {
|
|
386
406
|
detail = thinkingDetector.flush();
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
407
|
+
} else if (event.type === "text_start") {
|
|
408
|
+
if (checkAssistantContent && !sawToolCall) {
|
|
409
|
+
textArmed = true;
|
|
410
|
+
}
|
|
411
|
+
} else if (event.type === "text_delta") {
|
|
412
|
+
if (event.delta.trim().length > 0) {
|
|
413
|
+
sawVisibleText = true;
|
|
414
|
+
thinkingArmed = false;
|
|
415
|
+
}
|
|
416
|
+
if (textArmed) {
|
|
391
417
|
detail = textDetector.push(event.delta);
|
|
392
418
|
}
|
|
419
|
+
} else if (event.type === "text_end") {
|
|
420
|
+
if (textArmed) {
|
|
421
|
+
detail = textDetector.flush();
|
|
422
|
+
}
|
|
393
423
|
} else if (event.type === "toolcall_start" || event.type === "toolcall_delta") {
|
|
424
|
+
sawToolCall = true;
|
|
394
425
|
thinkingArmed = false;
|
|
395
426
|
textArmed = false;
|
|
396
427
|
} else if (event.type === "done") {
|
|
@@ -290,12 +290,19 @@ export class ToolCallLoopGuard {
|
|
|
290
290
|
result.content.length &&
|
|
291
291
|
result.content.every(part => part.type === "text")
|
|
292
292
|
) {
|
|
293
|
+
const normalizedContent = result.isError
|
|
294
|
+
? result.content.map(part =>
|
|
295
|
+
part.type === "text" ? { type: part.type, text: normalizeVolatileErrorText(part.text) } : part,
|
|
296
|
+
)
|
|
297
|
+
: result.content;
|
|
293
298
|
const fingerprint = Bun.hash(
|
|
294
|
-
JSON.stringify([entry.toolCall.name, entry.canonicalArgs, result.isError,
|
|
299
|
+
JSON.stringify([entry.toolCall.name, entry.canonicalArgs, result.isError, normalizedContent]),
|
|
295
300
|
);
|
|
296
301
|
const count = this.#unchanged?.fingerprint === fingerprint ? this.#unchanged.count + 1 : 1;
|
|
297
302
|
this.#unchanged = { fingerprint, count };
|
|
298
|
-
|
|
303
|
+
const streak = nextStreaks.get(entry.lookupKey) ?? 0;
|
|
304
|
+
const pauseAfter = Math.max(2, this.#threshold);
|
|
305
|
+
if (count >= pauseAfter || (result.isError && streak >= this.#threshold + pauseAfter)) {
|
|
299
306
|
this.#reset();
|
|
300
307
|
return { kind: "stalled_tool_call", toolName: entry.toolCall.name };
|
|
301
308
|
}
|
|
@@ -346,3 +353,11 @@ export class ToolCallLoopGuard {
|
|
|
346
353
|
return { kind: "cyclical_tool_calls", toolNames, windowSize: this.#cycleWindowSize };
|
|
347
354
|
}
|
|
348
355
|
}
|
|
356
|
+
|
|
357
|
+
function normalizeVolatileErrorText(text: string): string {
|
|
358
|
+
return text
|
|
359
|
+
.replace(/\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?\b/g, "<ts>")
|
|
360
|
+
.replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi, "<uuid>")
|
|
361
|
+
.replace(/\b(request[_-]?id|trace[_-]?id|correlation[_-]?id|x-request-id)\s*[:=]\s*[^\s,;}"']+/gi, "$1=<id>")
|
|
362
|
+
.replace(/\b\d+(?:\.\d+)?\s*(?:ms|s)\b/g, "<dur>");
|
|
363
|
+
}
|