Skip to content

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

fix(rooms): a bot answers a direct @mention from another bot, up to 3 hops

AdityaUmale4fdfbe85b2b1
diff --git a/server/index.ts b/server/index.ts
index c6d8a82a4a..a245e5fba5 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -9581,7 +9581,7 @@ handoffTicks.start({ pace: () => enginesRead || parkedNodesToReconcile.size > 0
function reconcileParkedRoots(): void {
for (const node of coordinator.active()) if (!reconcileParkedNode(node) && node.status === "waiting" && node.cards?.length && !anyCardLive(store, node.threadId, node.cards)) coordinator.releaseParked(node.id, WAIT_CARD_CLOSED_REASON);
}
-const MAX_GROUP_HOPS = 1;
+const MAX_GROUP_HOPS = 3;
type GroupMemberTurnOutcome = GoalStepOutcome;
type GroupTurnOrchestration = {
@@ -10551,9 +10551,11 @@ async function runClaimedGroupMemberTurn(
},
});
}
+ // A bot that spoke earlier answers this direct mention again; one that already answered since this reply does not.
+ const spokeBeforeReply = new Set(spoken);
for (const next of roomResponders(replyText, members, { kind: "mentions" })) {
if (isCancelled?.()) return false;
- if (spoken.has(next.id)) continue;
+ if (spoken.has(next.id) && !spokeBeforeReply.has(next.id)) continue;
if (operation) {
const verdict = await waitForChatRoomMember(operation, threadId, next);
if (verdict === "stop") return false;
diff --git a/server/room-chat-wait.e2e.test.ts b/server/room-chat-wait.e2e.test.ts
index f4f98c57a1..21cfdade9a 100644
--- a/server/room-chat-wait.e2e.test.ts
+++ b/server/room-chat-wait.e2e.test.ts
@@ -223,7 +223,7 @@ describe("chat rooms wait for a member busy elsewhere", { timeout: 45_000 }, ()
try {
await holdBusy(bee.id, "Bee, finish this first");
- expect((await api("POST", `/api/groups/${room.id}/messages`, { text: "@Ace please bring Bee in" })).status).toBe(202);
+ expect((await api("POST", `/api/groups/${room.id}/messages`, { text: "Ace, please bring Bee in" })).status).toBe(202);
await releaseAfterRoomWait(room.id, bee.id, "Bee");
await expect.poll(async () => {
diff --git a/server/room-roots.e2e.test.ts b/server/room-roots.e2e.test.ts
index 018d34047b..6e91f8b38d 100644
--- a/server/room-roots.e2e.test.ts
+++ b/server/room-roots.e2e.test.ts
@@ -566,6 +566,25 @@ it("R8 runs a chained @mention as a root of its own, with the hop recorded", ()
expect((await f.roomView(room.id))).toMatchObject({ working: false, busyBotId: null });
}), hostTimeout(60_000));
+it("R8 answers a direct bot @mention again for a bot that already spoke, up to three hops", () => scenario(async (f) => {
+ const mira = await f.bot("Mira", "Engineering");
+ const room = await f.room("Engineering", [f.clive.id, mira.id], { kind: "member", botId: f.clive.id });
+ f.script(f.clive.id,
+ { key: "C0", match: ["R8B-JOB"], reply: "R8B-C0: @Mira please check the total." },
+ { key: "C2", match: ["R8B-M1"], reply: "R8B-C2: @Mira and the tax line?" },
+ { key: "C-EXTRA", repeat: true, match: ["R8B"], reply: "R8B-EXTRA" });
+ f.script(mira.id,
+ { key: "M1", match: ["R8B-C0"], reply: "R8B-M1: 42. @Clive anything else?" },
+ { key: "M3", match: ["R8B-C2"], reply: "R8B-M3: tax is 4. @Clive done." },
+ { key: "M-EXTRA", repeat: true, match: ["R8B"], reply: "R8B-EXTRA" });
+ await f.post(room, "R8B-JOB: what is the week's total?");
+ await f.final(room.threadId, "R8B-M3");
+ await expect.poll(() => f.roomRoots(room.threadId).map((row: any) => row.status), { timeout: 15_000 }).toEqual(["completed", "completed", "completed", "completed"]);
+ expect(f.roomRoots(room.threadId).map((row: any) => row.brief.split(":")[0])).toEqual(["R8B-JOB", "Mentioned by Clive (hop 1)", "Mentioned by Mira (hop 2)", "Mentioned by Clive (hop 3)"]);
+ expect(f.turns().map((record: any) => record.planKey)).toEqual(["C0", "M1", "C2", "M3"]);
+ expect(nothingLive(f)).toEqual([]);
+}), hostTimeout(90_000));
+
const goalDone = (detail: string) => `<openmaus-goal>${JSON.stringify({ status: "completed", detail })}</openmaus-goal>`;
const sendGoal = (f: any, bot: { id: string; threadId: string }, text: string) =>
f.api("POST", `/api/bots/${bot.id}/messages`, { text, mode: "goal", threadId: bot.threadId });