Skip to content

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

Merge #5127: Hand-offs: an approval nobody answered parks as a durable Inbox ask

milind-soni55594c7284f9
diff --cc server/runtime-coordinator.test.ts
index 8d27a3a83a,3156963510..15fc89184e
--- a/server/runtime-coordinator.test.ts
+++ b/server/runtime-coordinator.test.ts
@@@ -453,17 -453,47 +453,55 @@@ describe("RuntimeCoordinator: refusals
await deep.host.release(node.id, { ok: true, text: "done" });
const tight = world(undefined, { requests: 1 });
send(tight, chief, "gen-1", undefined, builder, "Build it");
- expect(() => send(tight, chief, "gen-1", undefined, tester, "Test it")).toThrow("Room handoff budget exhausted");
+ expect(() => send(tight, chief, "gen-1", undefined, tester, "Test it")).toThrow(/limit of 1 hand-offs.*nobody can reset it, the person included/s);
+ });
+
+ it("counts one call to several teammates as one request against the budget", () => {
+ const w = world(undefined, { requests: 1 });
+ const { node: first } = send(w, chief, "gen-1", undefined, builder, "Review it", { fanOut: "call-1" });
+ const { node: second } = send(w, chief, "gen-1", undefined, tester, "Review it", { fanOut: "call-1" });
+ expect([first.status, second.status]).toEqual(["queued", "queued"]);
+ expect(() => send(w, chief, "gen-1", undefined, { botId: "scout", threadId: "scout-work" }, "Review it", { fanOut: "call-2" })).toThrow(/limit of 1 hand-offs/);
});
+ it("parks handed-off work a person started on an approval nobody answered, and carries the answer into its next turn", async () => {
+ const asked = { ok: true, text: "Could not run the checks.", approvalAsk: "Approve it?\nDefault: Try again" };
+ const w = world((node) => node.botId === "builder" && node.executions === 1 ? asked : undefined);
+ const { node } = send(w, chief, "gen-1", undefined, builder, "Run the checks");
+ w.coordinator.tick(); await flush();
+ expect(w.coordinator.node(node.id)).toMatchObject({ status: "waiting", question: "Approve it?\nDefault: Try again" });
+ expect(w.host.parks.map(p => p.question)).toEqual(["Approve it?\nDefault: Try again"]);
+ expect(w.host.reports).toEqual([]);
+ expect(w.coordinator.answerNode(node.id, "Try again")).toBe(true);
+ w.coordinator.tick(); await flush();
+ expect(w.host.runs.filter(r => r.node.botId === "builder").at(-1)!.text).toContain("The person answered: \"Try again\"");
+ expect(w.coordinator.node(node.id)?.status).toBe("completed");
+ });
+
+ it("parks a turn that failed for want of the approval too, but not a stalled one", async () => {
+ const failed = { ok: false, text: "One or more tool operations failed or were denied", approvalAsk: "Approve it?" };
+ const w = world((node) => node.botId === "builder" ? failed : node.botId === "tester" ? { ...failed, stalled: true } : undefined);
+ const { node: denied } = send(w, chief, "gen-1", undefined, builder, "Run the checks");
+ const { node: stuck } = send(w, chief, "gen-1", undefined, tester, "Run the checks");
+ w.coordinator.tick(); await flush();
+ expect(w.coordinator.node(denied.id)?.status).toBe("waiting");
+ expect(w.coordinator.node(stuck.id)).toMatchObject({ status: "failed", outcome: "stalled" });
+ });
+
+ it("leaves a bot's own question, and work no person started, on their usual path", async () => {
+ const own = world(() => ({ ok: true, text: "NEEDS INPUT: Which region?", approvalAsk: "Approve it?" }));
+ const { node } = send(own, chief, "gen-1", undefined, builder, "Run the checks");
+ own.coordinator.tick(); await flush();
+ expect(own.coordinator.node(node.id)?.question).toBe("Which region?");
+
+ const routine = world((n) => n.botId === "builder" ? { ok: true, text: "It did not run.", approvalAsk: "Approve it?" } : undefined);
+ routine.coordinator.beginTurn({ id: "gen-1", address: chief, brief: "Nightly", level: "ask",
+ opener: { requester: { kind: "routine_run", runId: "run-1" }, origin: { kind: "routine", source: "routine" } } });
+ const { node: nightly } = routine.coordinator.enqueue(chief, "gen-1", undefined, builder, "Run the checks");
+ routine.coordinator.tick(); await flush();
+ expect(routine.coordinator.node(nightly.id)).toMatchObject({ status: "completed", result: "It did not run." });
+ });
+
it("lets one Chief turn brief a room of 25 visitors and starts every one of them", async () => {
const w = world((node) => node.botId.startsWith("visitor-") ? "hold" : undefined);
const visitors = Array.from({ length: 25 }, (_, i) => ({ botId: `visitor-${i + 1}`, threadId: `visitor-${i + 1}-work` }));
diff --cc src/locales/de.json
index 5ea0a3e86a,b3518037b2..731f35a83e
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@@ -256,9 -257,10 +256,12 @@@
"server.teammates.goal.stopped": "Ziel gestoppt: {detail}",
"server.teammates.goal.failed": "Ziel fehlgeschlagen: {detail}",
"server.teammates.noAnswerInTime": "Niemand hat die Frage von {who} rechtzeitig beantwortet",
+ "server.teammates.stillWaiting": "Wartet noch auf deine Antwort: {question} Diese Arbeit wird in {days} Tagen beendet, wenn niemand antwortet.",
+ "server.teammates.stillWaitingCard": "Diese Arbeit wartet noch auf dich. Sie wird in {days} Tagen beendet, wenn sich nichts ändert.",
"server.teammates.noApprovalInTime": "Niemand hat die Freigabe von {who} rechtzeitig erteilt, dieser Schritt lief nicht",
+ "server.teammates.approvalAsk.one": "{who} brauchte deine Freigabe für {actions}, aber niemand hat rechtzeitig geantwortet, daher lief es nicht. Noch einmal versuchen lassen? Beim Ausführen wird noch einmal um Freigabe gefragt.",
+ "server.teammates.approvalAsk.many": "{who} brauchte deine Freigabe für {actions}, aber niemand hat rechtzeitig geantwortet, daher liefen sie nicht. Noch einmal versuchen lassen? Beim Ausführen wird noch einmal um Freigabe gefragt.",
+ "server.teammates.approvalAsk.retry": "Erneut versuchen",
"server.teammates.turnEndedBeforeAnswer": "Der Zug von {who} endete, bevor jemand seine Frage beantwortet hat",
"server.teammates.approvalClosed": "Die Freigabe von {who} wurde geschlossen, bevor jemand geantwortet hat, dieser Schritt lief nicht",
"server.teammates.questionDismissed": "Die Frage von {who} wurde verworfen",
diff --cc src/locales/en.json
index 95c507589b,ae3528efd1..f32929dc7a
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@@ -388,9 -384,10 +388,12 @@@
"server.teammates.goal.stopped": "Goal stopped: {detail}",
"server.teammates.goal.failed": "Goal failed: {detail}",
"server.teammates.noAnswerInTime": "Nobody answered {who}'s question in time",
+ "server.teammates.stillWaiting": "Still waiting on your answer: {question} This work closes in {days} days if nobody answers.",
+ "server.teammates.stillWaitingCard": "This work is still waiting on you. It closes in {days} days if nothing changes.",
"server.teammates.noApprovalInTime": "Nobody answered {who}'s approval in time — that step did not run",
+ "server.teammates.approvalAsk.one": "{who} needed your approval for {actions}, but nobody answered in time, so it did not run. Let it try again? It will ask you once more when it runs.",
+ "server.teammates.approvalAsk.many": "{who} needed your approval for {actions}, but nobody answered in time, so they did not run. Let it try again? It will ask you once more when it runs.",
+ "server.teammates.approvalAsk.retry": "Try again",
"server.teammates.turnEndedBeforeAnswer": "{who}'s turn ended before anyone answered its question",
"server.teammates.approvalClosed": "{who}'s approval closed before anyone answered — that step did not run",
"server.teammates.questionDismissed": "{who}'s question was dismissed",
diff --cc src/locales/pt-br.json
index 2e9dd66d20,383934692c..15b47f820b
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@@ -371,9 -367,10 +371,12 @@@
"server.teammates.goal.stopped": "Objetivo interrompido: {detail}",
"server.teammates.goal.failed": "O objetivo falhou: {detail}",
"server.teammates.noAnswerInTime": "Ninguém respondeu à pergunta de {who} a tempo",
+ "server.teammates.stillWaiting": "Ainda aguardando sua resposta: {question} Este trabalho será encerrado em {days} dias se ninguém responder.",
+ "server.teammates.stillWaitingCard": "Este trabalho ainda está esperando por você. Ele será encerrado em {days} dias se nada mudar.",
"server.teammates.noApprovalInTime": "Ninguém respondeu ao pedido de aprovação de {who} a tempo — essa etapa não foi executada",
+ "server.teammates.approvalAsk.one": "{who} precisava da sua aprovação para {actions}, mas ninguém respondeu a tempo, então não foi executado. Deixar tentar de novo? Ele vai pedir sua aprovação mais uma vez ao executar.",
+ "server.teammates.approvalAsk.many": "{who} precisava da sua aprovação para {actions}, mas ninguém respondeu a tempo, então não foram executados. Deixar tentar de novo? Ele vai pedir sua aprovação mais uma vez ao executar.",
+ "server.teammates.approvalAsk.retry": "Tentar de novo",
"server.teammates.turnEndedBeforeAnswer": "A sessão de {who} terminou antes de alguém responder à pergunta dele",
"server.teammates.approvalClosed": "O pedido de aprovação de {who} foi encerrado antes de alguém responder — essa etapa não foi executada",
"server.teammates.questionDismissed": "Pergunta de {who} descartada",