@strayl/agent 0.1.19 → 0.1.21
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 +7 -16
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -13563,9 +13563,7 @@ async function runAgent(config) {
|
|
|
13563
13563
|
const maxIterations = config.maxIterations ?? 200;
|
|
13564
13564
|
let consecutiveLLMErrors = 0;
|
|
13565
13565
|
const MAX_CONSECUTIVE_LLM_ERRORS = 5;
|
|
13566
|
-
let
|
|
13567
|
-
const MAX_CONSECUTIVE_TEXT_ONLY = 3;
|
|
13568
|
-
let totalToolCallsExecuted = 0;
|
|
13566
|
+
let nudgedToContinue = false;
|
|
13569
13567
|
if (config.restoreCheckpoint) {
|
|
13570
13568
|
const cp = config.restoreCheckpoint;
|
|
13571
13569
|
context.restoreMessages(cp.messages);
|
|
@@ -13752,21 +13750,14 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13752
13750
|
});
|
|
13753
13751
|
}
|
|
13754
13752
|
if (completedToolCalls.length === 0) {
|
|
13755
|
-
if (
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
const completionPattern = /\b(task\s+(is\s+)?complete|all\s+done|finished|ready\s+to\s+(use|go|test)|work\s+is\s+done|that'?s\s+it|nothing\s+(else|more)\s+to\s+do|i'?m\s+done)\b/i;
|
|
13760
|
-
const isExplicitlyDone = completionPattern.test(assistantText);
|
|
13761
|
-
if (isExplicitlyDone || consecutiveTextOnly >= MAX_CONSECUTIVE_TEXT_ONLY) {
|
|
13762
|
-
break;
|
|
13753
|
+
if (!nudgedToContinue) {
|
|
13754
|
+
nudgedToContinue = true;
|
|
13755
|
+
context.addUser("[System: You responded with text but did not call any tools. If you are done, respond with your final message. Otherwise, use your tools to continue working.]");
|
|
13756
|
+
continue;
|
|
13763
13757
|
}
|
|
13764
|
-
|
|
13765
|
-
emitter.emit({ type: "text-delta", text: "" });
|
|
13766
|
-
continue;
|
|
13758
|
+
break;
|
|
13767
13759
|
}
|
|
13768
|
-
|
|
13769
|
-
totalToolCallsExecuted += completedToolCalls.length;
|
|
13760
|
+
nudgedToContinue = false;
|
|
13770
13761
|
for (const tc of completedToolCalls) {
|
|
13771
13762
|
if (stdin.isCancelled()) {
|
|
13772
13763
|
context.addToolResult(tc.id, tc.function.name, JSON.stringify({ error: "Cancelled by user." }));
|