Skip to content

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

Round the teammate call timeout up to whole milliseconds

Bugfixer 2e53f92ba7055
diff --git a/server/remote-teammates.test.ts b/server/remote-teammates.test.ts
index aaf49cafa6..4dac0e58c9 100644
--- a/server/remote-teammates.test.ts
+++ b/server/remote-teammates.test.ts
@@ -128,6 +128,9 @@ describe("calling a teammate's Bot API", () => {
expect(await sendToRemote(far, { message: "hello", wait: 1 })).toEqual({ ok: true, answer: { reply: "hi", thread: "t1" } });
expect(seen[0]).toMatchObject({ method: "POST", url: "/hooks/api/bots/b1/messages", auth: `Bearer ${KEY}` });
expect(JSON.parse(seen[0]!.body)).toEqual({ message: "hello", wait: 1 });
+ // A fractional wait is a valid Bot API wait; it must not make the call throw before it is sent.
+ expect(await sendToRemote(far, { message: "soon", wait: 1 / 3 })).toEqual({ ok: true, answer: { reply: "hi", thread: "t1" } });
+ expect(JSON.parse(seen.pop()!.body)).toEqual({ message: "soon", wait: 1 / 3 });
next = { status: 202, body: JSON.stringify({ thread: "t1", status: "needs_approval" }) };
expect(await readRemote(far, "t1")).toEqual({ ok: true, answer: { thread: "t1", status: "needs_approval" } });
diff --git a/server/remote-teammates.ts b/server/remote-teammates.ts
index e543d91324..cc033342cf 100644
--- a/server/remote-teammates.ts
+++ b/server/remote-teammates.ts
@@ -181,7 +181,7 @@ export function sendToRemote(teammate: RemoteTeammate, call: { message: string;
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ message: call.message, ...(call.thread !== undefined ? { thread: call.thread } : {}), wait }),
- }, wait * 1000 + CALL_MARGIN_MS, options);
+ }, Math.ceil(wait * 1000) + CALL_MARGIN_MS, options);
}
/** Reads a thread an earlier answer gave: its reply once the other bot is done, or what it is doing now. */