Skip to content

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

One notice per hand-off: results coming back to the bot that asked don't notify

milind-sonid48dfc959e91
diff --git a/server/direct-coordination.e2e.test.ts b/server/direct-coordination.e2e.test.ts
index 9e7b17975b..eb5d7a513c 100644
--- a/server/direct-coordination.e2e.test.ts
+++ b/server/direct-coordination.e2e.test.ts
@@ -214,25 +214,17 @@ it("coordinates a lead and its specialist from ordinary chat, returns to Clive,
expect(turn.system).toContain("only an actual coordinate_bots result proves that teammate participated");
}), 45_000);
-it("announces a settled delegation and its resume in the parent thread", () => fixture(async f => {
+it("shows a settled delegation and its resume in the parent thread, and notifies once, with the answer", () => fixture(async f => {
const stream = await openSse(`${f.session.info.url}/api/events`);
try {
await f.start();
expect((await f.wait()).status).toBe("settled");
- // f.wait() resolves through the control CLI poll, independent of the SSE reader: until() proves both settles are stored first.
- await stream.until(frame => frame.kind === "notify"
- && frame.notification?.kind === "delegation-settled"
- && frame.notification.botId === f.chief.id);
- const settles = () => stream.frames.filter(frame => frame.kind === "notify" && frame.notification?.kind === "delegation-settled");
- const chiefFrames = settles().filter(frame => frame.notification.botId === f.chief.id);
- expect(chiefFrames).toHaveLength(1);
- expect(chiefFrames[0].notification).toMatchObject({
- threadId: f.chief.activeTaskId,
- title: "Clive resumed with results",
- body: "Results in from Engineering lead",
- });
- expect(settles().filter(frame => frame.notification.botId === f.lead.id), "bot-to-bot: nothing there needs the person").toEqual([]);
- expect(settles().some(frame => frame.notification.botId === f.specialist.id)).toBe(false);
+ // f.wait() resolves through the control CLI poll, independent of the SSE reader: until() proves the "done" is stored first.
+ await stream.until(frame => frame.kind === "notify" && frame.notification?.kind === "done" && frame.notification.botId === f.chief.id);
+ // The results coming back to the bot that asked notify nobody: its answer, the one "done", is what the person needs.
+ const notes = stream.frames.filter(frame => frame.kind === "notify").map(frame => frame.notification);
+ expect(notes.map(note => [note.kind, note.botId]), JSON.stringify(notes)).toEqual([["done", f.chief.id]]);
+ expect(notes[0]).toMatchObject({ threadId: f.chief.activeTaskId, title: "Clive finished" });
const { bots } = await f.api("/api/bots?messages=0");
const work = bots.find((bot: any) => bot.id === f.lead.id).tasks.find((task: any) => task.openedBy?.botId === f.chief.id);
expect(work.unread, "no unread mark, on the desktop or the phone's To review, for a teammate's own step").toBeFalsy();
diff --git a/server/index.ts b/server/index.ts
index 7b429c62f6..048358a615 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -4075,7 +4075,7 @@ const handoffTicks = createHandoffTicks(), coordinator: Coordinator = createCoor
});
const quiet = turnAnswers(node.threadId, { cardContinuation: true, coordination: node }).quiet;
const routineRoot = !node.parentId && activeRoutineRunForThread(node.threadId) !== null;
- if (node.restart !== "rerun" && !quiet && !routineRoot && !node.parentId && asking.length === 0) {
+ if (node.restart !== "rerun" && !quiet && !routineRoot && !node.parentId && asking.length === 0 && !doneNotice.owes(node.threadId)) {
notify(buildNotification("delegation-settled", bot, node.threadId, serverLine(language, "server.notify.resultsFrom", { who }), { avatarUrl: bot.avatarUrl }));
}
if (!node.parentId && !quiet) reviewAnswerThreads.add(node.threadId);
diff --git a/server/long-running-chief.e2e.test.ts b/server/long-running-chief.e2e.test.ts
index 29ac0b7714..5b9f8b1716 100644
--- a/server/long-running-chief.e2e.test.ts
+++ b/server/long-running-chief.e2e.test.ts
@@ -234,11 +234,10 @@ it("carries a consult-and-implement job over several teammate turns, through a s
expect(chiefRows.filter((name: string) => name.startsWith("Resumed with"))).toEqual(["Resumed with Mira, Eli results, reviewing", "Resumed with Mira, Eli results, reviewing"]);
for (const node of f.tree(job).filter((candidate: any) => candidate.parentId)) expect(await f.cards(node.threadId)).toEqual([]);
expect(f.notifications.filter((notification: any) => notification.kind === "approval")).toEqual([]);
- // No "done" while teammates still work (A0, and A1 handing off again): one at the job's end, with its final answer.
+ // No "done" while teammates still work (A0, and A1 handing off again), and nothing when their results come back: one
+ // "done" at the job's end, with its final answer.
await expect.poll(() => f.notifications.some((notification: any) => notification.kind === "done"), { timeout: 10_000 }).toBe(true);
expect(f.notifications.map((notification: any) => [notification.kind, notification.body])).toEqual([
- ["delegation-settled", "Results in from Mira, Eli"],
- ["delegation-settled", "Results in from Mira, Eli"],
["done", expect.stringContaining("A-FINAL")],
]);
@@ -307,9 +306,9 @@ it("tells the Chief what happened to each approval: allowed, denied, or never an
.toEqual([["git log --oneline -5 -- src/export", "allow", false, "loopback"], ["git push origin export", "deny", false, "loopback"], ["pnpm test", "deny", true, undefined]]);
await expect.poll(() => f.notifications.some((notification: any) => notification.kind === "done"), { timeout: 10_000 }).toBe(true);
expect(f.notifications.map((notification: any) => [notification.kind, notification.body])).toEqual([
- ["approval", "git log --oneline -5 -- src/export"], ["delegation-settled", "Results in from Mira"],
- ["approval", "git push origin export"], ["delegation-settled", "Results in from Mira"],
- ["approval", "pnpm test"], ["delegation-settled", "Results in from Mira"],
+ ["approval", "git log --oneline -5 -- src/export"],
+ ["approval", "git push origin export"],
+ ["approval", "pnpm test"],
["done", expect.stringContaining("APPROVALS-FINAL")],
]);
}), hostTimeout(120_000));
@@ -423,7 +422,7 @@ it("tells the Chief a teammate's turn stalled, in the watchdog's words", () => c
expect((await f.tasks(f.clive.id)).map((task: any) => task.title)).not.toContain("Problems to look at");
await expect.poll(() => f.notifications.some((notification: any) => notification.kind === "done"), { timeout: 10_000 }).toBe(true);
expect(f.notifications.map((notification: any) => [notification.kind, notification.body])).toEqual([
- ["delegation-settled", "Results in from Mira"], ["done", expect.stringContaining("STALL-FINAL")]]);
+ ["done", expect.stringContaining("STALL-FINAL")]]);
}), hostTimeout(90_000));
it("lets a card hold only its own job: other jobs run beside it, or say once whose card they wait behind", () => chiefJob(async (f) => {
diff --git a/server/notification-routing.e2e.test.ts b/server/notification-routing.e2e.test.ts
index 66c55fe533..56edeef139 100644
--- a/server/notification-routing.e2e.test.ts
+++ b/server/notification-routing.e2e.test.ts
@@ -391,10 +391,10 @@ describe("bot-to-bot coordination is recorded, not announced", () => {
const notified = stream.frames.filter((candidate) => candidate.kind === "notify").map((candidate) => candidate.notification);
expect(notified.filter((notification) => notification?.botId === peer.id), JSON.stringify(notified)).toEqual([]);
expect(notified.every((notification) => notification?.botId === asker.id && notification?.threadId === asker.threadId), JSON.stringify(notified)).toBe(true);
- // The hand-off turn is not the end of the job: no "done" then. Results in, then one "done" with the reviewed answer.
- expect(notified.map((notification) => notification?.kind), JSON.stringify(notified)).toEqual(["delegation-settled", "done"]);
- expect(notified[0]).toMatchObject({ title: "Pen resumed with results", body: "Results in from Ink" });
- expect(notified[1]).toMatchObject({ title: "Pen finished", body: expect.stringContaining("saw the result") });
+ // The hand-off turn is not the end of the job: no "done" then, and none when the results come back to the bot that
+ // asked. One "done", with the reviewed answer.
+ expect(notified.map((notification) => notification?.kind), JSON.stringify(notified)).toEqual(["done"]);
+ expect(notified[0]).toMatchObject({ title: "Pen finished", body: expect.stringContaining("saw the result") });
} finally {
stream.close();
await cleanup([], [asker.id, peer.id]);