+18
@@ -19,6 +19,8 @@ function fromPayload(payload, origin) {
|
||||
maxTurns: num(payload.maxTurns, voice ? 6 : 24),
|
||||
maxShellCalls: unlimitedShell ? 0 : num(payload.maxShellCalls, voice ? 1 : 0),
|
||||
maxToolRounds: num(payload.maxToolRounds, voice ? 4 : 0),
|
||||
completeTimeoutMs: voice ? 45000 : 0,
|
||||
completeIdleMs: voice ? 10000 : 0,
|
||||
shellCalls: 0,
|
||||
toolRounds: 0,
|
||||
answerOnly: false,
|
||||
@@ -57,6 +59,20 @@ function answerNowMessage() {
|
||||
return 'You have tool results. Reply to the user in one to three sentences. Do not call more tools.';
|
||||
}
|
||||
|
||||
const UNFINISHED_TOOL =
|
||||
/\b(let me|i(?:'m| am) going to|i(?:'ll| will)|i should|need to)\b[\s\S]{0,160}\b(fetch|search|look(?:ing)? up|check|open|read|run|call|use)\b/i;
|
||||
|
||||
function shouldNudgeToolCall(text, budget) {
|
||||
if (!budget || !budget.voice || budget.answerOnly) return false;
|
||||
const blob = String(text || '');
|
||||
if (UNFINISHED_TOOL.test(blob)) return true;
|
||||
return /\b(search(?:ing)? again|fetch (?:a |the |that )|look(?:ing)? that up)\b/i.test(blob);
|
||||
}
|
||||
|
||||
function continueToolMessage() {
|
||||
return 'Thinking is not an answer. Call the tool now with a concrete query or URL, then speak the result. Do not describe the next step.';
|
||||
}
|
||||
|
||||
function lastToolText(history, maxChars) {
|
||||
const list = Array.isArray(history) ? history : [];
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
@@ -78,5 +94,7 @@ module.exports = {
|
||||
forceAnswer,
|
||||
skipShellMessage,
|
||||
answerNowMessage,
|
||||
shouldNudgeToolCall,
|
||||
continueToolMessage,
|
||||
lastToolText,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user