@livx.cc/agentx 0.99.132 → 0.99.134
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/cli.js +18 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5716,12 +5716,12 @@ var Agent = class _Agent {
|
|
|
5716
5716
|
}
|
|
5717
5717
|
const sc = err2?.statusCode;
|
|
5718
5718
|
const serverSide = sc >= 500 || sc === 408 || /Service Unavailable|overloaded|Internal server error|Bad gateway|Gateway time/i.test(String(err2?.message ?? ""));
|
|
5719
|
-
const network = !sc && /ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|socket hang up|fetch failed|network|terminated|UND_ERR/i.test(String(err2?.message ?? err2?.code ?? err2));
|
|
5719
|
+
const network = !sc && /ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|socket hang up|socket connection was closed|closed unexpectedly|stream failed mid-response|premature close|fetch failed|network|terminated|UND_ERR/i.test(String(err2?.message ?? err2?.code ?? err2));
|
|
5720
5720
|
const stalled = err2?.code === "stall";
|
|
5721
5721
|
const empty = err2?.code === "empty" || err2?.code === "cursor_silent";
|
|
5722
5722
|
const maxAttempts = empty ? Math.max(o.emptyRetries, 0) : 2;
|
|
5723
|
-
const replaysTool = stalled && this.toolRanThisAttempt;
|
|
5724
|
-
if (replaysTool) log9.warn(
|
|
5723
|
+
const replaysTool = (stalled || network) && this.toolRanThisAttempt;
|
|
5724
|
+
if (replaysTool) log9.warn(`model ${stalled ? "stall" : "network drop"} after tool(s) already ran this step \u2014 not retrying (a retry would replay them)`);
|
|
5725
5725
|
const transient = !o.signal?.aborted && !isAbortError(err2) && !replaysTool && attempt < maxAttempts && (network || serverSide || stalled || empty);
|
|
5726
5726
|
if (!transient) throw err2;
|
|
5727
5727
|
const waitMs = (empty ? o.emptyRetryBaseMs : 1e3) * (attempt + 1);
|
|
@@ -6232,7 +6232,7 @@ ${out}`;
|
|
|
6232
6232
|
o.host?.notify?.({ kind: "compaction", message: `context full \u2014 auto-trimmed ${dropped} oldest message(s) to fit ~${Math.round(o.maxContextTokens / 1e3)}k tokens` });
|
|
6233
6233
|
}
|
|
6234
6234
|
}
|
|
6235
|
-
out = dropOrphanToolResults(out);
|
|
6235
|
+
out = answerOpenToolCalls(dropOrphanToolResults(out));
|
|
6236
6236
|
if (/^google\//.test(o.model ?? "")) out = hoistToolImages(out);
|
|
6237
6237
|
return scrubBase64(out);
|
|
6238
6238
|
}
|
|
@@ -6408,6 +6408,20 @@ var callIdSet = (msgs) => {
|
|
|
6408
6408
|
for (const m of msgs) if (m.role === "assistant") for (const tc of m.tool_calls ?? []) ids.add(tc.id);
|
|
6409
6409
|
return ids;
|
|
6410
6410
|
};
|
|
6411
|
+
function answerOpenToolCalls(messages) {
|
|
6412
|
+
const answered = new Set(messages.filter((m) => m.role === "tool").map((m) => m.tool_call_id ?? ""));
|
|
6413
|
+
if (messages.every((m) => m.role !== "assistant" || (m.tool_calls ?? []).every((tc) => answered.has(tc.id)))) return messages;
|
|
6414
|
+
const out = [];
|
|
6415
|
+
for (let i = 0; i < messages.length; i++) {
|
|
6416
|
+
const m = messages[i];
|
|
6417
|
+
out.push(m);
|
|
6418
|
+
const open = m.role === "assistant" ? (m.tool_calls ?? []).filter((tc) => !answered.has(tc.id)) : [];
|
|
6419
|
+
if (!open.length) continue;
|
|
6420
|
+
while (i + 1 < messages.length && messages[i + 1].role === "tool") out.push(messages[++i]);
|
|
6421
|
+
for (const tc of open) out.push({ role: "tool", tool_call_id: tc.id, name: tc.function?.name, content: "not run \u2014 the turn stopped before this call (a limit or an interruption); run it again if it is still needed" });
|
|
6422
|
+
}
|
|
6423
|
+
return out;
|
|
6424
|
+
}
|
|
6411
6425
|
function dropOrphanToolResults(messages) {
|
|
6412
6426
|
const ids = callIdSet(messages);
|
|
6413
6427
|
const ok = (m) => m.role !== "tool" || ids.has(m.tool_call_id ?? "");
|