opencode-lore 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/index.ts +15 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -395,12 +395,25 @@ export const LorePlugin: Plugin = async (ctx) => {
|
|
|
395
395
|
// so the append-only sequence stays intact for prompt caching.
|
|
396
396
|
if (result.layer > 0) {
|
|
397
397
|
// The API requires the conversation to end with a user message.
|
|
398
|
-
//
|
|
399
|
-
//
|
|
398
|
+
// Drop trailing non-user messages, but stop if we hit an assistant message
|
|
399
|
+
// with an in-progress (non-completed) tool call — dropping it would cause
|
|
400
|
+
// the model to lose its pending tool invocation and re-issue it in an
|
|
401
|
+
// infinite loop. A completed tool part is safe to drop; a pending one is not.
|
|
400
402
|
while (
|
|
401
403
|
result.messages.length > 0 &&
|
|
402
404
|
result.messages.at(-1)!.info.role !== "user"
|
|
403
405
|
) {
|
|
406
|
+
const last = result.messages.at(-1)!;
|
|
407
|
+
const hasPendingTool = last.parts.some(
|
|
408
|
+
(p) => p.type === "tool" && p.state.status !== "completed",
|
|
409
|
+
);
|
|
410
|
+
if (hasPendingTool) {
|
|
411
|
+
console.error(
|
|
412
|
+
"[lore] WARN: cannot drop trailing assistant message with pending tool call — may cause prefill error. id:",
|
|
413
|
+
last.info.id,
|
|
414
|
+
);
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
404
417
|
const dropped = result.messages.pop()!;
|
|
405
418
|
console.error(
|
|
406
419
|
"[lore] WARN: dropping trailing",
|