@bolt-cli/cli 0.15.4 → 0.15.5

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/lib/agent.js +34 -3
  2. package/package.json +1 -1
package/lib/agent.js CHANGED
@@ -117,7 +117,7 @@ function summarizeDetail(detail, seenDetails = null) {
117
117
  // thinking is not streamed; with the task buried mid-prompt it spent the whole
118
118
  // reply there and emitted nothing. This says, in the position that demonstrably
119
119
  // works, to answer visibly now - removing the wasted ~30s inference entirely.
120
- const OUTPUT_DIRECTIVE = `The operator's task above is still active - do it in THIS reply. Emit operator-visible text only: either plain prose or a fenced tool block. Internal reasoning and hidden thinking are NOT delivered to the operator and leave them staring at an empty screen - do not spend the reply on them. If you need to think, first emit a short visible progress line, then continue. Never end a turn with no visible output.`;
120
+ const OUTPUT_DIRECTIVE = `The operator's task above is still active - do it in THIS reply. Emit operator-visible text only: either the finished answer or a fenced tool block. Do NOT announce what you will do, describe your plan, or say "I'll create it" - do it now in the same reply. Internal reasoning and hidden thinking are NOT delivered to the operator and leave them staring at an empty screen - do not spend the reply on them. A progress line alone is not an answer. Never end a turn with only a promise or with no visible output.`;
121
121
 
122
122
  function buildAgentPrompt({ target, objective, evidence, history, memory, session, account }) {
123
123
  return `${api.buildPrompt({ target, objective, evidence, history, memory, session, account })}\n\n${TOOL_PROTOCOL}\n\n${OUTPUT_DIRECTIVE}`;
@@ -125,6 +125,23 @@ function buildAgentPrompt({ target, objective, evidence, history, memory, sessio
125
125
 
126
126
  const EMPTY_REPLY_NUDGE = `Your previous reply arrived at this terminal empty - no prose and no tool block. That is a protocol failure, not an answer. The ORIGINAL TASK is still in this message, above this note: do it now. Do not ask what the task is, do not ask for a target, and do not describe what you could do. Do not re-send internal reasoning, 自知 blocks or tool call syntax in any other shape. Either continue the task with one or more \`\`\`tool blocks, or give the finished answer in plain prose.`;
127
127
 
128
+ // A reply like "I'll create a Python port scanner for you." has prose, so the
129
+ // loop used to call it a final answer and stop — 49s and 1,677 tokens spent to
130
+ // announce work that never happened. Detect the promise-only shape and keep
131
+ // going; a deliverable (code fence) or a tool call is what ends a run.
132
+ const PROMISE_VERBS = "(?:create|write|build|make|run|check|scan|generate|produce|start|set up|install|read|look|try|do|fix|add|find|get|show|give|continue|proceed|execute|prepare|analy[sz]e|design|implement|test|deploy|compil[e]|open|load|fetch|query|list|search|inspect|review|report|explain|summari[sz]e)";
133
+ const PROMISE_RE = new RegExp(`(?:I'?ll|I will|I'?m going to|I shall|let me|now I(?:'ll| will)?)\\s+${PROMISE_VERBS}\\b`, "i");
134
+
135
+ function isPromiseOnlyReply(text) {
136
+ const s = String(text || "").trim();
137
+ if (!s || s.length > 300) return false;
138
+ // A code block or tool syntax is a deliverable, even if short.
139
+ if (/```|~~~|<(?:tool|function|invoke)\b/i.test(s)) return false;
140
+ return PROMISE_RE.test(s);
141
+ }
142
+
143
+ const PROMISE_NUDGE = `Your last reply only announced what you would do - no tool block, no code and no result reached the operator. That is not an answer. Do the work NOW in this reply: emit a fenced tool block for each step, or give the finished deliverable as your answer. Do not describe the plan, do not announce intent, and do not ask what the task is - the ORIGINAL TASK is still in this message, above this note.`;
144
+
128
145
  function buildFollowup({ iteration, calls, results, errors = [], seenDetails = null, maxIters = DEFAULT_MAX_ITERS, syntaxNote = null }) {
129
146
  const lines = [`TOOL_RESULTS for iteration ${iteration} (ground truth from this terminal - do not invent, continue the task):`];
130
147
  for (let i = 0; i < calls.length; i += 1) {
@@ -206,6 +223,7 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
206
223
  let done = null;
207
224
  let iters = 0;
208
225
  let nudged = false; // one silent-reply recovery per run
226
+ let promiseNudged = false; // one promise-only recovery per run
209
227
  let cancelled = false;
210
228
  const toolCalls = [];
211
229
  // Byte-identical tool results across the run collapse to a pointer line
@@ -339,7 +357,19 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
339
357
  // rejection and restate its intent, or it concludes the channel is broken
340
358
  // and refuses work the terminal could have done. maxIters still bounds us.
341
359
  if (!calls.length && !errors.length) {
342
- if (cleaned.trim()) break; // normal final answer
360
+ const visible = cleaned.trim();
361
+ if (visible) {
362
+ // "I'll create the script for you." is prose but not a result. The
363
+ // loop must not reward it with a stop — keep the original task alive
364
+ // and demand the deliverable in this reply.
365
+ if (isPromiseOnlyReply(visible) && !promiseNudged && iters < maxIters) {
366
+ promiseNudged = true;
367
+ emit({ type: "retry", reason: "promise-only", message: "reply announced work without doing it - continuing with the original task" });
368
+ prompt = `${basePrompt}\n\n${PROMISE_NUDGE}`;
369
+ continue;
370
+ }
371
+ break; // normal final answer
372
+ }
343
373
  // Empty reply — the classic "replied with nothing" failure. Nudge
344
374
  // once; a second consecutive silent reply stops the run honestly.
345
375
  // Resend the original objective WITH the note: a bare nudge costs two
@@ -351,6 +381,7 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
351
381
  continue;
352
382
  }
353
383
  nudged = false;
384
+ promiseNudged = false;
354
385
 
355
386
  if (signal && signal.aborted) {
356
387
  cancelled = true;
@@ -376,4 +407,4 @@ function toolFenceWriter(write) {
376
407
  return toolparse.createMarkupFilter(write);
377
408
  }
378
409
 
379
- module.exports = { TOOL_PROTOCOL, TOOL_PROTOCOL_BODY, TERMINAL_BEGIN, TERMINAL_END, OUTPUT_DIRECTIVE, DEFAULT_MAX_ITERS, buildAgentPrompt, buildFollowup, runAgentLoop, truncateResult, summarizeDetail, toolFenceWriter, scrubOutbound };
410
+ module.exports = { TOOL_PROTOCOL, TOOL_PROTOCOL_BODY, TERMINAL_BEGIN, TERMINAL_END, OUTPUT_DIRECTIVE, isPromiseOnlyReply, DEFAULT_MAX_ITERS, buildAgentPrompt, buildFollowup, runAgentLoop, truncateResult, summarizeDetail, toolFenceWriter, scrubOutbound };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolt-cli/cli",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "Bolt terminal CLI — authorized testing and tool-building from your terminal or VS Code.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",