zames_pro 2.9.2 → 2.9.3
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-loop.js +18 -7
- package/package.json +1 -1
package/dist/agent-loop.js
CHANGED
|
@@ -80,6 +80,8 @@ export async function runAgentLoop({ browser, tools, task, workdir, maxIteration
|
|
|
80
80
|
// chatty model.
|
|
81
81
|
let looksDoneRetries = 0;
|
|
82
82
|
const MAX_LOOKSDONE_RETRIES = 3;
|
|
83
|
+
let plainTextRetries = 0;
|
|
84
|
+
const MAX_PLAINTEXT_RETRIES = 5;
|
|
83
85
|
// Watchdog against the agent emitting a tool call and then going silent.
|
|
84
86
|
// After a tool result the expected next answer is a fresh tool call; if we
|
|
85
87
|
// instead get an EMPTY answer or the EXACT same answer as the previous turn
|
|
@@ -217,16 +219,25 @@ export async function runAgentLoop({ browser, tools, task, workdir, maxIteration
|
|
|
217
219
|
'сообщением оператору.';
|
|
218
220
|
continue;
|
|
219
221
|
}
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
// STRICT: only tool calls and respond reach the operator. Plain text is
|
|
223
|
+
// a protocol violation: re-ask for a tool call instead of printing it.
|
|
224
|
+
if (plainTextRetries < MAX_PLAINTEXT_RETRIES) {
|
|
225
|
+
plainTextRetries++;
|
|
226
|
+
transcript?.log('plaintext_retry', {
|
|
227
|
+
attempt: plainTextRetries,
|
|
228
|
+
response: rawResponse.slice(0, 500),
|
|
229
|
+
});
|
|
230
|
+
message =
|
|
231
|
+
'Only call tools. Do not write plain text. ' +
|
|
232
|
+
'If the task is done - call respond with the final message. ' +
|
|
233
|
+
'Otherwise reply with EXACTLY one JSON tool-call object, no text around it.';
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
224
236
|
if (responseLooksLikeToolCall(rawResponse)) {
|
|
225
237
|
transcript?.log('suspicious_final', { response: rawResponse });
|
|
226
|
-
onWarning(translate(locale)('msg.suspicious_stop'));
|
|
227
238
|
}
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
transcript?.log('plaintext_final', { message: rawResponse });
|
|
240
|
+
onWarning(translate(locale)('msg.suspicious_stop'));
|
|
230
241
|
return rawResponse;
|
|
231
242
|
}
|
|
232
243
|
const calls = Array.isArray(parsed) ? parsed : [parsed];
|