@bolt-cli/cli 0.15.3 → 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.
- package/lib/agent.js +37 -5
- package/lib/toolparse.js +9 -3
- package/package.json +1 -1
package/lib/agent.js
CHANGED
|
@@ -43,8 +43,9 @@ you to restate the intent with these tools (usually bash).
|
|
|
43
43
|
|
|
44
44
|
Call format is strict: emit every tool call ONLY as a fenced \`\`\`tool
|
|
45
45
|
block. Never as XML or chat-template syntax (<tool>, <tool_call>,
|
|
46
|
-
<function>, <function_calls>, <invoke>
|
|
47
|
-
|
|
46
|
+
<function>, <function_calls>, <invoke>, <dots_function_call> or any other
|
|
47
|
+
relay-native call tag), never as bare JSON outside a fence, and never
|
|
48
|
+
wrapped in 自知 or similar markup - the operator-visible
|
|
48
49
|
channel reads fenced blocks, and anything else reaches them as raw garbage.
|
|
49
50
|
Never send an empty reply: if you have nothing to add, state in one
|
|
50
51
|
sentence that the task is complete.
|
|
@@ -116,7 +117,7 @@ function summarizeDetail(detail, seenDetails = null) {
|
|
|
116
117
|
// thinking is not streamed; with the task buried mid-prompt it spent the whole
|
|
117
118
|
// reply there and emitted nothing. This says, in the position that demonstrably
|
|
118
119
|
// works, to answer visibly now - removing the wasted ~30s inference entirely.
|
|
119
|
-
const OUTPUT_DIRECTIVE = `The operator's task above is still active - do it in THIS reply. Emit operator-visible text only: either
|
|
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.`;
|
|
120
121
|
|
|
121
122
|
function buildAgentPrompt({ target, objective, evidence, history, memory, session, account }) {
|
|
122
123
|
return `${api.buildPrompt({ target, objective, evidence, history, memory, session, account })}\n\n${TOOL_PROTOCOL}\n\n${OUTPUT_DIRECTIVE}`;
|
|
@@ -124,6 +125,23 @@ function buildAgentPrompt({ target, objective, evidence, history, memory, sessio
|
|
|
124
125
|
|
|
125
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.`;
|
|
126
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
|
+
|
|
127
145
|
function buildFollowup({ iteration, calls, results, errors = [], seenDetails = null, maxIters = DEFAULT_MAX_ITERS, syntaxNote = null }) {
|
|
128
146
|
const lines = [`TOOL_RESULTS for iteration ${iteration} (ground truth from this terminal - do not invent, continue the task):`];
|
|
129
147
|
for (let i = 0; i < calls.length; i += 1) {
|
|
@@ -205,6 +223,7 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
|
|
|
205
223
|
let done = null;
|
|
206
224
|
let iters = 0;
|
|
207
225
|
let nudged = false; // one silent-reply recovery per run
|
|
226
|
+
let promiseNudged = false; // one promise-only recovery per run
|
|
208
227
|
let cancelled = false;
|
|
209
228
|
const toolCalls = [];
|
|
210
229
|
// Byte-identical tool results across the run collapse to a pointer line
|
|
@@ -338,7 +357,19 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
|
|
|
338
357
|
// rejection and restate its intent, or it concludes the channel is broken
|
|
339
358
|
// and refuses work the terminal could have done. maxIters still bounds us.
|
|
340
359
|
if (!calls.length && !errors.length) {
|
|
341
|
-
|
|
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
|
+
}
|
|
342
373
|
// Empty reply — the classic "replied with nothing" failure. Nudge
|
|
343
374
|
// once; a second consecutive silent reply stops the run honestly.
|
|
344
375
|
// Resend the original objective WITH the note: a bare nudge costs two
|
|
@@ -350,6 +381,7 @@ async function runAgentLoop({ cfg, objective, mode, target, evidence, sess, stre
|
|
|
350
381
|
continue;
|
|
351
382
|
}
|
|
352
383
|
nudged = false;
|
|
384
|
+
promiseNudged = false;
|
|
353
385
|
|
|
354
386
|
if (signal && signal.aborted) {
|
|
355
387
|
cancelled = true;
|
|
@@ -375,4 +407,4 @@ function toolFenceWriter(write) {
|
|
|
375
407
|
return toolparse.createMarkupFilter(write);
|
|
376
408
|
}
|
|
377
409
|
|
|
378
|
-
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/lib/toolparse.js
CHANGED
|
@@ -48,8 +48,14 @@ const RESERVED_ATTR_KEYS = new Set(["id", "type", "index", "session"]);
|
|
|
48
48
|
const THINK_TAGS = ["thinking", "thought", "scratchpad", "reasoning", "think"];
|
|
49
49
|
|
|
50
50
|
// XML-family tags that carry one call each. "function_calls" is a wrapper
|
|
51
|
-
// whose children are parsed recursively.
|
|
52
|
-
|
|
51
|
+
// whose children are parsed recursively. Some relays emit their native call
|
|
52
|
+
// tag instead of the instructed fence (e.g. <dots_function_call>); those are
|
|
53
|
+
// part of the same family — parse them as calls and keep them off the
|
|
54
|
+
// operator's screen, including when the call body is empty.
|
|
55
|
+
const XML_TAGS = [
|
|
56
|
+
"dots_function_calls", "dots_function_call", "dots_tool_call", "dots_tool_use", "dots_invoke",
|
|
57
|
+
"function_calls", "tool_call", "tool_use", "function_call", "function", "tool", "invoke",
|
|
58
|
+
];
|
|
53
59
|
|
|
54
60
|
const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : null);
|
|
55
61
|
const firstOf = (obj, keys) => {
|
|
@@ -302,7 +308,7 @@ function xmlToCall(attrs, body) {
|
|
|
302
308
|
}
|
|
303
309
|
// No name but a nested call block (or nothing at all): recurse — the
|
|
304
310
|
// parameters collected here belong to the inner call, parsed whole.
|
|
305
|
-
const hasNestedCall = /<(?:antml:)?(?:function_calls|tool_call|tool_use|function_call|function|tool|invoke)\b/.test(trimmed);
|
|
311
|
+
const hasNestedCall = /<(?:antml:)?(?:dots_function_calls|dots_function_call|dots_tool_call|dots_tool_use|dots_invoke|function_calls|tool_call|tool_use|function_call|function|tool|invoke)\b/.test(trimmed);
|
|
306
312
|
if (!name && (hasNestedCall || !found)) return { recurse: true };
|
|
307
313
|
if (!name) return { ok: false, error: "no tool name in block" };
|
|
308
314
|
// Name without parameters while a nested call block sits inside: the real
|
package/package.json
CHANGED