Skip to content

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

A stopped hand-off stays stopped for a routine run too

luishron123750af456193e
diff --git a/server/runtime-coordinator.test.ts b/server/runtime-coordinator.test.ts
index e08386e101..b5914980a3 100644
--- a/server/runtime-coordinator.test.ts
+++ b/server/runtime-coordinator.test.ts
@@ -1049,6 +1049,32 @@ describe("RuntimeCoordinator: one stopped hand-off, and the rest of its teammate
now += 1;
expect(send(w, chief, "gen-1", undefined, builder, "Build it again", { rework: true }).node).toMatchObject({ botId: "builder" });
});
+
+ const routineRun = (w: World, generation: string, runId: string) => w.coordinator.beginTurn({ id: generation, address: chief, brief: "Nightly export",
+ level: "ask", opener: { requester: { kind: "routine_run", runId, botId: "chief", threadId: "chief-chat" }, origin: { kind: "routine", source: "routine", ref: "nightly" } } });
+
+ it("holds for a routine run, which has no person's words: that run does not hand the teammate the work again", () => {
+ const w = world(holdAll);
+ routineRun(w, "gen-run", "run-1");
+ const { node } = w.coordinator.enqueue(chief, "gen-run", undefined, builder, "Export", {});
+ w.coordinator.tick();
+ expect(w.coordinator.stopHandoff(node.id)).toBe("stopped");
+ expect(() => w.coordinator.enqueue(chief, "gen-run", undefined, builder, "Export", { rework: true }))
+ .toThrow("The person stopped this teammate's work on this request.");
+ expect(() => w.coordinator.enqueue(chief, "gen-run", undefined, { botId: "builder", threadId: "builder-other" }, "Export it another way", {}))
+ .toThrow("The person stopped this teammate's work on this request.");
+ });
+
+ it("lets the routine's next run hand the same teammate work", () => {
+ const w = world(holdAll);
+ routineRun(w, "gen-run", "run-1");
+ const { node } = w.coordinator.enqueue(chief, "gen-run", undefined, builder, "Export", {});
+ w.coordinator.tick();
+ w.coordinator.stopHandoff(node.id);
+ w.coordinator.endTurn("gen-run", { ok: true, text: "" });
+ routineRun(w, "gen-run-2", "run-2");
+ expect(w.coordinator.enqueue(chief, "gen-run-2", undefined, builder, "Export", {}).node).toMatchObject({ botId: "builder", status: "queued" });
+ });
});
describe("RuntimeCoordinator: a stop the person made is remembered", () => {
diff --git a/server/runtime-coordinator.ts b/server/runtime-coordinator.ts
index 54c0351631..80519f4a8c 100644
--- a/server/runtime-coordinator.ts
+++ b/server/runtime-coordinator.ts
@@ -495,20 +495,23 @@ export class RuntimeCoordinator implements Coordinator {
/** The person's stop, remembered (scoped to that request): the bots whose work on it the stop ended don't take the same
* request from another bot again, unless the person asked again after the stop. In memory only, for a day. A `scoped`
- * stop holds for that one request's tree only, never for another request in the same words. */
+ * stop holds for that one request's tree only, never for another request in the same words, and needs no person's words:
+ * a routine run's tree is held the same way. */
private rememberStop(root: Assignment, work: readonly Assignment[], scoped = false): void {
const request = requestKey(root);
const bots = new Set(work.filter(a => this.store.get(a.id)?.status === "cancelled").map(a => a.assignee.botId));
const at = this.now();
while (this.stops.length && at - this.stops[0]!.at > STOP_MEMORY_MS) this.stops.shift();
- if (request && bots.size) this.stops.push({ at, request, bots, ...(scoped ? { rootId: root.id } : {}) });
+ if (!bots.size) return;
+ if (scoped) this.stops.push({ at, request, bots, rootId: root.id });
+ else if (request) this.stops.push({ at, request, bots });
}
/** Work for `root`'s request was stopped for `botId`, and this request is not one the person made after that stop. */
private stoppedFor(root: Assignment, botId: string): boolean {
const request = requestKey(root);
- return request !== "" && this.stops.some(stop => stop.bots.has(botId) && this.now() - stop.at <= STOP_MEMORY_MS
- && (stop.rootId !== undefined ? stop.rootId === root.id : stop.request === request && root.createdAt <= stop.at));
+ return this.stops.some(stop => stop.bots.has(botId) && this.now() - stop.at <= STOP_MEMORY_MS
+ && (stop.rootId !== undefined ? stop.rootId === root.id : request !== "" && stop.request === request && root.createdAt <= stop.at));
}
activeDirect(threadId: string): boolean {