Skip to content

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

fix(agents): ignore code, approval waits and emphasis in last-sentence check

ARAYN701117bc3567b49a
diff --git a/server/drivers/chat-announcement.ts b/server/drivers/chat-announcement.ts
index d8e2854eda..36ecb40de2 100644
--- a/server/drivers/chat-announcement.ts
+++ b/server/drivers/chat-announcement.ts
@@ -15,9 +15,13 @@ function announcesChineseAction(prose: string): boolean {
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");
+const WAITS_FOR_USER = /\b(?:after|once|when|if|until|before)\s+you\b|\bwait(?:ing)?\s+for\s+you\b/i;
+
function endsWithAnnouncingSentence(reply: string): boolean {
- const sentences = reply.split(/(?<=[.!])\s+/);
- return sentences.length > 1 && ANNOUNCING_SENTENCE.test(sentences.at(-1)!);
+ const sentences = blankCode(reply).trim().split(/(?<=[.!])\s+/);
+ if (sentences.length < 2) return false;
+ const last = sentences.at(-1)!.replace(/^[*_]+/, "");
+ return ANNOUNCING_SENTENCE.test(last) && !WAITS_FOR_USER.test(last);
}
export function announcesAction(text: string): boolean {
diff --git a/server/drivers/openai-chat-announcement.test.ts b/server/drivers/openai-chat-announcement.test.ts
index 5602ca0843..a92a493164 100644
--- a/server/drivers/openai-chat-announcement.test.ts
+++ b/server/drivers/openai-chat-announcement.test.ts
@@ -11,6 +11,7 @@ describe("announcesAction", () => {
"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.",
+ "Got it.\n\n**I'll pull the data now.**",
])("recognizes a short action announcement: %s", text => {
expect(announcesAction(text)).toBe(true);
});
@@ -71,6 +72,8 @@ describe("announcesAction", () => {
"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.",
+ "The report is ready. I'll send it after you approve.",
+ "Example:\n```text\nDone. I'll check the logs.\n```",
"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?",