Skip to content

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

Keep a routine quiet when the turn that resumes it after a hand-off says and sends nothing

Xiaolei Shi413bcdf906e6
diff --git a/server/automation-reports.test.ts b/server/automation-reports.test.ts
index 110c74ec9e..79e31bdda5 100644
--- a/server/automation-reports.test.ts
+++ b/server/automation-reports.test.ts
@@ -469,6 +469,7 @@ describe("automation reports", () => {
const pdf = { kind: "file" as const, path: "brief-1.pdf", mime: "application/pdf", name: "Brief.pdf" };
f.store.appendMessage(run.threadId!, { role: "user", kind: "text", text: "Do the Daily brief check." });
f.store.appendMessage(run.threadId!, { role: "bot", kind: "text", text: "", attachments: [pdf] });
+ f.store.appendMessage(run.threadId!, { role: "bot", kind: "activity", tool: { name: "Bash", ok: true }, turnId: `turn-${run.id}` });
f.reports.runSettled(run, `turn-${run.id}`);
expect(f.lines()).toEqual([expect.objectContaining({ text: "", attachments: [pdf] })]);
expect(f.runs.get(run.id)!.report).toMatchObject({ state: "posted" });
@@ -500,6 +501,16 @@ describe("automation reports", () => {
expect(f.lines().at(-1)).not.toHaveProperty("attachments");
});
+ it("keeps a run quiet whose last turn, resumed after a hand-off, said and sent nothing", () => {
+ const f = fixture();
+ const run = f.finished(null);
+ f.store.appendMessage(run.threadId!, { role: "user", kind: "text", text: "Do the Stock check." });
+ f.store.appendMessage(run.threadId!, { role: "bot", kind: "text", text: "Asked Sam to count the stock.", turnId: "turn-before", turnTerminal: true });
+ f.reports.runSettled(run, `turn-${run.id}`);
+ expect(f.added()).toEqual([]);
+ expect(f.runs.get(run.id)!.report).toEqual({ state: "quiet" });
+ });
+
it("keeps a run quiet that said nothing and sent nothing, though its tools returned images", () => {
const f = fixture();
const run = f.finished(null);
diff --git a/server/automation-reports.ts b/server/automation-reports.ts
index daa88f404f..adf1da86fa 100644
--- a/server/automation-reports.ts
+++ b/server/automation-reports.ts
@@ -264,7 +264,8 @@ export function createAutomationReports(deps: AutomationReportDeps) {
if (run.target !== "bot" || run.status !== "completed" || !run.threadId) return;
if (run.deliver === "brief") return deps.brief?.(run, turnId);
const path = store.activePath(run.threadId);
- const said = turnId ? path.findLast((message) => saidLine(message) && message.turnId === turnId) ?? path.slice(path.findLastIndex(asks) + 1).findLast(saidLine)
+ const earlier = (message: Message) => asks(message) || (message.turnId !== undefined && message.turnId !== turnId);
+ const said = turnId ? path.findLast((message) => saidLine(message) && message.turnId === turnId) ?? path.slice(path.findLastIndex(earlier) + 1).findLast(saidLine)
: replyOf(run);
const reply = read(run, said);
const bot = store.bot(run.botId);