@strayl/agent 0.1.16 → 0.1.18

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.
Files changed (2) hide show
  1. package/dist/agent.js +28 -2
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -133,7 +133,15 @@ Use sub-agents aggressively for parallel speedup:
133
133
  Create todos when: 3+ files involved, installing packages + writing code, sequential dependencies.
134
134
  Do NOT create todos for: single file edits, research only, single commands.
135
135
  Granularity: ONE completable action per todo.
136
- Lifecycle: create todos \u2192 set in_progress \u2192 completed \u2192 write_todos({ todos: [] }) when all done.`;
136
+ Lifecycle: create todos \u2192 set in_progress \u2192 completed \u2192 write_todos({ todos: [] }) when all done.
137
+
138
+ ## Task Completion
139
+ - Keep working until the user's request is FULLY implemented \u2014 do not stop after one step of a multi-step task
140
+ - After each action, verify the result and proceed to the next step
141
+ - A task is complete ONLY when: code is written, verified (build/test), and the feature works end-to-end
142
+ - If you output a text response without using tools, the system will ask you to continue \u2014 use your tools to make progress
143
+ - When truly done, include a clear completion statement (e.g., "The task is complete" or "All done")
144
+ - NEVER stop just because you explained what you did \u2014 actually verify it works`;
137
145
  PLAN_MODE_SYSTEM_PROMPT = `
138
146
 
139
147
  ## PLAN MODE \u2014 YOU CAN ONLY DO 3 THINGS
@@ -13555,6 +13563,9 @@ async function runAgent(config) {
13555
13563
  const maxIterations = config.maxIterations ?? 200;
13556
13564
  let consecutiveLLMErrors = 0;
13557
13565
  const MAX_CONSECUTIVE_LLM_ERRORS = 5;
13566
+ let consecutiveTextOnly = 0;
13567
+ const MAX_CONSECUTIVE_TEXT_ONLY = 3;
13568
+ let totalToolCallsExecuted = 0;
13558
13569
  if (config.restoreCheckpoint) {
13559
13570
  const cp = config.restoreCheckpoint;
13560
13571
  context.restoreMessages(cp.messages);
@@ -13740,7 +13751,22 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
13740
13751
  context_left_percent: leftPercent
13741
13752
  });
13742
13753
  }
13743
- if (completedToolCalls.length === 0) break;
13754
+ if (completedToolCalls.length === 0) {
13755
+ if (totalToolCallsExecuted === 0) {
13756
+ break;
13757
+ }
13758
+ consecutiveTextOnly++;
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;
13763
+ }
13764
+ context.addUser("[System: You responded with text but did not use any tools. If the task is complete, say so explicitly. Otherwise, continue working \u2014 use your tools to make progress on the user's request.]");
13765
+ emitter.emit({ type: "text-delta", text: "" });
13766
+ continue;
13767
+ }
13768
+ consecutiveTextOnly = 0;
13769
+ totalToolCallsExecuted += completedToolCalls.length;
13744
13770
  for (const tc of completedToolCalls) {
13745
13771
  if (stdin.isCancelled()) {
13746
13772
  context.addToolResult(tc.id, tc.function.name, JSON.stringify({ error: "Cancelled by user." }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strayl/agent",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"