Skip to content

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

fix(prompt): keep which computers are online out of the cached prompt half

AdityaUmale28e03b2acd10
diff --git a/server/index.ts b/server/index.ts
index e8b24b6a66..3bf0eb1671 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -401,7 +401,7 @@ import {
botPersona,
buildSystemPrompt,
userProfileSystemPrompt,
- cloudHomePrompt, syncedFolders,
+ cloudHomePrompt, cloudComputersNowPart, syncedFolders,
computerPrompt,
composioSystemPrompt,
customMcpPrompt,
@@ -2925,7 +2925,7 @@ function previewSystemPrompt(bot: BotRecord) {
computer: previewPlan.computer && previewPlan.computer !== "off" && computerPromptKind ? previewPlan.computer : null,
browser: previewPlan.computer === undefined ? false : previewPlan.browser,
}, { note: previewPlan.note, cloudHome: Boolean(CLOUD_HOME), ownComputer: CLOUD_HOME && agentsMounted && lendingEnabled() ? sharedComputers.known(CLOUD_HOME_LENDER) : undefined }) }, { id: "computer-selection", label: "Choosing a computer", text: agentsMounted && bot.computer !== "off" && !inheritedTeamComputer(bot) ? computerSelectionPrompt({ cloudHome: Boolean(CLOUD_HOME) }) : "" },
- { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(agentsMounted && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER), CLOUD_PERSONAL) + firstHourHooks.prompt(bot.id, bot.threadId) : "" }, phoneLinkPart(),
+ { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(agentsMounted && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER), CLOUD_PERSONAL) + firstHourHooks.prompt(bot.id, bot.threadId) : "" }, cloudComputersNowPart(agentsMounted && lendingEnabled(), CLOUD_HOME ? sharedComputers.known(CLOUD_HOME_LENDER) : []), phoneLinkPart(),
{ id: "composio", label: "Connected apps", text: caps?.composioMcp && bot.composio !== false && composio.configured(cfg) ? composioSystemPrompt(bot.connectorTools) + describeConnectorScopes(bot.connectorScopes) : "" },
{ id: "email", label: "Email", text: caps?.emailMcp === true ? emailHost.prompt(bot) : "" }, { id: "meetings", label: "Meetings", text: meetingsUnavailablePrompt({ agentsTools: agentsMounted, cloudComputer: boat.boatConfigured(cfg) }) }, toolsOffPart(bot),
...phones.previewParts(bot, caps?.deviceMcp === true),
@@ -8235,7 +8235,7 @@ async function beginTurn(
{ id: "computer", label: "Computer", text: computerPrompt(computerPromptKind) + noTerminal.turn(threadId, bot, { ownShell: worksInWorkspace, computerMounted: computerKind !== null, sharedTools: Boolean(integrations.agents && lendingEnabled()), canSelect: Boolean(computerSelectionTurns.get(threadId) && !computerSelectionTurns.get(threadId)?.handoff) }, { model: cloudEngine(instance, bot.modelSelection.model).name, routine: opts?.automationSource !== undefined }) },
{ id: "team-computer", label: "Team computer", text: teamComputerPrompt(teamComputer) },
{ id: "plan", label: "Surface", text: surfacePrompt({ computer: mountedComputer, browser: Boolean(integrations.browser) }, { pinned: plan.pinned, note: plan.note + vpsUnavailableNote + vmUpdateNote + (computerSkipped && plan.computer !== "off" ? computerSkippedNote(redactSecretsInText(computerSkipped)) : "") + (computerSelectionTurns.get(threadId)?.handoff && !integrations.browser ? HANDOFF_BROWSER_NOTE : ""), canSelect: computerSelectionTurns.has(threadId) && !computerSelectionTurns.get(threadId)?.handoff, selectionRules: !selectionRulesStable, cloudHome: Boolean(CLOUD_HOME), botOpened: plan.botOpened, ownComputer: CLOUD_HOME && integrations.agents && lendingEnabled() ? sharedComputers.known(CLOUD_HOME_LENDER, typingSession) : undefined, lentToServer: lentToServer(integrations.agents, { botId: bot.id, threadId, generation: dispatchClaimId }), worksOnAuto: bot.computer === undefined, thisComputer: !CLOUD_HOME && bot.computer !== "off" && !inheritedTeamComputer(bot) && shouldMountLocalComputer({ requested: "local", providerSupportsLocal: instance.adapter.capabilities.localComputerMcp === true }) ? { bot: bot.name, botId: bot.id, platform: process.platform, desktopApp: DESKTOP_MANAGED || desktopComputer.granted() } : undefined }) }, { id: "computer-selection", label: "Choosing a computer", text: selectionRulesStable ? computerSelectionPrompt({ cloudHome: Boolean(CLOUD_HOME) }) : "" },
- { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(Boolean(integrations.agents) && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER, typingSession), CLOUD_PERSONAL) + firstHourHooks.prompt(bot.id, threadId) : "" }, phoneLinkPart(),
+ { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(Boolean(integrations.agents) && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER, typingSession), CLOUD_PERSONAL) + firstHourHooks.prompt(bot.id, threadId) : "" }, cloudComputersNowPart(Boolean(integrations.agents) && lendingEnabled(), CLOUD_HOME ? sharedComputers.known(CLOUD_HOME_LENDER, typingSession) : []), phoneLinkPart(),
{ id: "composio", label: "Connected apps", text: integrations.composio ? composioSystemPrompt(liveBot?.connectorTools ?? bot.connectorTools) + describeConnectorScopes((liveBot ?? bot).connectorScopes) : "" },
{ id: "mcp", label: "MCP servers", text: customMcpPrompt(Object.keys(integrations.custom ?? {}), mcpServersHost.off(bot)) }, { id: "to-connect", label: "Connections to make", text: cloudConnections.prompt(liveBot ?? bot, lentMcp.lines(liveBot ?? bot, { botId: bot.id, threadId, generation: dispatchClaimId }), teamConnections.mcpServerApps(liveBot ?? bot, { servers: cfg.mcpServers ?? {}, bridged: Boolean(integrations.composio), blocked: (slug) => managedPolicy.appsConnectRefusal([slug]) })) + teamConnections.prompt(threadId, dispatchClaimId, integrations) },
{ id: "browser", label: "Browser", text: integrations.browser ? browserPromptFor(bot, Boolean(integrations.agents)) : "" },
@@ -10009,7 +10009,7 @@ async function runClaimedGroupMemberTurn(
{ id: "computer", label: "Computer", text: computerPrompt(roomComputerPromptKind) },
{ id: "team-computer", label: "Team computer", text: teamComputerPrompt(roomTeamComputer) },
{ id: "plan", label: "Surface", text: surfacePrompt({ computer: roomTeamComputer ? "cloud" : roomVmTarget ? "vm" : surfaceOfComputerKind(roomComputerKind), browser: Boolean(integrations.browser) }, { note: roomPlan.note, cloudHome: Boolean(CLOUD_HOME), ownComputer: CLOUD_HOME && integrations.agents && lendingEnabled() ? sharedComputers.known(CLOUD_HOME_LENDER) : undefined }) },
- { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(Boolean(integrations.agents) && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER), CLOUD_PERSONAL) : "" }, phoneLinkPart(), { id: "composio", label: "Connected apps", text: integrations.composio ? composioSystemPrompt(readyBot.connectorTools) + describeConnectorScopes(readyBot.connectorScopes) : "" },
+ { id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(Boolean(integrations.agents) && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER), CLOUD_PERSONAL) : "" }, cloudComputersNowPart(Boolean(integrations.agents) && lendingEnabled(), CLOUD_HOME ? sharedComputers.known(CLOUD_HOME_LENDER) : []), phoneLinkPart(), { id: "composio", label: "Connected apps", text: integrations.composio ? composioSystemPrompt(readyBot.connectorTools) + describeConnectorScopes(readyBot.connectorScopes) : "" },
{ id: "browser", label: "Browser", text: integrations.browser ? browserPromptFor(bot, Boolean(integrations.agents)) : "" },
{ id: "data", label: "Data", text: integrations.data ? dataPrompt(readyBot.id, threadId, `${roomContext}\n${latestUser?.text ?? ""}`) : "" },
{ id: "email", label: "Email", text: instance.adapter.capabilities.emailMcp === true ? emailHost.prompt(readyBot) : "" }, toolsOffPart(readyBot),
diff --git a/server/system-prompt.test.ts b/server/system-prompt.test.ts
index e0481969dc..83f027789a 100644
--- a/server/system-prompt.test.ts
+++ b/server/system-prompt.test.ts
@@ -12,6 +12,7 @@ import {
CLOUD_PUSH_CODE_WORK,
CLOUD_REUSE_INSTALLS,
cloudHomePrompt,
+ cloudComputersNowPart,
userProfileSystemPrompt,
computerPrompt,
resolveComputerPromptKind,
@@ -447,17 +448,31 @@ describe("cloudHomePrompt", () => {
});
it("names every computer's status with the tools on, and says nothing about them without", () => {
const known = [{ name: "ASH-MBP", platform: "darwin" as const, online: true, lent: true, lastSeenAt: 1 }, { name: "OFFICE-PC", platform: "win32" as const, online: false, lent: true, lastSeenAt: Date.UTC(2026, 9, 1, 8, 0) }];
- expect(cloudHomePrompt(true, [], known)).toContain("Their computers right now: ASH-MBP (Mac): online; OFFICE-PC (PC): offline since 2026-10-01 08:00 UTC.");
- expect(cloudHomePrompt(false, [], known)).not.toContain("Their computers right now");
+ expect(cloudComputersNowPart(true, known).text).toBe(" Their computers right now: ASH-MBP (Mac): online; OFFICE-PC (PC): offline since 2026-10-01 08:00 UTC.");
+ expect(cloudComputersNowPart(false, known).text).toBe("");
+ });
+
+ it("keeps which computers are online out of the cached half, so a computer going to sleep never rewrites the conversation's cache", () => {
+ const online = [{ name: "ASH-MBP", platform: "darwin" as const, online: true, lent: true, lastSeenAt: 1, typing: true }];
+ const asleep = [{ ...online[0]!, online: false, typing: false, lastSeenAt: Date.UTC(2026, 10, 29, 9, 0) }];
+ const turn = (known: typeof online) => buildSystemPrompt("You are Kiwi.", "", [
+ { id: "cloud-home", label: "My Cloud", text: cloudHomePrompt(true, [], known, true) }, cloudComputersNowPart(true, known),
+ ]);
+ const before = turn(online), after = turn(asleep);
+ expect(after.stable).toBe(before.stable);
+ expect(before.stable).not.toContain("Their computers right now");
+ expect(before.volatile).toContain("ASH-MBP (Mac): online, they are typing on it now");
+ expect(after.volatile).toContain("ASH-MBP (Mac): offline since 2026-11-29 09:00 UTC");
+ expect(after.text).toContain("If they ask for something on their Mac (ASH-MBP)");
});
it("names the computer the person types on, so their \"my computer\" means that one", () => {
const both = [{ name: "WIN-1", platform: "win32" as const, online: true, typing: true }, { name: "UBUNTU-1", platform: "linux" as const, online: true }];
- const text = cloudHomePrompt(true, [], both);
+ const text = cloudComputersNowPart(true, both).text;
expect(text).toContain("Their computers right now: WIN-1 (PC): online, they are typing on it now; UBUNTU-1 (computer): online.");
expect(text).toContain("When they say \"my computer\" or \"this computer\", they mean WIN-1.");
- expect(text).toContain("If they ask for something on their PC (WIN-1)");
- expect(cloudHomePrompt(true, [], both.map(({ typing: _typing, ...computer }) => computer))).not.toContain("typing");
+ expect(cloudHomePrompt(true, [], both)).toContain("If they ask for something on their PC (WIN-1)");
+ expect(cloudComputersNowPart(true, both.map(({ typing: _typing, ...computer }) => computer)).text).not.toContain("typing");
});
it("says the bot runs in the cloud, offers what works there, and never asks for a place that cannot exist", () => {
for (const tools of [true, false]) {
diff --git a/server/system-prompt.ts b/server/system-prompt.ts
index 4d5e71f691..6f7a4a36a9 100644
--- a/server/system-prompt.ts
+++ b/server/system-prompt.ts
@@ -46,7 +46,7 @@ export function heavyPrompt(sections: readonly PromptSection[]): boolean {
// Two more ride the volatile half so a bot's stable half is the same bytes across its runs: the bridge rule (on for some
// runs of a bot and not others) and an automation run's reply rule ("automation-reply"), which otherwise makes every
// routine run write a new cached prefix.
-const VOLATILE_SECTIONS = new Set(["memory", "mentions", "outstanding", "teammate-questions", "long-waits", "recent", "availability", "active-routines",
+const VOLATILE_SECTIONS = new Set(["memory", "computers-now", "mentions", "outstanding", "teammate-questions", "long-waits", "recent", "availability", "active-routines",
"plan", "assignment", "routine-execution", "automation-reply", "skill-instructions", "playbooks", "device", "device-place", "files", "tool-bridge"]);
/** In the stable half, so it is not sent again whenever availability changes, but no part of what a per-thread process is
* keyed on: a warm process gets a changed roster as a note instead of a relaunch (SendTurnInput.systemRoster). */
@@ -208,6 +208,12 @@ export const CLOUD_REUSE_INSTALLS = " Reuse, and update if needed, what is alrea
/** Work on a Cloud disk lives only there: code with a remote goes up as a branch, never over anyone's main line. */
export const CLOUD_PUSH_CODE_WORK = " When a project in your working folder has a git remote the person works in and you can push to it, commit your work and push it to one branch of your own, reusing that branch, instead of leaving it only on this disk: never force-push, never push to the default branch, and never commit secrets, .env files or installed packages such as node_modules.";
+/** Which of their computers are online and which one they are typing on: it changes between turns, so it rides the volatile half,
+ * and a computer going to sleep or a message sent from another device never relaunches the engine with a new cached prefix. */
+export function cloudComputersNowPart(sharedComputerTools: boolean, lent: Parameters<typeof lentComputersLine>[0]): PromptPart {
+ return { id: "computers-now", label: "Their computers now", text: sharedComputerTools ? lentComputersLine(lent) : "" };
+}
+
/** `asks`: the person's own Cloud, whose bots ask them to turn on what their computer doesn't give now (ask_for_computer). */
export function cloudHomePrompt(sharedComputerTools: boolean, synced: ReadonlyArray<{ computerName: string; pcPath: string; cloudPath: string }> = [],
lent: ReadonlyArray<{ name: string; platform: "darwin" | "win32" | "linux" | null; online?: boolean; lent?: boolean; lastSeenAt?: number; typing?: boolean }> = [], asks = false): string {
@@ -216,7 +222,7 @@ export function cloudHomePrompt(sharedComputerTools: boolean, synced: ReadonlyAr
? ` If it isn't online, or doesn't lend what you need (its apps and screen, its files, running commands), call ask_for_computer with what you want to do and why: it shows them one card with a one-tap Turn on, and you carry on once it's on. Don't explain the fix yourself, and never do it on their cloud computer or in the built-in browser instead unless they ask you to.`
: ` If none is online, say so in one sentence: use its say field when it has one (it names the computer and when it was last online), otherwise ask them to open OpenMausBot on that ${device}, signed in to MausBot Cloud: it shares that ${device} with you by itself.`;
return ` You run on ${CLOUD_HOME_PLACE}.` + (sharedComputerTools
- ? ` If they ask for something on ${theirs}, check list_shared_computers: a computer they share with the Cloud is reachable through shared_computer, within the folders and apps it allows.${lentComputersLine(lent)}${unavailable}${device === "computer" ? " Call it their computer: never assume it is a Mac." : ` It is a ${device}: call it that, never a Mac unless it is one.`}`
+ ? ` If they ask for something on ${theirs}, check list_shared_computers: a computer they share with the Cloud is reachable through shared_computer, within the folders and apps it allows.${unavailable}${device === "computer" ? " Call it their computer: never assume it is a Mac." : ` It is a ${device}: call it that, never a Mac unless it is one.`}`
+ ` While that ${device} is away, each folder it lends that the Cloud keeps a copy of still works from that copy: list_shared_computers lists them under away_computers (copy null means a folder only on the ${device}), every read says how fresh the copy is, and a write to a folder lent with editing is saved here and reaches the ${device} when it's on (tell them so in a few words). A file or folder that isn't in the copy is only on the ${device}: say you'll get it when it's on.`
: ` You cannot see or use ${theirs}, its screen or its files from here. If they ask for something on it, say so in one sentence.`)
+ offTheirNetwork(sharedComputerTools, theirs)