nexrall-code 0.5.104 → 0.5.105
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/index.js +30 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -103400,7 +103400,9 @@ var require_loop = __commonJS({
|
|
|
103400
103400
|
};
|
|
103401
103401
|
}();
|
|
103402
103402
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
103403
|
-
exports2.VERIFY_CMD_RE = exports2.WRITE_TOOL_NAMES = exports2.ToolNotAllowedError = exports2.AGENT_MEMORY_TOOL_SCHEMA = exports2.AGENT_MEMORY_TOOL = exports2._stallLimits = exports2.bashNeedsRepoLock = void 0;
|
|
103403
|
+
exports2.VERIFY_CMD_RE = exports2.WRITE_TOOL_NAMES = exports2.ToolNotAllowedError = exports2.AGENT_MEMORY_TOOL_SCHEMA = exports2.AGENT_MEMORY_TOOL = exports2._stallLimits = exports2._emptyTurnRetry = exports2.bashNeedsRepoLock = void 0;
|
|
103404
|
+
exports2.emptyTurnBackoffMs = emptyTurnBackoffMs;
|
|
103405
|
+
exports2.shouldRetryEmptyTurn = shouldRetryEmptyTurn;
|
|
103404
103406
|
exports2.errorRoundSignature = errorRoundSignature;
|
|
103405
103407
|
exports2.executeAgentMemoryWrite = executeAgentMemoryWrite;
|
|
103406
103408
|
exports2.stopReasonNotice = stopReasonNotice;
|
|
@@ -103557,6 +103559,17 @@ var require_loop = __commonJS({
|
|
|
103557
103559
|
var HARD_ITERATIONS_CAP = Infinity;
|
|
103558
103560
|
var STALL_LIMIT = 8;
|
|
103559
103561
|
var REPEAT_STALL_LIMIT = 12;
|
|
103562
|
+
var EMPTY_TURN_RETRY_LIMIT = 3;
|
|
103563
|
+
var EMPTY_TURN_RETRY_BASE_MS = 1e3;
|
|
103564
|
+
function emptyTurnBackoffMs(attempt) {
|
|
103565
|
+
return EMPTY_TURN_RETRY_BASE_MS * Math.pow(2, Math.max(0, attempt));
|
|
103566
|
+
}
|
|
103567
|
+
function shouldRetryEmptyTurn(stopReason, attemptsSoFar) {
|
|
103568
|
+
if (stopReason === "max_tokens")
|
|
103569
|
+
return false;
|
|
103570
|
+
return attemptsSoFar < EMPTY_TURN_RETRY_LIMIT;
|
|
103571
|
+
}
|
|
103572
|
+
exports2._emptyTurnRetry = { EMPTY_TURN_RETRY_LIMIT, EMPTY_TURN_RETRY_BASE_MS };
|
|
103560
103573
|
function errorRoundSignature(errored) {
|
|
103561
103574
|
return errored.map(({ name, error }) => `${name}:${String(error).slice(0, 200)}`).sort().join("|");
|
|
103562
103575
|
}
|
|
@@ -103600,7 +103613,7 @@ var require_loop = __commonJS({
|
|
|
103600
103613
|
return null;
|
|
103601
103614
|
case "empty-response":
|
|
103602
103615
|
return `
|
|
103603
|
-
\u26A0\uFE0F The model returned an empty response, so nothing was done. This is usually a transient upstream hiccup
|
|
103616
|
+
\u26A0\uFE0F The model returned an empty response ${EMPTY_TURN_RETRY_LIMIT} times in a row, so nothing was done. This is usually a transient upstream hiccup that the agent retries by itself; it did not clear this time. Send "continue" to try again, or switch model with /model if it persists.
|
|
103604
103617
|
`;
|
|
103605
103618
|
case "output-limit":
|
|
103606
103619
|
return `
|
|
@@ -104763,6 +104776,7 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
|
|
|
104763
104776
|
let stalledRepeatError = null;
|
|
104764
104777
|
let budget = maxIterations;
|
|
104765
104778
|
let iteration = 0;
|
|
104779
|
+
let emptyTurnRetries = 0;
|
|
104766
104780
|
let filesMutatedSinceVerify = false;
|
|
104767
104781
|
let ranVerificationCmd = false;
|
|
104768
104782
|
let verificationNudgeSent = false;
|
|
@@ -104954,10 +104968,24 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
|
|
|
104954
104968
|
messages.push({ role: "user", content: [{ type: "text", text }] });
|
|
104955
104969
|
continue;
|
|
104956
104970
|
}
|
|
104971
|
+
if (shouldRetryEmptyTurn(assistantMessage.stopReason, emptyTurnRetries)) {
|
|
104972
|
+
const waitMs = emptyTurnBackoffMs(emptyTurnRetries);
|
|
104973
|
+
emptyTurnRetries++;
|
|
104974
|
+
options.onRetry?.(emptyTurnRetries, EMPTY_TURN_RETRY_LIMIT, "The model returned an empty response \u2014 retrying automatically");
|
|
104975
|
+
await new Promise((r2) => setTimeout(r2, waitMs));
|
|
104976
|
+
if (options.abortSignal?.aborted) {
|
|
104977
|
+
stopReason = "aborted";
|
|
104978
|
+
break;
|
|
104979
|
+
}
|
|
104980
|
+
options.onRetryResolved?.();
|
|
104981
|
+
iteration--;
|
|
104982
|
+
continue;
|
|
104983
|
+
}
|
|
104957
104984
|
runSimpleHooks(hooks.PostMessageComplete, options.workDir);
|
|
104958
104985
|
stopReason = assistantMessage.stopReason === "max_tokens" ? "output-limit" : "empty-response";
|
|
104959
104986
|
break;
|
|
104960
104987
|
}
|
|
104988
|
+
emptyTurnRetries = 0;
|
|
104961
104989
|
const { stopReason: _stopReason, ...historyMessage } = assistantMessage;
|
|
104962
104990
|
messages.push(historyMessage);
|
|
104963
104991
|
const serverSideResultIds = new Set(assistantMessage.content.filter((b) => b.type === "tool_result").map((b) => b.tool_use_id).filter((id) => !!id));
|