Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(agents): nudge a short reply that ends by announcing the next tool call

ARAYN70111bc91771ccc4
diff --git a/server/drivers/chat-announcement.ts b/server/drivers/chat-announcement.ts
index a855d2a3d5..d8e2854eda 100644
--- a/server/drivers/chat-announcement.ts
+++ b/server/drivers/chat-announcement.ts
@@ -12,6 +12,14 @@ function announcesChineseAction(prose: string): boolean {
return Boolean(match && !/^[了过過完]/u.test(action.slice(match[0].length)));
}
+const ACTION_VERBS = "execute|send|type|press|launch|open|check|inspect|read|fetch|run|create|write|verify|pull|look|search|navigate|load";
+const ANNOUNCING_SENTENCE = new RegExp(`^(?:now,?\\s+)?(?:let me|i['\\u2019]ll|i will|i(?:['\\u2019]m| am) going to)\\s+(?:now\\s+)?(?:${ACTION_VERBS})\\b`, "i");
+
+function endsWithAnnouncingSentence(reply: string): boolean {
+ const sentences = reply.split(/(?<=[.!])\s+/);
+ return sentences.length > 1 && ANNOUNCING_SENTENCE.test(sentences.at(-1)!);
+}
+
export function announcesAction(text: string): boolean {
const reply = text.trim();
if (!reply || reply.length > 4_000 || reply.includes("?")) return false;
@@ -24,7 +32,7 @@ export function announcesAction(text: string): boolean {
const tail = reply.split(/\n\s*\n/).at(-1)!.trim();
return tail.length <= 400 && /^(?:let me|i['\u2019]ll|i will|i(?:['\u2019]m| am) going to)\s+(?:now\s+)?(?:execute|send|type|press|launch|open|check|inspect|read|fetch|run|create|write|verify)\b/i.test(tail);
}
- return /(?:[:\u2014\u2013]|\.\.\.|\u2026)$/.test(reply) ||
+ return /(?:[:\u2014\u2013]|\.\.\.|\u2026)$/.test(reply) || endsWithAnnouncingSentence(reply) ||
/^(?:checking|let me(?! know\b)|i'll|i will|i'm going to|i am going to|opening|pulling|looking|searching|navigating|reading|fetching|loading|now (?:i'll|let me|opening|checking|pulling|reading))\b/i.test(reply) ||
/^i(?:['\u2019]m| am)\b[^.!?\n]*\band (?:i )?will\s+(?:launch|open|check|pull|look|search|navigate|read|fetch|load|run|inspect)\b/i.test(reply);
}
diff --git a/server/drivers/openai-chat-announcement.test.ts b/server/drivers/openai-chat-announcement.test.ts
index df51d7d0f7..5602ca0843 100644
--- a/server/drivers/openai-chat-announcement.test.ts
+++ b/server/drivers/openai-chat-announcement.test.ts
@@ -9,6 +9,8 @@ describe("announcesAction", () => {
"I’m in the VM and will launch XFCE Terminal first.",
"I'll open the browser.",
"Opening the page now:",
+ "Got the structure. Now I'll pull the actual content from each — inbox, tasks, unread messages, and today's calendar.",
+ "Yes, I'm here. Let me pull from all four MCP servers now.",
])("recognizes a short action announcement: %s", text => {
expect(announcesAction(text)).toBe(true);
});
@@ -68,6 +70,8 @@ describe("announcesAction", () => {
"I'm done and will be available tomorrow.",
"I'm waiting and will need your approval first.",
"I'm in the VM. The user will launch XFCE Terminal first.",
+ "The report is done. I'll be available tomorrow.",
+ "That is the full list. Let me know if you want more.",
"The instructions say I will launch XFCE Terminal first.",
"I'm in the VM and will launch XFCE Terminal first. Is that okay?",
"Let me know if you want the full report.",