jeopi-ai 16.7.1 → 16.7.3
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
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.7.2] - 2026-11-20
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Detect when consecutive reads of the same file return identical text even if the requested page changes, while allowing reads that return new content.
|
|
10
|
+
|
|
5
11
|
## [16.7.1] - 2026-11-20
|
|
6
12
|
|
|
7
13
|
### Fixed
|
|
@@ -26,7 +26,10 @@ export interface CyclicalToolCallDetection {
|
|
|
26
26
|
readonly toolNames: readonly string[];
|
|
27
27
|
readonly windowSize: number;
|
|
28
28
|
}
|
|
29
|
-
export type ToolCallLoopDetection = RepeatedToolCallDetection | CyclicalToolCallDetection
|
|
29
|
+
export type ToolCallLoopDetection = RepeatedToolCallDetection | CyclicalToolCallDetection | {
|
|
30
|
+
readonly kind: "stalled_tool_call";
|
|
31
|
+
readonly toolName: string;
|
|
32
|
+
};
|
|
30
33
|
/** Detects consecutive identical or semantically repeated assistant tool calls across model turns. */
|
|
31
34
|
export declare class ToolCallLoopGuard {
|
|
32
35
|
#private;
|
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.3",
|
|
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.3",
|
|
42
|
+
"jeopi-utils": "16.7.3",
|
|
43
|
+
"jeopi-wire": "16.7.3",
|
|
44
44
|
"arktype": "2.2.3",
|
|
45
45
|
"zod": "^4"
|
|
46
46
|
},
|
|
@@ -36,7 +36,10 @@ export interface CyclicalToolCallDetection {
|
|
|
36
36
|
readonly windowSize: number;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export type ToolCallLoopDetection =
|
|
39
|
+
export type ToolCallLoopDetection =
|
|
40
|
+
| RepeatedToolCallDetection
|
|
41
|
+
| CyclicalToolCallDetection
|
|
42
|
+
| { readonly kind: "stalled_tool_call"; readonly toolName: string };
|
|
40
43
|
|
|
41
44
|
function canonicalizeToolCallValue(value: unknown): unknown {
|
|
42
45
|
if (Array.isArray(value)) {
|
|
@@ -166,7 +169,7 @@ export class ToolCallLoopGuard {
|
|
|
166
169
|
#threshold: number;
|
|
167
170
|
#exemptTools: ReadonlySet<string>;
|
|
168
171
|
#callStreaks = new Map<string, number>();
|
|
169
|
-
#
|
|
172
|
+
#unchanged: { fingerprint: bigint; count: number } | undefined;
|
|
170
173
|
#cycleWindowSize: number;
|
|
171
174
|
#recentCalls: Array<{ hash: string; toolNames: string[] }> = [];
|
|
172
175
|
#lastCycleSignature: string | undefined;
|
|
@@ -191,13 +194,13 @@ export class ToolCallLoopGuard {
|
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
#reset(): void {
|
|
197
|
+
this.#unchanged = undefined;
|
|
194
198
|
this.#callStreaks.clear();
|
|
195
|
-
this.#lastReadStartByPath.clear();
|
|
196
199
|
this.#recentCalls = [];
|
|
197
200
|
this.#lastCycleSignature = undefined;
|
|
198
201
|
}
|
|
199
202
|
|
|
200
|
-
#computeLookupKey(toolCall: ToolCall, canonicalArgs: string,
|
|
203
|
+
#computeLookupKey(toolCall: ToolCall, canonicalArgs: string, toolResults: readonly ToolResultMessage[]): string {
|
|
201
204
|
const args =
|
|
202
205
|
toolCall.arguments && typeof toolCall.arguments === "object" && !Array.isArray(toolCall.arguments)
|
|
203
206
|
? (toolCall.arguments as Record<string, unknown>)
|
|
@@ -217,12 +220,15 @@ export class ToolCallLoopGuard {
|
|
|
217
220
|
if (toolCall.name === "read" && args) {
|
|
218
221
|
const target = parseReadTarget(args);
|
|
219
222
|
if (target) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
|
|
223
|
+
// A changing selector is only progress if the read actually returns new content.
|
|
224
|
+
const result = toolResults.find(candidate => candidate.toolCallId === toolCall.id);
|
|
225
|
+
if (result && !result.isError && result.content.every(block => block.type === "text")) {
|
|
226
|
+
const textParts = result.content.map(block => block.text);
|
|
227
|
+
if (textParts.some(text => text.trim().length > 0)) {
|
|
228
|
+
return `read:result:${target.basePath}:${Bun.hash(JSON.stringify(textParts))}`;
|
|
229
|
+
}
|
|
224
230
|
}
|
|
225
|
-
return `read:
|
|
231
|
+
return `read:page:${target.basePath}:${target.startLine}`;
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
|
|
@@ -239,10 +245,10 @@ export class ToolCallLoopGuard {
|
|
|
239
245
|
|
|
240
246
|
const trackedCalls = allToolCalls.filter(call => !this.#isExemptToolCall(call));
|
|
241
247
|
if (trackedCalls.length === 0) {
|
|
248
|
+
this.#unchanged = undefined;
|
|
242
249
|
return null;
|
|
243
250
|
}
|
|
244
251
|
|
|
245
|
-
const nextReadStartByPath = new Map<string, number>(this.#lastReadStartByPath);
|
|
246
252
|
const turnEntries: Array<{
|
|
247
253
|
lookupKey: string;
|
|
248
254
|
toolCall: ToolCall;
|
|
@@ -252,27 +258,51 @@ export class ToolCallLoopGuard {
|
|
|
252
258
|
|
|
253
259
|
for (const toolCall of trackedCalls) {
|
|
254
260
|
const canonicalArgs = JSON.stringify(canonicalizeToolCallValue(toolCall.arguments));
|
|
255
|
-
const lookupKey = this.#computeLookupKey(toolCall, canonicalArgs,
|
|
261
|
+
const lookupKey = this.#computeLookupKey(toolCall, canonicalArgs, turn.toolResults);
|
|
256
262
|
if (seenLookupKeys.has(lookupKey)) continue;
|
|
257
263
|
seenLookupKeys.add(lookupKey);
|
|
258
264
|
turnEntries.push({ lookupKey, toolCall, canonicalArgs });
|
|
259
265
|
}
|
|
260
266
|
|
|
261
|
-
this.#lastReadStartByPath = nextReadStartByPath;
|
|
262
|
-
|
|
263
267
|
const nextStreaks = new Map<string, number>();
|
|
264
268
|
let hitEntry: { toolCall: ToolCall; canonicalArgs: string; count: number } | undefined;
|
|
265
269
|
|
|
266
270
|
for (const entry of turnEntries) {
|
|
267
271
|
const count = (this.#callStreaks.get(entry.lookupKey) ?? 0) + 1;
|
|
268
272
|
nextStreaks.set(entry.lookupKey, count);
|
|
269
|
-
if (count
|
|
273
|
+
if (count === this.#threshold && !hitEntry) {
|
|
270
274
|
hitEntry = { toolCall: entry.toolCall, canonicalArgs: entry.canonicalArgs, count };
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
|
|
274
278
|
this.#callStreaks = nextStreaks;
|
|
275
279
|
|
|
280
|
+
// The redirect uses a broad semantic match. Pausing needs stronger evidence:
|
|
281
|
+
// one exact call and the same full text result, after a redirect was sent.
|
|
282
|
+
const entry = turnEntries[0];
|
|
283
|
+
const result = turn.toolResults[0];
|
|
284
|
+
if (
|
|
285
|
+
allToolCalls.length === 1 &&
|
|
286
|
+
entry &&
|
|
287
|
+
(nextStreaks.get(entry.lookupKey) ?? 0) > this.#threshold &&
|
|
288
|
+
turn.toolResults.length === 1 &&
|
|
289
|
+
result?.toolCallId === entry.toolCall.id &&
|
|
290
|
+
result.content.length &&
|
|
291
|
+
result.content.every(part => part.type === "text")
|
|
292
|
+
) {
|
|
293
|
+
const fingerprint = Bun.hash(
|
|
294
|
+
JSON.stringify([entry.toolCall.name, entry.canonicalArgs, result.isError, result.content]),
|
|
295
|
+
);
|
|
296
|
+
const count = this.#unchanged?.fingerprint === fingerprint ? this.#unchanged.count + 1 : 1;
|
|
297
|
+
this.#unchanged = { fingerprint, count };
|
|
298
|
+
if (count >= Math.max(2, this.#threshold)) {
|
|
299
|
+
this.#reset();
|
|
300
|
+
return { kind: "stalled_tool_call", toolName: entry.toolCall.name };
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
this.#unchanged = undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
276
306
|
if (hitEntry) {
|
|
277
307
|
return {
|
|
278
308
|
kind: "repeated_tool_call",
|