Skip to content

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

Show a tagged teammate's answer in a bot's chat under its own name (#8096)

Bugfixer 28f69903bbf11
diff --git a/docs/verification/mentions.md b/docs/verification/mentions.md
index 9488babf3d..c7445d535d 100644
--- a/docs/verification/mentions.md
+++ b/docs/verification/mentions.md
@@ -23,6 +23,7 @@ stops the fixture servers and removes their temporary data directory.
| Long draft | Paste 12 lines, choose Display in chat box, scroll inside the textarea and edit at the end | Mirror and textarea widths, wrapped heights and scroll offsets agree; 12 mentions retained |
| Direct chat | Switch to Direct chat; select Juniper by mouse and send | User bubble highlights the mention and the task settles |
| Direct chat scope | Enter `@everyone @Atlas @Juniper` in Atlas's direct chat | Only Juniper is highlighted |
+| Tagged teammate answers | In Atlas's direct chat, ask `@Juniper …` with a live engine; Atlas consults Juniper | Juniper's answer appears under Juniper's name and avatar, not as a folded teammate row; Atlas does not repeat it (`server/direct-coordination.e2e.test.ts` "#8096", `ChatView.team.test.ts`) |
| Responsive draft | Resize from desktop to 390px with the multiple-mention draft | Input grows to three lines; mirror and textarea both measure 80px |
| Skins | Switch Dark → Light → Dark | Names remain legible in the composer and sent bubbles |
| Bot identity colors | Compare Juniper (red) and Atlas (blue) with their avatars | Each mention uses its bot's MAUS_COLORS value; everyone remains neutral |
diff --git a/server/direct-coordination.e2e.test.ts b/server/direct-coordination.e2e.test.ts
index 6f6b16bce3..a06debcfe0 100644
--- a/server/direct-coordination.e2e.test.ts
+++ b/server/direct-coordination.e2e.test.ts
@@ -160,6 +160,23 @@ it("lets a bot ask a bot in another department directly, with nothing set up fir
expect(said.some((message: any) => message.text === "Clive says yes: the latest PHP is fine for us.")).toBe(true);
}), 45_000);
+it("shows a tagged teammate's answer in the asker's chat under its own name (#8096)", () => fixture(async f => {
+ await f.api(`/api/bots/${f.chief.id}`, { managedSections: [] }, "PATCH");
+ f.plan[f.lead.id] = {
+ steps: [{ arguments: { bot_ids: ["Clive"], message: "Can we upgrade to the latest PHP version?", consult: true } }],
+ reply: "Asked Clive", resumeReply: "Nothing to add.",
+ };
+ f.plan[f.chief.id] = { reply: "Yes, the latest PHP version is fine for us." };
+ f.save();
+ await f.cli("send", "--bot", f.lead.id, "--task", f.lead.activeTaskId, "--text", "@Clive can we upgrade to the latest PHP version?");
+ expect((await f.cli("wait", "--bot", f.lead.id, "--task", f.lead.activeTaskId, "--timeout", "30")).status).toBe("settled");
+ expect(f.evidence().find((turn: any) => turn.botId === f.lead.id).system).toContain("its answer shows in this chat under its own name");
+ const said = await f.messages(f.lead.activeTaskId);
+ expect(said).toContainEqual(expect.objectContaining({ role: "bot", kind: "text", text: "Yes, the latest PHP version is fine for us.",
+ from: expect.objectContaining({ botId: f.chief.id, name: "Clive" }) }));
+ expect(said.filter((message: any) => message.roomRequest?.phase === "result")).toHaveLength(1);
+}), 45_000);
+
it.each([false, true])("starts independent work immediately and frees the Chief while waiting (source fails: %s)", fail => fixture(async f => {
const sourceGate = join(f.session.info.dataDir, "source-ready");
const childGate = join(f.session.info.dataDir, "child-ready");
diff --git a/server/index.ts b/server/index.ts
index e8b24b6a66..bd0a9f1df9 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -33,7 +33,7 @@ import { BOT_PROFILE_LIMITS } from "../shared/bot-profile.ts";
import { CLOUD_COMPUTER_BUSY_ERROR } from "../shared/computer-contention.ts";
import { failedTurnTool } from "../shared/failed-turn.ts";
import { assistantTranscript, errorTranscript } from "../shared/client-cancel.ts"; import { PersonStops, stoppedTurnRow } from "./person-stops.ts"; import { LiveTurns } from "./live-turns.ts";
-import { phonePairingLink } from "../shared/pairing-link.ts"; import { personTagNames, withoutPersonTags } from "../shared/person-mention.ts";
+import { TAGGED_ANSWER_PROMPT, taggedAnswerRow } from "./tagged-answer.ts"; import { phonePairingLink } from "../shared/pairing-link.ts"; import { personTagNames, withoutPersonTags } from "../shared/person-mention.ts";
import { canWorkOnCloud, type CloudEngine } from "../shared/cloud-computer.ts";
import {
approvalModeFor,
@@ -3910,7 +3910,10 @@ const handedLines: HandedLineDeps | undefined = CLOUD_TEAM ? undefined : { store
const bot = store.bot(child.botId);
if (store.messagesFor(parent.threadId).some(m => m.roomRequest?.id === child.id && m.roomRequest.phase === "result")) return;
const problem = roomHandoffProblem(child, parent);
- store.appendMessage(parent.threadId, {
+ const source = store.bot(parent.botId);
+ const answer = problem || !source ? null
+ : taggedAnswerRow(child, parent, bot, taggedTeammates(parent.text, personalReach.peers(store.bots, source, parent.threadId)).map((one) => one.id));
+ store.appendMessage(parent.threadId, answer ?? {
role: "bot", kind: "activity",
roomRequest: { id: child.id, phase: "result" }, ...handoffFiles.returnedWith(child, parent),
from: bot ? { botId: bot.id, name: bot.name, color: bot.color } : undefined,
@@ -3927,7 +3930,6 @@ const handedLines: HandedLineDeps | undefined = CLOUD_TEAM ? undefined : { store
if (group) store.markGroupThreadUnread(group.id, child.threadId, true);
else {
if (!parent.parentId && parent.reply !== "poll") store.patchTask(parent.botId, parent.threadId, { unread: true });
- const source = store.bot(parent.botId);
if (source) markTaskContextExternallyUpdated(source, parent.threadId);
}
if (!child.groupId && child.status === "completed" && !problem && !coordinator.activeDirect(child.threadId)) finishHandedThread(store, child.botId, child.threadId, parent.botId, (threadId) => botWaits.list(child.botId).some((wait) => wait.threadId === threadId));
@@ -7392,6 +7394,12 @@ const titleRegenerations = new Set<string>();
/** The turn's start saves its thread's bookkeeping (title, last asked, read) once, when its synchronous part returns. */
function startTurn(...args: Parameters<typeof beginTurn>): ReturnType<typeof beginTurn> { return batchSaves(() => beginTurn(...args)); }
+/** The teammates a person's "@Name" tags in `text`, never a bot that shares the name of the writer or a teammate. */
+function taggedTeammates<T extends { id?: string; name: string; hidden?: boolean }>(text: string, peers: T[], picked?: readonly string[]): T[] {
+ return mentionedBots(withoutPersonTags(text, [...personTagNames(cfg.profile?.name), ...teamMessages.people().flatMap((one) => one.tags)],
+ store.bots.filter((one) => !one.hidden).map((one) => one.name)), peers, picked);
+}
+
async function beginTurn(
botId: string,
text: string,
@@ -8132,11 +8140,7 @@ async function beginTurn(
if (instance.adapter.capabilities.hooks === true && hooksEnabled()) {
integrations.hooks = hooksIntegration(bot.id, threadId, dispatchClaimId);
}
- // "@Bob" is the teammate Bob (or the writer themselves), never a bot that shares the name.
- const tagged = integrations.agents
- ? mentionedBots(withoutPersonTags(providerText, [...personTagNames(cfg.profile?.name), ...teamMessages.people().flatMap((one) => one.tags)],
- store.bots.filter((one) => !one.hidden).map((one) => one.name)), sectionPeers, opts?.mentions)
- : [];
+ const tagged = integrations.agents ? taggedTeammates(providerText, sectionPeers, opts?.mentions) : [];
const teamPrompt = withElsewhere(chiefLevel(bot)
? chiefOfStaffPrompt(bot.id, store.bots, Boolean(integrations.agents), (peer) => personalReach.listed(bot, peer, threadId), store.sections, linkedRoster.forChief(bot, Boolean(integrations.agents)))
: integrations.agents && (sectionPeers.length > 0 || linkedRoster.forPeer(bot))
@@ -8273,7 +8277,7 @@ async function beginTurn(
{ id: "playbooks", label: "Playbooks", text: packagePlaybooks },
{ id: "webhook", label: "Webhook provenance", text: opts?.automationSource === "webhook" ? WEBHOOK_PROMPT : opts?.automationSource === "api" ? (botApiThread(threadId) ? BOT_API_PROMPT : BOT_API_OWNER_PROMPT) : "" },
{ id: "automation-reply", label: "Automation reply", text: opts?.automationSource && automationReports.reportsElsewhere(threadId) ? AUTOMATION_REPLY_PROMPT : "" },
- { id: "mentions", label: "Mentions", text: (tagged.length ? `The user named these existing teammates: ${tagged.map(b => `${peerName(b.name)} (${b.id})`).join(", ")}. Use coordinate_bots when their contribution is needed; do not substitute native helper agents for these bots.` : "") + placesElsewhere.mentioned(providerText, store.bots, botLink.reaches) },
+ { id: "mentions", label: "Mentions", text: (tagged.length ? `The user named these existing teammates: ${tagged.map(b => `${peerName(b.name)} (${b.id})`).join(", ")}. Use coordinate_bots when their contribution is needed; do not substitute native helper agents for these bots.${commsDepth === 0 ? TAGGED_ANSWER_PROMPT : ""}` : "") + placesElsewhere.mentioned(providerText, store.bots, botLink.reaches) },
].filter((part) => (apiFenced ? BOT_API_PARTS.has(part.id) : !confined || READ_AND_DRAFT_PARTS.has(part.id))), integrations.agents, { replyStyle: liveBot?.replyStyle ?? bot.replyStyle, rules: cfg.everyBotRules, pagesOff: (liveBot ?? bot).toolsOff?.includes("pages") }); setup.lap("prompt");
turnPromptBytes.set(threadId, { stable: Buffer.byteLength(prompt.stable), volatile: Buffer.byteLength(prompt.volatile) });
// Recall rides in front of this turn's message, never the system prompt, whose volatile half is re-sent whole on any change.
diff --git a/server/tagged-answer.test.ts b/server/tagged-answer.test.ts
new file mode 100644
index 0000000000..410dad4808
--- /dev/null
+++ b/server/tagged-answer.test.ts
@@ -0,0 +1,33 @@
+import { describe, expect, it } from "vitest";
+import { taggedAnswerRow } from "./tagged-answer.ts";
+
+const chief = { id: "chief", name: "Chief", color: "red" as const };
+const answered = { id: "h1", botId: "chief", mode: "consult" as const, status: "completed" as const, result: " $4.20 today. " };
+const wesChat = { botId: "wes" };
+
+describe("a teammate tagged in another bot's one-to-one chat", () => {
+ it("answers there under its own name", () => {
+ expect(taggedAnswerRow(answered, wesChat, chief, ["chief"])).toEqual({
+ role: "bot", kind: "text", text: "$4.20 today.",
+ from: { botId: "chief", name: "Chief", color: "red" }, roomRequest: { id: "h1", phase: "result" },
+ });
+ });
+
+ it("keeps the teammate row for everything else", () => {
+ expect(taggedAnswerRow(answered, wesChat, chief, [])).toBeNull();
+ expect(taggedAnswerRow(answered, { ...wesChat, groupId: "room" }, chief, ["chief"])).toBeNull();
+ expect(taggedAnswerRow(answered, { ...wesChat, parentId: "p" }, chief, ["chief"])).toBeNull();
+ expect(taggedAnswerRow({ ...answered, mode: "work" }, wesChat, chief, ["chief"])).toBeNull();
+ expect(taggedAnswerRow({ ...answered, status: "failed" }, wesChat, chief, ["chief"])).toBeNull();
+ expect(taggedAnswerRow({ ...answered, result: " " }, wesChat, chief, ["chief"])).toBeNull();
+ expect(taggedAnswerRow(answered, wesChat, undefined, ["chief"])).toBeNull();
+ expect(taggedAnswerRow({ ...answered, botId: "wes" }, wesChat, chief, ["wes"])).toBeNull();
+ });
+});
+
+describe("the tagged teammate's reply", () => {
+ it("hides secrets like the teammate row does", () => {
+ const key = "sk-ant-api03-" + "x".repeat(40);
+ expect(taggedAnswerRow({ ...answered, result: `key ${key}` }, wesChat, chief, ["chief"])?.text).not.toContain(key);
+ });
+});
diff --git a/server/tagged-answer.ts b/server/tagged-answer.ts
new file mode 100644
index 0000000000..9f8175d728
--- /dev/null
+++ b/server/tagged-answer.ts
@@ -0,0 +1,24 @@
+// "@Chief how much did we spend today?" in Wes's one-to-one chat: Wes asks Chief (coordinate_bots consult), and Chief's
+// answer shows in that chat as Chief's own reply, under Chief's name, instead of a folded teammate row Wes must repeat.
+import type { HandoffView } from "./coordinator.ts";
+import type { WireBot } from "../shared/wire.ts";
+import type { Message } from "./store.ts";
+import { redactSecretsInText } from "./redact.ts";
+
+/** The reply row a teammate's finished consult leaves in the person's chat when the person tagged that teammate there,
+ * or null when it is any other hand-off: rooms, work, notices, nested asks, failures and untagged teammates keep their
+ * teammate row. */
+export function taggedAnswerRow(
+ child: Pick<HandoffView, "id" | "botId" | "mode" | "status" | "result">,
+ parent: Pick<HandoffView, "botId" | "groupId" | "parentId">,
+ bot: Pick<WireBot, "id" | "name" | "color"> | undefined,
+ tagged: readonly string[],
+): Omit<Message, "id" | "at"> | null {
+ const text = redactSecretsInText(child.result.trim());
+ if (!bot || !text || parent.groupId || parent.parentId || child.botId === parent.botId) return null;
+ if (child.mode !== "consult" || child.status !== "completed" || !tagged.includes(child.botId)) return null;
+ return { role: "bot", kind: "text", text, from: { botId: bot.id, name: bot.name, color: bot.color }, roomRequest: { id: child.id, phase: "result" } };
+}
+
+/** The line the chat's own bot reads when it is told the people it tagged: their answer is already in the chat. */
+export const TAGGED_ANSWER_PROMPT = " When you ask a tagged teammate a question with consult, its answer shows in this chat under its own name: do not repeat it; add only what it left out, or nothing.";
diff --git a/shared/skill-burger/delegation.test.ts b/shared/skill-burger/delegation.test.ts
index c3ab79e59e..17b084edf6 100644
--- a/shared/skill-burger/delegation.test.ts
+++ b/shared/skill-burger/delegation.test.ts
@@ -50,6 +50,14 @@ describe("a delegation run", () => {
expect(delegation.replies[0]!.text).toContain("Kiwi: 3 findings");
});
+ it("reads a tagged teammate's answer, a text row in its own name, as that teammate's reply (#8096)", () => {
+ const asText = run.map((message): RunMessage => message.kind === "activity" && message.roomRequest?.phase === "result"
+ ? { id: message.id, role: "bot", kind: "text", text: message.tool?.output, from: message.from, roomRequest: message.roomRequest } : message);
+ const [before, after] = [burgerLayers(run), burgerLayers(asText)];
+ expect(after.map((layer) => [layer.kind, layerLabel(layer)])).toEqual(before.map((layer) => [layer.kind, layerLabel(layer)]));
+ expect(after[0]!.delegation!.replies).toEqual(before[0]!.delegation!.replies);
+ });
+
it("saves one delegate step that can be remapped, with the site as an input, and the review as an AI step", () => {
const draft = draftWorkflow(run, { teammate })!;
expect(workflowSchema.safeParse(draft.workflow).success).toBe(true);
diff --git a/shared/skill-burger/layers.ts b/shared/skill-burger/layers.ts
index 31228db4af..accb34f853 100644
--- a/shared/skill-burger/layers.ts
+++ b/shared/skill-burger/layers.ts
@@ -488,10 +488,11 @@ function repliesIn(run: readonly RunMessage[]): Map<string, Omit<DelegateReply,
const out = new Map<string, Omit<DelegateReply, "round">>();
for (const message of run) {
const request = message.roomRequest;
- if (message.kind !== "activity" || request?.phase !== "result" || !request.id) continue;
+ // A tagged teammate's answer is a text row in its own name (server/tagged-answer.ts); every other reply is an activity row.
+ if ((message.kind !== "activity" && message.kind !== "text") || request?.phase !== "result" || !request.id) continue;
out.set(request.id, {
name: message.from?.name ?? "", ...(message.from?.botId ? { botId: message.from.botId } : {}), requestId: request.id,
- ok: message.tool?.ok !== false, text: message.tool?.output ?? message.tool?.name ?? "",
+ ok: message.tool?.ok !== false, text: message.tool?.output ?? (message.kind === "text" ? message.text : undefined) ?? message.tool?.name ?? "",
});
}
return out;
diff --git a/src/components/ChatView.team.test.ts b/src/components/ChatView.team.test.ts
index a930b731e2..12958fcaf1 100644
--- a/src/components/ChatView.team.test.ts
+++ b/src/components/ChatView.team.test.ts
@@ -90,3 +90,14 @@ it.each([[false, "[data-chathead-privacy='shared']"], [true, "[data-chathead-sha
expect(said()).toBe(t("team.sharedHeaderPeople"));
setAdvancedMode(false);
});
+
+it("labels a tagged teammate's answer with its name, and leaves the chat's own bot unlabelled (#8096)", () => {
+ draw(luna([
+ { id: "u1", role: "user", kind: "text", at: 1, text: "@Chief how much did we spend today?" },
+ { id: "c1", role: "bot", kind: "text", at: 2, text: "$4.20 today.", from: { botId: "chief", name: "Chief", color: "red" }, roomRequest: { id: "h1", phase: "result" } },
+ { id: "l1", role: "bot", kind: "text", at: 3, text: "Anything else?" },
+ ]));
+ const block = (id: string) => container.querySelector(`[data-mid="${id}"]`)!.textContent;
+ expect(block("c1")).toContain("Chief");
+ expect(block("l1")).not.toContain("Luna");
+});
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index e65ab65517..20cf376f07 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -49,6 +49,7 @@ import { isCancelledTranscriptRow, PERSON_STOPPED_TURN_NAME } from "../../shared
import { stopNoticeDue, useStoppedAt } from "@/lib/stop-turn";
import { THIS_COMPUTER_NOT_READY } from "../../shared/your-computer";
import { BotAvatar } from "./Avatar";
+import { ClusterLabel } from "./RoomClusterLabel";
import { TurnPresence } from "./TurnPresence";
import { showToolCallsEnabled } from "@/lib/feature-flags";
import { stateForBot } from "@/lib/mascot";
@@ -686,7 +687,9 @@ const MessagesList = memo(function MessagesList({
const peer = peerLine(m) ?? peerRequest(m, botId);
const user = m.role === "user" && !peer;
if (!user && isPureLeakedSystemHarnessMessage(m.text) && !m.attachments?.length) return null;
- return (
+ // A teammate the person tagged here answers in its own name (server/tagged-answer.ts).
+ const teammate = m.role === "bot" && m.from && m.from.botId !== botId ? m.from : undefined;
+ const bubble = (
<Bubble
message={m}
emerging={m.id === emergingId}
@@ -705,6 +708,9 @@ const MessagesList = memo(function MessagesList({
onReply={onReply} forked={forked.has(m.id)} earlierRound={earlier.get(m.id)}
/>
);
+ return teammate
+ ? <><ClusterLabel bot={bots.find((one) => one.id === teammate.botId)} name={teammate.name} color={teammate.color} />{bubble}</>
+ : bubble;
}
}
})();
@@ -781,8 +787,8 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
});
const lastBotTextId = useMemo(
- () => [...messages].reverse().find((m) => m.role === "bot" && m.kind === "text")?.id,
- [messages],
+ () => [...messages].reverse().find((m) => m.role === "bot" && m.kind === "text" && (!m.from || m.from.botId === bot.id))?.id,
+ [messages, bot.id],
); const unreadDivider = useUnreadDivider({ threadId: bot.threadId, messages: chatMessages, following });
const bots = useStoreSelector((s) => s.bots, sameDrawnBots);