@strayl/agent 0.1.14 → 0.1.16
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.js +20 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -7225,6 +7225,12 @@ var LLMClient = class {
|
|
|
7225
7225
|
}
|
|
7226
7226
|
}
|
|
7227
7227
|
}
|
|
7228
|
+
if (!emittedToolCalls && partialToolCalls.size > 0) {
|
|
7229
|
+
const hasIncomplete = [...partialToolCalls.values()].some((p) => !p.id || !p.name);
|
|
7230
|
+
if (hasIncomplete) {
|
|
7231
|
+
throw new Error("LLM stream truncated: incomplete tool calls received (provider may have timed out)");
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
7228
7234
|
}
|
|
7229
7235
|
};
|
|
7230
7236
|
|
|
@@ -13693,7 +13699,9 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13693
13699
|
emitter.emit({ type: "error", message: `LLM failed ${consecutiveLLMErrors} times in a row: ${msg}`, recoverable: false });
|
|
13694
13700
|
break;
|
|
13695
13701
|
}
|
|
13696
|
-
|
|
13702
|
+
const backoffMs = Math.min(2e3 * Math.pow(2, consecutiveLLMErrors - 1), 16e3);
|
|
13703
|
+
emitter.emit({ type: "error", message: `LLM error (${consecutiveLLMErrors}/${MAX_CONSECUTIVE_LLM_ERRORS}): ${msg} \u2014 retrying in ${backoffMs / 1e3}s`, recoverable: true });
|
|
13704
|
+
await new Promise((r) => setTimeout(r, backoffMs));
|
|
13697
13705
|
context.addAssistant(`[Error communicating with model: ${msg}]`);
|
|
13698
13706
|
continue;
|
|
13699
13707
|
}
|
|
@@ -13705,6 +13713,17 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13705
13713
|
emitter.emit({ type: "session-end", usage: context.totalUsage(), exit_reason: "cancelled" });
|
|
13706
13714
|
return;
|
|
13707
13715
|
}
|
|
13716
|
+
if (!assistantText.trim() && completedToolCalls.length === 0) {
|
|
13717
|
+
consecutiveLLMErrors++;
|
|
13718
|
+
if (consecutiveLLMErrors >= MAX_CONSECUTIVE_LLM_ERRORS) {
|
|
13719
|
+
emitter.emit({ type: "error", message: `LLM returned empty response ${consecutiveLLMErrors} times in a row`, recoverable: false });
|
|
13720
|
+
break;
|
|
13721
|
+
}
|
|
13722
|
+
const backoffMs = Math.min(2e3 * Math.pow(2, consecutiveLLMErrors - 1), 16e3);
|
|
13723
|
+
emitter.emit({ type: "error", message: `LLM returned empty response (${consecutiveLLMErrors}/${MAX_CONSECUTIVE_LLM_ERRORS}) \u2014 retrying in ${backoffMs / 1e3}s`, recoverable: true });
|
|
13724
|
+
await new Promise((r) => setTimeout(r, backoffMs));
|
|
13725
|
+
continue;
|
|
13726
|
+
}
|
|
13708
13727
|
consecutiveLLMErrors = 0;
|
|
13709
13728
|
context.addAssistant(assistantText, completedToolCalls.length > 0 ? completedToolCalls : void 0);
|
|
13710
13729
|
{
|