@krmxd/onegpt 0.2.0-beta → 0.2.1-beta
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 +1 -1
- package/src/agent.js +20 -6
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -131,7 +131,15 @@ const EXECUTE_NUDGE =
|
|
|
131
131
|
|
|
132
132
|
function wantsAction(userInput) {
|
|
133
133
|
// True when the user asked for something to be built (not explained).
|
|
134
|
-
|
|
134
|
+
const t = String(userInput || "").trim();
|
|
135
|
+
const tm = TASK_RE.exec(t);
|
|
136
|
+
if (!tm) return false;
|
|
137
|
+
// A question word BEFORE the build verb means they're ASKING, not
|
|
138
|
+
// requesting work: "how do I fix the login bug?" must be answered,
|
|
139
|
+
// not turned into a flurry of file edits.
|
|
140
|
+
const qm = /\b(how|what|why|when|where|which|who|whom|explain|describe)\b/i.exec(t);
|
|
141
|
+
if (qm && qm.index < tm.index) return false;
|
|
142
|
+
return true;
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
function redirectMsg(task) {
|
|
@@ -631,8 +639,11 @@ class Agent {
|
|
|
631
639
|
// Self-correction: instructions/code instead of done work gets one
|
|
632
640
|
// firm push to act - on ANY round, not just the first (tiny models
|
|
633
641
|
// relapse into how-to mode mid-task). An EMPTY reply after partial
|
|
634
|
-
// work means it stalled - push it too.
|
|
635
|
-
|
|
642
|
+
// work means it stalled - push it too. BUT a reply is never "lazy"
|
|
643
|
+
// once real work happened this turn: closing summaries often quote
|
|
644
|
+
// commands in fences ("run it with ```npm start```") - nudging then
|
|
645
|
+
// made the model edit files over and over instead of answering.
|
|
646
|
+
const replyLazy = repliedWithoutActing(resp.content) && doneBits.length === 0;
|
|
636
647
|
const wentSilent = !resp.content.trim() && (rounds > 1 || doneBits.length > 0);
|
|
637
648
|
if (nudges < 3 && !this._cancelled
|
|
638
649
|
&& wantsAction(userInput) && (replyLazy || wentSilent || stalledHalfway(resp.content, userInput, doneBits))) {
|
|
@@ -784,8 +795,11 @@ class Agent {
|
|
|
784
795
|
// Self-correction: instructions/code instead of done work gets one
|
|
785
796
|
// firm push to act - on ANY round, not just the first (tiny models
|
|
786
797
|
// relapse into how-to mode mid-task). An EMPTY reply after partial
|
|
787
|
-
// work means it stalled - push it too.
|
|
788
|
-
|
|
798
|
+
// work means it stalled - push it too. BUT a reply is never "lazy"
|
|
799
|
+
// once real work happened this turn: closing summaries often quote
|
|
800
|
+
// commands in fences ("run it with ```npm start```") - nudging then
|
|
801
|
+
// made the model edit files over and over instead of answering.
|
|
802
|
+
const replyLazy = repliedWithoutActing(full) && doneBits.length === 0;
|
|
789
803
|
const wentSilent = !full.trim() && (rounds > 1 || doneBits.length > 0);
|
|
790
804
|
if (nudges < 3 && !this._cancelled
|
|
791
805
|
&& wantsAction(userInput) && (replyLazy || wentSilent || stalledHalfway(full, userInput, doneBits))) {
|
|
@@ -892,4 +906,4 @@ class Agent {
|
|
|
892
906
|
}
|
|
893
907
|
}
|
|
894
908
|
|
|
895
|
-
module.exports = { Agent, extractJsonTools, repairToolJson };
|
|
909
|
+
module.exports = { Agent, extractJsonTools, repairToolJson, wantsAction, repliedWithoutActing, stalledHalfway };
|