Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
assignment_status: tell a sibling chat its hand-off result does not resume it
AdityaUmale670e995bd1c9
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.tsindex f18a7da65f..ce1ad61016 100644--- a/server/drivers/agents-call.ts+++ b/server/drivers/agents-call.ts@@ -103,7 +103,7 @@ function renderAssignmentStatus(r: Json, id: string): string {const children = Array.isArray(r.children) ? r.children.filter(jsonRecord) : [];if (children.length) lines.push("Its own hand-offs:", ...children.map((child) => `- ${assignmentLine(child)}`));const settled = a.status === "completed" || a.status === "failed" || a.status === "cancelled" || a.status === "done";- if (!settled) lines.push("It is not settled. Its result resumes you on its own; do not wait on it in this turn.");+ if (!settled) lines.push(`It is not settled. ${r.sentElsewhere === true ? "It was sent from another of your chats, so its result returns there and does not resume you here" : "Its result resumes you on its own"}; do not wait on it in this turn.`);return lines.join("\n");}diff --git a/server/drivers/agents-proxy.test.ts b/server/drivers/agents-proxy.test.tsindex 95eea316b9..bc32052ab8 100644--- a/server/drivers/agents-proxy.test.ts+++ b/server/drivers/agents-proxy.test.ts@@ -1335,6 +1335,20 @@ describe("agents-proxy MCP surface", () => {assignmentStatusResponse = DONE_ASSIGNMENT;});+ it("assignment_status on a hand-off sent from another own chat says its result does not resume this one", async () => {+ const running = { assignment: { id: "asg-7", botId: "bot-helper", botName: "Helper", status: "running" }, children: [], inbox: [] };+ try {+ assignmentStatusResponse = running;+ expect((await callTool("assignment_status", { id: "asg-7" })).result.content[0].text).toContain("Its result resumes you on its own");+ assignmentStatusResponse = { ...running, sentElsewhere: true };+ const text = (await callTool("assignment_status", { id: "asg-7" })).result.content[0].text;+ expect(text).toContain("It was sent from another of your chats, so its result returns there and does not resume you here");+ expect(text).not.toContain("resumes you on its own");+ } finally {+ assignmentStatusResponse = DONE_ASSIGNMENT;+ }+ });+it("assignment_status long-polls with wait_ms, capped at 240000, and refuses a bad wait", async () => {lastAssignmentStatusUrl = null;const res = await callTool("assignment_status", { id: "task-earlier123", wait_ms: 900_000 });diff --git a/server/external-runtime.e2e.test.ts b/server/external-runtime.e2e.test.tsindex 269e4c6439..c202d6d66c 100644--- a/server/external-runtime.e2e.test.ts+++ b/server/external-runtime.e2e.test.ts@@ -195,10 +195,13 @@ describe("a bot's external runtime", () => {expect(sibling.status, JSON.stringify(sibling.body)).toBe(200);expect(sibling.body.inbox.length).toBeGreaterThan(0);expect(sibling.body.inbox.filter((item: { deliveredAt?: number }) => item.deliveredAt !== undefined)).toEqual([]);+ expect(sibling.body.sentElsewhere).toBe(true);pin(runtime.threadId);const owner = await asRuntime("GET", `/api/internal/assignment-status?id=${handed.body.rootId}`);expect(owner.status, JSON.stringify(owner.body)).toBe(200);+ expect(owner.body.sentElsewhere).toBeUndefined();+ expect(owner.body.inbox.length).toBeGreaterThan(0);expect(owner.body.inbox.filter((item: { deliveredAt?: number }) => item.deliveredAt === undefined)).toEqual([]);} finally {for (const bot of [runtime, peer]) {diff --git a/server/index.ts b/server/index.tsindex 4ee8c2f4d1..3d69e43cd4 100644--- a/server/index.ts+++ b/server/index.ts@@ -13767,8 +13767,8 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {const refused = readRefusal(status.assignment); if (refused) return json(res, 403, { error: refused });if (!reachable(status.assignment)) return json(res, 403, { error: "Result withheld: team access changed while the teammate was working" });if (settled.has(status.assignment.status) || Date.now() >= deadline) {- // Only the conversation that sent it takes its results; another of the bot's chats just reads them.- if (EXTERNAL && !status.assignment.parentId && coordinator.node(status.assignment.rootId)?.threadId === fromThreadId) {+ const sentHere = coordinator.node(status.assignment.rootId)?.threadId === fromThreadId; // only the sending conversation takes its results+ if (EXTERNAL && !status.assignment.parentId && sentHere) {const lanes = new Map<string, { botId?: string; threadId?: string; runId?: string }>();for (const item of status.inbox) {if (item.deliveredAt !== undefined) continue;@@ -13781,7 +13781,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {for (const lane of lanes.values()) coordinator.poll(lane);}const current = coordinator.status(id) ?? status;- return json(res, 200, { assignment: shape(current.assignment), children: current.children.map(shape), inbox: current.inbox });+ return json(res, 200, { assignment: shape(current.assignment), children: current.children.map(shape), inbox: current.inbox, ...(sentHere ? {} : { sentElsewhere: true }) });}await new Promise((wake) => setTimeout(wake, 500));}