chatccc 0.2.142 → 0.2.143
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
CHANGED
package/src/agent-stop-stuck.ts
CHANGED
|
@@ -27,9 +27,9 @@ export async function handleAgentStopStuckRequest(
|
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
let body: { session_id?: string };
|
|
30
|
+
let body: { session_id?: string; final_reply?: string };
|
|
31
31
|
try {
|
|
32
|
-
body = await readUtf8JsonBody<{ session_id?: string }>(req, MAX_REQUEST_BYTES);
|
|
32
|
+
body = await readUtf8JsonBody<{ session_id?: string; final_reply?: string }>(req, MAX_REQUEST_BYTES);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
jsonReply(res, 400, { error: `Invalid request body: ${(err as Error).message}` });
|
|
35
35
|
return true;
|
|
@@ -59,6 +59,8 @@ export async function handleAgentStopStuckRequest(
|
|
|
59
59
|
// 丢弃缓存队列中的消息
|
|
60
60
|
cancelQueuedMessage(sessionId);
|
|
61
61
|
|
|
62
|
+
const finalReply = typeof body?.final_reply === "string" ? body.final_reply.trim() : "";
|
|
63
|
+
|
|
62
64
|
// fire-and-forget:立即把 stream-state 标为 done(而非 stopped),
|
|
63
65
|
// 让 display loop 以"正常完成"而非"已停止"来渲染卡片和最终回复。
|
|
64
66
|
// 不设 prompt.stopped = true,这样 runAgentSession 的 finally 也会写 "done"。
|
|
@@ -70,6 +72,7 @@ export async function handleAgentStopStuckRequest(
|
|
|
70
72
|
await writeStreamState({
|
|
71
73
|
...current,
|
|
72
74
|
status: "done",
|
|
75
|
+
finalReply: finalReply ? current.finalReply + "\n\n" + finalReply : current.finalReply,
|
|
73
76
|
updatedAt: Date.now(),
|
|
74
77
|
});
|
|
75
78
|
} catch (err) {
|
|
@@ -82,7 +85,7 @@ export async function handleAgentStopStuckRequest(
|
|
|
82
85
|
// 不设 stopped 标记 → finally block 写 "done" → 卡片正常结束
|
|
83
86
|
prompt.controller.abort();
|
|
84
87
|
|
|
85
|
-
console.log(`[${ts()}] [STUCK-LOOP] Session ${sessionId} aborted as done (agent detected stuck loop)`);
|
|
88
|
+
console.log(`[${ts()}] [STUCK-LOOP] Session ${sessionId} aborted as done (agent detected stuck loop, final_reply=${finalReply ? "yes" : "no"})`);
|
|
86
89
|
|
|
87
90
|
jsonReply(res, 200, { ok: true });
|
|
88
91
|
return true;
|