kiosapi 0.1.23 → 0.1.24
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/run.js +17 -4
- package/package.json +1 -1
package/dist/agent/run.js
CHANGED
|
@@ -550,10 +550,23 @@ export async function runTurn(s, userText) {
|
|
|
550
550
|
if (count > 1 && READ_ONLY_TOOLS.has(call.function.name) && toolCache.has(sig)) {
|
|
551
551
|
const toolName = call.function.name;
|
|
552
552
|
const cachedOut = toolCache.get(sig) ?? '';
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
553
|
+
// Always include the cached content so the model has the data it needs even after
|
|
554
|
+
// trimContext drops old messages from its window. The escalating warning text
|
|
555
|
+
// discourages repetition; withholding the content at count=3+ only causes the model
|
|
556
|
+
// to keep retrying — counter-productive to stopping the loop.
|
|
557
|
+
const stopNote = count >= COUNT_LIMIT - 1
|
|
558
|
+
? `\n\n⚠ STOP (ke-${count}): JANGAN panggil "${toolName}" lagi dengan argumen yang sama. Gunakan tool "selesai" dan jelaskan kendalanya, atau gunakan cari/baca_file dengan path/range BERBEDA.`
|
|
559
|
+
: `\n\n⚠ Cache ke-${count}: "${toolName}" sudah dipanggil ${count}× dengan argumen sama. Gunakan cari atau baca_file(path, mulai=N) untuk bagian berbeda.`;
|
|
560
|
+
const warn = `[Cache ke-${count}]\n${cachedOut}${stopNote}`;
|
|
561
|
+
const cachePathHint = (() => {
|
|
562
|
+
try {
|
|
563
|
+
return ` ${JSON.parse(call.function.arguments).path ?? ''}`;
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
return '';
|
|
567
|
+
}
|
|
568
|
+
})();
|
|
569
|
+
console.log(dim(` ↩ ${toolName}${cachePathHint} (cache ke-${count})`));
|
|
557
570
|
s.messages.push({ role: 'tool', content: warn, tool_call_id: call.id });
|
|
558
571
|
continue;
|
|
559
572
|
}
|