Skip to content

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

fix(engines): a teammate's report keeps the thread's warm engine

Absterrg0051eb26fda49
diff --git a/docs/verification/claude-tool-lifecycle.md b/docs/verification/claude-tool-lifecycle.md
index bd2caee086..c819300952 100644
--- a/docs/verification/claude-tool-lifecycle.md
+++ b/docs/verification/claude-tool-lifecycle.md
@@ -51,16 +51,23 @@ engine stays warm instead of relaunching every turn. The same bot on the same
thread, with the same grants and approval level, holds the same bearer, and
the harness honours it only while one of that thread's turns runs. Stop, a
stall, a deleted bot or thread, a changed grant or approval level, or a
-provider reload gives the next turn a new bearer. The computer gets a new
-bearer every turn: its tools bridge into a machine that can stop between
-turns (an idle Local VM, a VPS that Auto starts), and a warm engine would not
-restart a bridge whose machine went away. The per-turn limits (bots
-created, threads opened, room posts, and not checking a delegation in the
-turn that made it) are counted by the harness for each turn, not by the
+provider reload gives the next turn a new bearer. What only one turn may do
+is not such a grant: its depth, the hand-off it runs for and whether it may
+author skills live in that turn's record, which the harness reads on every
+call. So a teammate's report, the person's next message and each new job a
+teammate takes all run in the same Claude process and ACP session, in direct
+chats and in rooms alike; the engine is never told its depth. The computer
+gets a new bearer every turn: its tools bridge into a machine that can stop
+between turns (an idle Local VM, a VPS that Auto starts), and a warm engine
+would not restart a bridge whose machine went away. The per-turn limits
+(bots created, threads opened, room posts, and not checking a delegation in
+the turn that made it) are counted by the harness for each turn, not by the
proxy, which a warm engine keeps across turns.
```sh
pnpm exec vitest run server/session-credentials.e2e.test.ts server/post-to-room.test.ts server/vps-routing.test.ts
+pnpm exec vitest run server/delta-context.e2e.test.ts -t "keeps the source's and the teammate's engines|keeps an ACP teammate's session"
+pnpm exec vitest run server/room-coordination.e2e.test.ts -t "keeps each member's engine"
```
A message steered into a running Claude turn is folded in only before a
diff --git a/server/agents-bridge-gates.test.ts b/server/agents-bridge-gates.test.ts
index 711dbed137..af339b897b 100644
--- a/server/agents-bridge-gates.test.ts
+++ b/server/agents-bridge-gates.test.ts
@@ -28,7 +28,7 @@ type Server = { command: string; args: string[]; env: Record<string, string> };
const BRIDGED: Server = {
command: process.execPath,
args: [join(HERE, "drivers", "agents-proxy.ts")],
- env: { OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-gated", OMB_THREAD_ID: "thread-gated", OMB_COMMS_TOKEN: "unused", OMB_TURN_DEPTH: "0", [TOOL_BRIDGE_ENV]: "1" },
+ env: { OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-gated", OMB_THREAD_ID: "thread-gated", OMB_COMMS_TOKEN: "unused", [TOOL_BRIDGE_ENV]: "1" },
};
const DENY_VM: ToolScope = { deny: ["mcp:agents:vm_exec"] };
const ONLY_LIST_BOTS: ToolScope = { allow: ["mcp:agents:list_bots"] };
diff --git a/server/agents-turn.ts b/server/agents-turn.ts
index b960bc42a5..f77c3e08de 100644
--- a/server/agents-turn.ts
+++ b/server/agents-turn.ts
@@ -40,7 +40,6 @@ export function agentsServerEnv(conversation: AgentsConversation, turn: AgentsTu
OMB_BOT_ID: bot.id,
OMB_THREAD_ID: conversation.threadId,
OMB_COMMS_TOKEN: bearer(turn),
- OMB_TURN_DEPTH: String(turn.depth),
OMB_SKILL_AUTHORING_ENABLED: flag(host.skillAuthoring),
OMB_MEMORY_ENABLED: flag(bot.memoryEnabled !== false),
OMB_SHARED_COMPUTERS_ENABLED: flag(host.sharedComputers),
diff --git a/server/bot-box/env.ts b/server/bot-box/env.ts
index 52c55adff9..583526f26b 100644
--- a/server/bot-box/env.ts
+++ b/server/bot-box/env.ts
@@ -17,7 +17,7 @@ export const BOX_ENV_NAMES: ReadonlySet<string> = new Set([
* proxies it starts. Security: no other `OMB_` name passes, whatever the operator set on the server (an SMTP URL, a
* token); env.test.ts lists every `OMB_` name the server knows, so a new one needs a decision. */
export const BOX_ENV_OMB_NAMES: ReadonlySet<string> = new Set([
- "OMB_HARNESS_URL", "OMB_BOT_ID", "OMB_THREAD_ID", "OMB_COMMS_TOKEN", "OMB_TURN_DEPTH", "OMB_EXTERNAL_RUNTIME",
+ "OMB_HARNESS_URL", "OMB_BOT_ID", "OMB_THREAD_ID", "OMB_COMMS_TOKEN", "OMB_EXTERNAL_RUNTIME",
"OMB_CHIEF_OF_STAFF", "OMB_MAUSBOT", "OMB_SKILL_AUTHORING_ENABLED", "OMB_MEMORY_ENABLED", "OMB_SHARED_COMPUTERS_ENABLED",
"OMB_VOICE_NOTES", "OMB_X_RESEARCH", "OMB_RESEARCH", "OMB_TEAM_PEOPLE", "OMB_COMPUTER_SELECTION", "OMB_ROOM",
"OMB_IMAGE_GENERATION", "OMB_MEETINGS", "OMB_APP_HOSTING", "OMB_AGENTS_TOOL_BRIDGE", "OMB_TOOL_LIMIT", "OMB_TOOL_SCHEMA_PROFILE",
diff --git a/server/delta-context.e2e.test.ts b/server/delta-context.e2e.test.ts
index 8ec20f37aa..6c0990bd74 100644
--- a/server/delta-context.e2e.test.ts
+++ b/server/delta-context.e2e.test.ts
@@ -27,11 +27,11 @@ const OUTSIDE_LINEAGE = "This work started with a chat line nothing proves the u
const jsonl = (path: string) => existsSync(path)
? readFileSync(path, "utf8").trim().split("\n").filter(Boolean).map((line) => JSON.parse(line)) : [];
-async function fixture(test: (f: any) => Promise<void>, options: { env?: NodeJS.ProcessEnv; codex?: Record<string, string> } = {}) {
+async function fixture(test: (f: any) => Promise<void>, options: { env?: NodeJS.ProcessEnv; codex?: Record<string, string>; acp?: boolean } = {}) {
// The fixture's Claude is new enough to refresh a resumed session's recorded system prompt; a test may override it.
const parentEnv = { ...process.env, FAKE_CLAUDE_VERSION: "2.1.270", ...options.env };
const session = await launchVerificationServer(parentEnv, undefined, undefined, undefined, undefined,
- { scripted: true }, options.codex ? ["codex"] : []);
+ { scripted: true }, [...(options.codex ? ["codex" as const] : []), ...(options.acp ? ["customAcp" as const] : [])]);
const cli = (...args: string[]) => runControlOmb(args, { env: { OPENMAUSBOT_URL: session.info.url } }) as Promise<any>;
const api = (path: string, body?: unknown, method = "POST") =>
request(path, body === undefined ? {} : { method, body: JSON.stringify(body) }, session.info.url) as Promise<any>;
@@ -91,6 +91,9 @@ async function fixture(test: (f: any) => Promise<void>, options: { env?: NodeJS.
await api("/api/instances/codex", { cli: wrap("codex", "fake-codex-app-server.ts",
{ FAKE_CODEX_MODE: "resume", FAKE_CODEX_ROOM_PLAN: planPath, FAKE_CODEX_DUMP: codexDumpPath, ...options.codex }) }, "PATCH");
}
+ const acpRpcPath = join(dataDir, "acp-rpc.jsonl");
+ if (options.acp) await api("/api/instances/myAgent", { cli: wrap("acp", "fake-acp-cli.ts", { FAKE_ACP_RPC_APPEND_FILE: acpRpcPath }) }, "PATCH");
+ const acpCalls = () => jsonl(acpRpcPath);
const bot = async (name: string, section: string) => (await cli("new-bot", "--name", name, "--section", section)).bot;
const chief = await bot("Clive", "Leadership");
const lead = await bot("Engineering lead", "Engineering");
@@ -164,7 +167,7 @@ async function fixture(test: (f: any) => Promise<void>, options: { env?: NodeJS.
}, { timeout: 20_000 }).toBe(true);
};
await test({ session, dataDir, cli, api, chief, lead, qa, ops, plan, save, send, wait, idle, turns, prompt, messages, nodes, root, task, handed,
- launches, nativeSession, consumed, codexLaunches, codexCalls, codexModels, selectModel, setMode, delegate, gate, holdDelegation, open, thread, useModel, restart });
+ launches, nativeSession, consumed, codexLaunches, codexCalls, codexModels, acpCalls, selectModel, setMode, delegate, gate, holdDelegation, open, thread, useModel, restart });
} finally {
if (restarted) await waitForExit(restarted, { signal: "SIGTERM" });
await session.close();
@@ -189,8 +192,7 @@ it("resumes the source session and gives it each of three results exactly once,
const returned = f.turns().at(-1);
const text = f.prompt(returned);
expect(returned.resumed).toBe(true);
- const launches = f.launches();
- expect(launches.at(-1).resume).toBe(launches[0].sessionId);
+ expect(f.nativeSession()).toBe(f.launches()[0].sessionId);
for (const tag of ["LEAD", "QA", "OPS"]) {
expect(count(text, `RESULT_${tag}_START`)).toBe(1);
expect(count(text, `RESULT_${tag}_END`)).toBe(1);
@@ -199,6 +201,39 @@ it("resumes the source session and gives it each of three results exactly once,
expect(text).not.toMatch(/^Assistant: @/m);
}), hostTimeout(60_000));
+it("keeps the source's and the teammate's engines through reports and the person's next messages", () => fixture(async (f) => {
+ await warmUp(f);
+ for (const round of [1, 2]) {
+ f.plan[f.lead.id] = { reply: `ROUND_${round}_RESULT` };
+ f.plan[f.chief.id] = f.delegate(`round-${round}`, [f.lead], `Check round ${round}`);
+ await f.send(`Have Engineering check round ${round}.`);
+ await f.wait();
+ expect(count(f.prompt(f.turns().at(-1)), `ROUND_${round}_RESULT`)).toBe(1);
+ }
+ f.plan[f.chief.id] = { reply: "Plain answer." };
+ await f.send("Just a plain question now.");
+ await f.wait();
+
+ expect(f.launches()).toHaveLength(1);
+ expect(f.launches(f.lead.id)).toHaveLength(1);
+ expect(f.consumed()).toBe(6);
+ expect(f.consumed(f.lead.id)).toBe(2);
+ expect(f.prompt(f.turns().at(-1))).not.toMatch(/ROUND_\d_RESULT/);
+}), hostTimeout(90_000));
+
+it("keeps an ACP teammate's session through two hand-offs", () => fixture(async (f) => {
+ await f.api(`/api/bots/${f.lead.id}`, { modelSelection: { instanceId: "myAgent", model: "fixture-fast" } }, "PATCH");
+ await warmUp(f);
+ for (const round of [1, 2]) {
+ f.plan[f.chief.id] = f.delegate(`round-${round}`, [f.lead], `Check round ${round}`);
+ await f.send(`Have Engineering check round ${round}.`);
+ await f.wait();
+ }
+ const sessions = f.acpCalls().filter((call: any) => ["session/new", "session/load", "session/prompt"].includes(call.method));
+ expect(sessions.map((call: any) => call.method)).toEqual(["session/new", "session/prompt", "session/prompt"]);
+ expect(new Set(sessions.map((call: any) => call.pid)).size).toBe(1);
+}, { acp: true }), hostTimeout(90_000));
+
it("gives the return turn a result that landed while a newer message was running, exactly once", () => fixture(async (f) => {
await warmUp(f);
f.plan[f.lead.id] = { reply: "LEAD_RESULT_TOKEN", gateFile: f.gate("lead") };
@@ -214,7 +249,7 @@ it("gives the return turn a result that landed while a newer message was running
const returned = f.turns().at(-1);
expect(returned.resumed).toBe(true);
expect(count(f.prompt(returned), "LEAD_RESULT_TOKEN")).toBe(1);
- expect(f.launches().at(-1).resume).not.toBeNull();
+ expect(f.nativeSession()).toBe(f.launches()[0].sessionId);
}), hostTimeout(60_000));
it("stops the teammate with the source it worked for, so no result of it lands later or reaches a later turn", () => fixture(async (f) => {
@@ -300,16 +335,21 @@ it("offers the results again when the person stops the return turn before the pr
it("rebuilds a rejected resume with each result exactly once", () => fixture(async (f) => {
await warmUp(f);
- f.plan[f.lead.id] = { reply: `RECOVERY_RESULT_START ${"r".repeat(900)} RECOVERY_RESULT_END` };
+ f.plan[f.lead.id] = { reply: `RECOVERY_RESULT_START ${"r".repeat(900)} RECOVERY_RESULT_END`, gateFile: f.gate("lead") };
f.plan[f.chief.id] = f.delegate("build", [f.lead], "Build the export");
await f.send("Please have Engineering build the export.");
+ await leadRunning(f);
+ await sourceWaiting(f);
+ await f.setMode("resume=dead-session");
+ f.open(f.gate("lead"));
await f.wait();
+ expect(f.launches().map((launch: any) => launch.resume)).toContain(f.launches()[0].sessionId);
const recovered = f.prompt(f.turns().at(-1));
expect(recovered).toContain("received an update outside your provider session");
expect(recovered).toContain("ORCHID_7Q");
expect(count(recovered, "RECOVERY_RESULT_START")).toBe(1);
expect(count(recovered, "RECOVERY_RESULT_END")).toBe(1);
-}, { env: { FAKE_CLAUDE_MODE: "dead-session" } }), hostTimeout(60_000));
+}), hostTimeout(60_000));
it("keeps provenance and exactly-once delivery across rework rounds to the same teammate", () => fixture(async (f) => {
await warmUp(f);
@@ -328,7 +368,7 @@ it("keeps provenance and exactly-once delivery across rework rounds to the same
expect(count(f.prompt(roundOne), "ROUND_ONE_RESULT")).toBe(1);
expect(count(f.prompt(roundTwo), "ROUND_TWO_RESULT")).toBe(1);
expect(count(f.prompt(roundTwo), "ROUND_ONE_RESULT")).toBe(1);
- expect(f.launches().at(-1).resume).not.toBeNull();
+ expect(f.nativeSession()).toBe(f.launches()[0].sessionId);
const second = f.prompt(f.turns(f.lead.id)[1]);
expect(count(second, "REQUEST_TWO")).toBe(1);
@@ -818,7 +858,7 @@ it("gives a replacement session an earlier round's result that its rebuild could
await expect.poll(() => f.nodes().filter((node: any) => node.botId === f.lead.id).map((node: any) => node.status).join(","), { timeout: 30_000 }).toBe("completed,running");
await expect.poll(() => f.turns().length, { timeout: 10_000 }).toBe(3);
await expect.poll(() => count(f.prompt(f.turns()[2]), "ROUND_ONE_RESULT_TOKEN"), { timeout: 10_000 }).toBe(1);
- await expect.poll(() => f.launches(f.lead.id).length, { timeout: 15_000 }).toBe(2);
+ await expect.poll(() => f.consumed(f.lead.id), { timeout: 15_000 }).toBe(2);
for (let i = 0; i < chat; i++) {
await sourceWaiting(f);
expect((await f.send(`chat ${i}`)).steered).toBeUndefined();
@@ -1075,6 +1115,7 @@ it("gives a delegated return the fresh session and replay it always had when the
const returned = f.turns().at(-1);
expect(f.launches().at(-1).resume).toBeNull();
+ const replacement = f.nativeSession();
expect(returned.system).toContain("NEW_SOUL_MARK");
expect(f.prompt(returned)).toContain("received an update outside your provider session");
expect(f.prompt(returned)).toContain("ORCHID_7Q");
@@ -1082,7 +1123,7 @@ it("gives a delegated return the fresh session and replay it always had when the
await f.send("And now?");
await f.wait();
- expect(f.launches().at(-1).resume).not.toBeNull();
+ expect(f.nativeSession()).toBe(replacement);
expect(count(f.prompt(f.turns().at(-1)), "SOUL_CHANGE_RESULT")).toBe(0);
}), hostTimeout(90_000));
@@ -1233,7 +1274,7 @@ it.skipIf(process.platform === "win32")("gives a delegated return today's fresh
f.plan[f.chief.id] = { reply: "Nothing new" };
await f.send("And now?");
await f.wait();
- expect(f.launches().at(-1).resume).toBe(Object.values(f.task().resumeCursors)[0]);
+ expect(f.nativeSession()).toBe(Object.values(f.task().resumeCursors)[0]);
expect(count(f.prompt(f.turns().at(-1)), "SETUP_SOUL_RESULT")).toBe(0);
}), hostTimeout(90_000));
diff --git a/server/direct-coordination.e2e.test.ts b/server/direct-coordination.e2e.test.ts
index 3c4b50b061..eeb701d6a3 100644
--- a/server/direct-coordination.e2e.test.ts
+++ b/server/direct-coordination.e2e.test.ts
@@ -544,7 +544,7 @@ it("continues one recipient thread for every follow-up from the same conversatio
const leadTurns = f.evidence().filter((turn: any) => turn.botId === f.lead.id);
expect(leadTurns.map((turn: any) => turn.threadId)).toEqual([first.threadId, first.threadId, first.threadId]);
for (const [index, brief] of briefs.entries()) expect(leadTurns[index].prompt.message.content).toContain(brief);
- expect(leadTurns.every((turn: any) => turn.system.includes("current request and returned results arrive in the user turn"))).toBe(true);
+ expect(leadTurns.every((turn: any) => told(turn).includes("current request and returned results arrive in the user turn"))).toBe(true);
expect(leadTurns.every((turn: any) => turn.snapshotMode === "off")).toBe(true);
for (const brief of briefs) expect(leadTurns.every((turn: any) => !turn.system.includes(brief))).toBe(true);
const receipts = sendReceipts(f, f.chief.id);
diff --git a/server/drivers/agents-aliases.test.ts b/server/drivers/agents-aliases.test.ts
index e0568544a4..37a979de8b 100644
--- a/server/drivers/agents-aliases.test.ts
+++ b/server/drivers/agents-aliases.test.ts
@@ -36,7 +36,7 @@ async function run(name: string, args: Json) {
const sent: Array<{ path: string; body?: unknown }> = [];
const answer = { ok: true, status: 201, body: { messageId: "m1", resultId: "t-1", now: "2026-10-29T09:00:00Z", timeZone: "UTC", triggers: [], ok: true, file: "memory/log/2026-10-29.md", line: "- 09:00 · Deployed the site.", text: "Saved." } };
const context: ToolCallContext = {
- botId: "bot-alias", threadId: "thread-alias", depth: 0, externalRuntime: false, sharedComputers: true,
+ botId: "bot-alias", threadId: "thread-alias", externalRuntime: false, sharedComputers: true,
client: {
api: async (path, init) => { sent.push({ path, body: init?.body }); return answer.body; },
apiResponse: async (path, init) => { sent.push({ path, body: init?.body }); return answer; },
diff --git a/server/drivers/agents-bridge-chat.test.ts b/server/drivers/agents-bridge-chat.test.ts
index 8f18bdaff3..a28a560f43 100644
--- a/server/drivers/agents-bridge-chat.test.ts
+++ b/server/drivers/agents-bridge-chat.test.ts
@@ -74,7 +74,7 @@ it("a bridged turn on the chat-completions runtime carries on after use_tool nam
const agents: NonNullable<SendTurnInput["integrations"]>["agents"] = {
command: process.execPath,
args: [join(dirname(fileURLToPath(import.meta.url)), "agents-proxy.ts")],
- env: { OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-chat", OMB_THREAD_ID: "thread-chat", OMB_COMMS_TOKEN: "unused", OMB_TURN_DEPTH: "0", [TOOL_BRIDGE_ENV]: "1" },
+ env: { OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-chat", OMB_THREAD_ID: "thread-chat", OMB_COMMS_TOKEN: "unused", [TOOL_BRIDGE_ENV]: "1" },
};
const threadId = randomUUID();
await instance.adapter.sendTurn({ threadId, text: "Schedule my morning brief.", model: "fixture-model", integrations: { agents } });
diff --git a/server/drivers/agents-bridge-wire.test.ts b/server/drivers/agents-bridge-wire.test.ts
index 9ba814978b..757ac6f254 100644
--- a/server/drivers/agents-bridge-wire.test.ts
+++ b/server/drivers/agents-bridge-wire.test.ts
@@ -125,7 +125,7 @@ async function proxyLines(entry: string, env: Record<string, string>, requests:
// OMB_* switches of its own; the profile must be the only source.
const inherited = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith("OMB_")));
const child = spawn(process.execPath, [entry], {
- env: { ...inherited, OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-golden", OMB_THREAD_ID: "thread-golden", OMB_COMMS_TOKEN: "unused", OMB_TURN_DEPTH: "0", ...env },
+ env: { ...inherited, OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-golden", OMB_THREAD_ID: "thread-golden", OMB_COMMS_TOKEN: "unused", ...env },
stdio: ["pipe", "pipe", "inherit"],
});
try {
diff --git a/server/drivers/agents-call-cards.test.ts b/server/drivers/agents-call-cards.test.ts
index 605077208d..50f40dec4b 100644
--- a/server/drivers/agents-call-cards.test.ts
+++ b/server/drivers/agents-call-cards.test.ts
@@ -10,7 +10,7 @@ const PROFILE: CatalogProfile = { skillAuthoring: false, sharedComputers: false,
function harness(answer: { ok: boolean; status: number; body: Record<string, unknown> } = { ok: true, status: 201, body: { messageId: "m42" } }) {
const api = vi.fn<HarnessClient["api"]>(async () => ({}));
const apiResponse = vi.fn<HarnessClient["apiResponse"]>(async () => answer);
- const context: ToolCallContext = { botId: "bot-scout", threadId: "thread-scout", depth: 0, externalRuntime: false, sharedComputers: false, client: { api, apiResponse } };
+ const context: ToolCallContext = { botId: "bot-scout", threadId: "thread-scout", externalRuntime: false, sharedComputers: false, client: { api, apiResponse } };
return { api, apiResponse, context };
}
diff --git a/server/drivers/agents-call-triggers.test.ts b/server/drivers/agents-call-triggers.test.ts
index 566bf3712a..d0e811ac7f 100644
--- a/server/drivers/agents-call-triggers.test.ts
+++ b/server/drivers/agents-call-triggers.test.ts
@@ -11,7 +11,7 @@ function context(answers: { api?: unknown; response?: { ok: boolean; status: num
return answers.response ?? { ok: true, status: 201, body: { resultId: "t-1", summary: "When an email arrives in Gmail from acme.com, Scout follows: Draft." } };
},
};
- return { calls, context: { botId: "scout", threadId: "thread-1", depth: 0, externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
+ return { calls, context: { botId: "scout", threadId: "thread-1", externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
}
describe("app events in the trigger tools", () => {
diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.ts
index aeb451db8a..b64e51f9b2 100644
--- a/server/drivers/agents-call.test.ts
+++ b/server/drivers/agents-call.test.ts
@@ -10,7 +10,6 @@ function context(overrides: Partial<ToolCallContext> = {}): ToolCallContext {
return {
botId: "bot-voice",
threadId: "thread-voice",
- depth: 0,
externalRuntime: false,
sharedComputers: false,
client: {
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.ts
index e6f93d48ae..474f84216f 100644
--- a/server/drivers/agents-call.ts
+++ b/server/drivers/agents-call.ts
@@ -35,7 +35,6 @@ import { callDevsTool, DEVS_TOOL_NAMES } from "./agents-devs-tools.ts";
export interface ToolCallContext {
botId: string;
threadId: string;
- depth: number;
/** A standing external runtime: its capability cannot reach the result cache, so big results are cut. */
externalRuntime: boolean;
// Presentation only: the server still authenticates and scopes every call.
@@ -54,7 +53,6 @@ export function toolCallContextFromEnv(env: NodeJS.ProcessEnv): ToolCallContext
return {
botId: profile.botId,
threadId: env.OMB_THREAD_ID ?? "",
- depth: Number(env.OMB_TURN_DEPTH ?? "0") || 0,
externalRuntime: env.OMB_EXTERNAL_RUNTIME === "1",
sharedComputers: profile.sharedComputers,
client: harnessClientFromEnv(env),
@@ -219,7 +217,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon
const refused = outOfBounds(name, fullInputSchema(name), args);
if (refused) return { text: refused, isError: true };
const member = agentsCallMember(name, args);
- const { botId: BOT_ID, threadId: THREAD_ID, depth: DEPTH } = context;
+ const { botId: BOT_ID, threadId: THREAD_ID } = context;
const { api, apiResponse } = context.client;
if (name === "vm_exec") {
const { ok, body } = await apiResponse("/api/internal/vm-exec", {
@@ -453,7 +451,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon
if (!title || !message) return { text: "start_thread needs title (one short line) and message (the complete first message).", isError: true };
const toBotId = typeof args.bot_id === "string" ? args.bot_id.trim() : "";
const folder = typeof args.folder === "string" ? args.folder.trim() : "";
- const body: Record<string, unknown> = { fromBotId: BOT_ID, fromThreadId: THREAD_ID, title, message, depth: DEPTH };
+ const body: Record<string, unknown> = { fromBotId: BOT_ID, fromThreadId: THREAD_ID, title, message };
if (toBotId) body.toBotId = toBotId;
if (folder) body.folder = folder;
if (args.model_selection !== undefined) {
diff --git a/server/drivers/agents-catalog-wire.test.ts b/server/drivers/agents-catalog-wire.test.ts
index 0578e52529..880b31187e 100644
--- a/server/drivers/agents-catalog-wire.test.ts
+++ b/server/drivers/agents-catalog-wire.test.ts
@@ -124,7 +124,7 @@ async function toolsListWire(entry: string, env: Record<string, string>): Promis
// A developer shell or an OpenMausBot turn can carry OMB_* switches; the profile must be the only source.
const inherited = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith("OMB_")));
const child = spawn(process.execPath, [entry], {
- env: { ...inherited, OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-golden", OMB_THREAD_ID: "thread-golden", OMB_COMMS_TOKEN: "unused", OMB_TURN_DEPTH: "0", ...env },
+ env: { ...inherited, OMB_HARNESS_URL: "http://127.0.0.1:9", OMB_BOT_ID: "bot-golden", OMB_THREAD_ID: "thread-golden", OMB_COMMS_TOKEN: "unused", ...env },
stdio: ["pipe", "pipe", "inherit"],
});
try {
diff --git a/server/drivers/agents-mcp-env.ts b/server/drivers/agents-mcp-env.ts
index f79c381e6e..3d68f0f86c 100644
--- a/server/drivers/agents-mcp-env.ts
+++ b/server/drivers/agents-mcp-env.ts
@@ -2,6 +2,6 @@ import { TOOL_BRIDGE_ENV } from "./agents-bridge.ts";
import { TOOL_LIMIT_ENV } from "../tool-count-limit.ts";
/** The settings the harness gives the agents MCP server, and the only ones a request may carry over HTTP. */
-export const AGENTS_MCP_ENV = ["OMB_BOT_ID", "OMB_THREAD_ID", "OMB_TURN_DEPTH", "OMB_EXTERNAL_RUNTIME", "OMB_CHIEF_OF_STAFF",
+export const AGENTS_MCP_ENV = ["OMB_BOT_ID", "OMB_THREAD_ID", "OMB_EXTERNAL_RUNTIME", "OMB_CHIEF_OF_STAFF",
"OMB_SKILL_AUTHORING_ENABLED", "OMB_MEMORY_ENABLED", "OMB_SHARED_COMPUTERS_ENABLED", "OMB_CLOUD_HOME", "OMB_VOICE_NOTES",
"OMB_X_RESEARCH", "OMB_RESEARCH", "OMB_TEAM_PEOPLE", "OMB_MAUSBOT", "OMB_COMPUTER_SELECTION", "OMB_ROOM", "OMB_IMAGE_GENERATION", "OMB_MEETINGS", "OMB_APP_HOSTING", TOOL_BRIDGE_ENV, TOOL_LIMIT_ENV] as const;
diff --git a/server/drivers/agents-options-card.test.ts b/server/drivers/agents-options-card.test.ts
index cfa2909cbc..dccbdebac2 100644
--- a/server/drivers/agents-options-card.test.ts
+++ b/server/drivers/agents-options-card.test.ts
@@ -20,7 +20,6 @@ function context(overrides: Partial<ToolCallContext> = {}): ToolCallContext {
return {
botId: WATCHER_OPTIONS_CARD_BOT_ID,
threadId: "thread-watcher",
- depth: 0,
externalRuntime: false,
sharedComputers: false,
client: {
diff --git a/server/drivers/agents-proxy.test.ts b/server/drivers/agents-proxy.test.ts
index dd18f69c4f..b2e4c34564 100644
--- a/server/drivers/agents-proxy.test.ts
+++ b/server/drivers/agents-proxy.test.ts
@@ -470,7 +470,6 @@ beforeAll(async () => {
OMB_BOT_ID: "bot-asker",
OMB_THREAD_ID: "thread-asker-routine",
OMB_COMMS_TOKEN: TOKEN,
- OMB_TURN_DEPTH: "0",
OMB_SKILL_AUTHORING_ENABLED: "1",
OMB_SHARED_COMPUTERS_ENABLED: "1",
// A Chief's turn, so the Chief-only team tools are mounted too.
@@ -1001,7 +1000,7 @@ describe("agents-proxy MCP surface", () => {
expect(text).toContain("do not check or wait for it in this turn");
expect(text).not.toMatch(/Deprecated|alias/);
expect(lastThreadBody).toEqual({
- fromBotId: "bot-asker", fromThreadId: "thread-asker-routine", title: "QA: PR #9", message: "Review the login fix.", depth: 0, toBotId: "bot-helper",
+ fromBotId: "bot-asker", fromThreadId: "thread-asker-routine", title: "QA: PR #9", message: "Review the login fix.", toBotId: "bot-helper",
});
} finally {
threadResponse = previous;
@@ -1030,7 +1029,7 @@ describe("agents-proxy MCP surface", () => {
expect(text).toContain("its result comes back to this conversation and resumes you automatically (assignment id: asg-own-1)");
expect(text).toContain("finish your turn");
expect(lastThreadBody).toEqual({ fromBotId: "bot-asker", fromThreadId: "thread-asker-routine", title: "Review: GPT", message: "Review the diff.",
- depth: 0, modelSelection, reportBack: true });
+ modelSelection, reportBack: true });
} finally {
threadResponse = previous;
}
@@ -1047,7 +1046,6 @@ describe("agents-proxy MCP surface", () => {
fromThreadId: "thread-asker-routine",
title: "QA: PR #1",
message: "Review the login fix.",
- depth: 0,
});
threadResponse = { threadId: "thread-two", title: "QA: PR #2", botId: "bot-asker", botName: "Asker", self: true, state: "queued", position: 2, limit: 3 };
const queued = await callTool("start_thread", { title: "QA: PR #2", message: "Review the signup fix.", folder: "QA" });
@@ -2217,7 +2215,7 @@ describe("standing external runtime", () => {
beforeAll(async () => {
external = spawn(process.execPath, [PROXY], {
env: { ...childEnv(), OMB_HARNESS_URL: `http://127.0.0.1:${stubPort}`, OMB_BOT_ID: "bot-asker",
- OMB_THREAD_ID: "thread-asker-routine", OMB_COMMS_TOKEN: TOKEN, OMB_TURN_DEPTH: "0",
+ OMB_THREAD_ID: "thread-asker-routine", OMB_COMMS_TOKEN: TOKEN,
OMB_EXTERNAL_RUNTIME: "1", OMB_ROOM_TURN: "1", OMB_OWN_THREAD_CREATION: "1",
OMB_SKILL_AUTHORING_ENABLED: "1", OMB_SHARED_COMPUTERS_ENABLED: "1" },
stdio: ["pipe", "pipe", "inherit"],
@@ -2315,7 +2313,6 @@ describe("with computer sharing off and no Chief of Staff (the defaults)", () =>
OMB_BOT_ID: "bot-asker",
OMB_THREAD_ID: "thread-asker-routine",
OMB_COMMS_TOKEN: TOKEN,
- OMB_TURN_DEPTH: "0",
OMB_SKILL_AUTHORING_ENABLED: "1",
// deliberately no OMB_SHARED_COMPUTERS_ENABLED or OMB_CHIEF_OF_STAFF
},
@@ -2467,7 +2464,7 @@ describe("tool bridge", () => {
const proxy = spawn(process.execPath, [PROXY], {
env: {
...childEnv(), TZ: "Asia/Kolkata", OMB_HARNESS_URL: `http://127.0.0.1:${stubPort}`, OMB_BOT_ID: "bot-asker",
- OMB_THREAD_ID: "thread-asker-routine", OMB_COMMS_TOKEN: TOKEN, OMB_TURN_DEPTH: "0", ...env,
+ OMB_THREAD_ID: "thread-asker-routine", OMB_COMMS_TOKEN: TOKEN, ...env,
},
stdio: ["pipe", "pipe", "inherit"],
});
diff --git a/server/drivers/agents-proxy.ts b/server/drivers/agents-proxy.ts
index c326eadee4..48956db550 100644
--- a/server/drivers/agents-proxy.ts
+++ b/server/drivers/agents-proxy.ts
@@ -3,7 +3,6 @@
// OMB_HARNESS_URL base URL of the harness (http://127.0.0.1:8799)
// OMB_BOT_ID the calling bot's id
// OMB_COMMS_TOKEN shared secret for the localhost-only internal endpoints
-// OMB_TURN_DEPTH this turn's comms depth (the harness refuses recursion)
// OMB_EXTERNAL_RUNTIME "1" for a standing process: oversized results are cut instead of cached
// OMB_CHIEF_OF_STAFF "1" for a Chief of Staff, the only bot shown the Chief-only tools
// OMB_MAUSBOT "1" for the person's MausBot, the only bot shown its notification tools
diff --git a/server/drivers/agents-schema.test.ts b/server/drivers/agents-schema.test.ts
index 1d628c0d40..0a7e4fb9f4 100644
--- a/server/drivers/agents-schema.test.ts
+++ b/server/drivers/agents-schema.test.ts
@@ -75,7 +75,7 @@ function recordingContext(): { context: ToolCallContext; calls: string[] } {
return {
calls,
context: {
- botId: "bot-schema", threadId: "thread-schema", depth: 0, externalRuntime: false, sharedComputers: true,
+ botId: "bot-schema", threadId: "thread-schema", externalRuntime: false, sharedComputers: true,
client: {
api: async (path) => { calls.push(path); return {}; },
apiResponse: async (path) => { calls.push(path); return { ok: true, status: 200, body: {} }; },
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.ts
index 5da7ec53d6..5b0e083248 100644
--- a/server/drivers/claude.test.ts
+++ b/server/drivers/claude.test.ts
@@ -1339,7 +1339,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
agents: {
command: process.execPath,
args: ["/fake/agents-proxy.js"],
- env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_BOT_ID: "b1", OMB_COMMS_TOKEN: "tok", OMB_TURN_DEPTH: "0" },
+ env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_BOT_ID: "b1", OMB_COMMS_TOKEN: "tok" },
},
},
});
@@ -2624,7 +2624,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
agents: {
command: process.execPath,
args: ["/fake/agents-proxy.js"],
- env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_BOT_ID: "b1", OMB_COMMS_TOKEN: "tok", OMB_TURN_DEPTH: "0" },
+ env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_BOT_ID: "b1", OMB_COMMS_TOKEN: "tok" },
},
},
});
diff --git a/server/drivers/codex.test.ts b/server/drivers/codex.test.ts
index dd6763043a..a076b13341 100644
--- a/server/drivers/codex.test.ts
+++ b/server/drivers/codex.test.ts
@@ -1962,7 +1962,6 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)
OMB_BOT_ID: "captain",
OMB_THREAD_ID: "t-agents",
OMB_COMMS_TOKEN: "peer-comms-secret",
- OMB_TURN_DEPTH: "0",
},
},
},
diff --git a/server/host/room-sessions.test.ts b/server/host/room-sessions.test.ts
index ff10b0155b..186e0ca13c 100644
--- a/server/host/room-sessions.test.ts
+++ b/server/host/room-sessions.test.ts
@@ -567,7 +567,7 @@ describe("room sessions: when a record is not trusted", () => {
});
it("starts again when anything in its standing configuration changed", () => {
- const base = ["You are Editor, a bot in the room \"Edit bay\".", "/work", { instanceId: "claude", model: "opus", effort: "high" }, "ask", { agents: { env: { OMB_TURN_DEPTH: "0" } } }];
+ const base = ["You are Editor, a bot in the room \"Edit bay\".", "/work", { instanceId: "claude", model: "opus", effort: "high" }, "ask", { agents: { env: { OMB_SKILL_AUTHORING_ENABLED: "0" } } }];
const changes: unknown[][] = [
["You are Editor, a bot in the room \"Cutting room\".", ...base.slice(1)],
[base[0], "/elsewhere", ...base.slice(2)],
@@ -575,7 +575,7 @@ describe("room sessions: when a record is not trusted", () => {
[...base.slice(0, 2), { instanceId: "claude", model: "opus", effort: "low" }, ...base.slice(3)],
[...base.slice(0, 2), { instanceId: "claude", model: "opus", effort: "high", variant: "1m" }, ...base.slice(3)],
[...base.slice(0, 3), "full", base[4]],
- [...base.slice(0, 4), { agents: { env: { OMB_TURN_DEPTH: "1" } } }],
+ [...base.slice(0, 4), { agents: { env: { OMB_SKILL_AUTHORING_ENABLED: "1" } } }],
[...base, "one more"],
];
for (const changed of changes) {
diff --git a/server/index.ts b/server/index.ts
index 51aae5d10d..b128b835fd 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -1681,9 +1681,11 @@ function beginInternalCapabilityGeneration(threadId: string, generation = random
}
// The bearer is part of the engine's launch contract, so it stays stable per bot, thread and grants; the record behind it is per turn and honoured only during one.
+// Security invariant: a turn's depth, the hand-off it runs for and whether it may author skills are read from that record on every call, never
+// from the engine, so a person's message and a teammate's report keep one bearer.
const sessionCredentials = new Map<string, Map<string, { grants: string; token: string }>>();
-function sessionGrants({ generation: _turn, ...grants }: Omit<InternalCapability, "orphanExpiresAt">): string {
+function sessionGrants({ generation: _turn, depth: _depth, roomHandoffId: _handoff, skillAuthoring: _skills, ...grants }: Omit<InternalCapability, "orphanExpiresAt">): string {
const thread = botForThread(grants.botId, grants.threadId);
return JSON.stringify({ ...grants, approval: thread ? approvalModeFor(thread) : null });
}
@@ -13998,12 +14000,6 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
const fromThreadId = internalCapability.threadId;
const owner = connectorThread(from.id, fromThreadId);
if (!owner) return json(res, 403, { error: "source conversation does not belong to sender" }); if (outsideWorkStaysHere(fromThreadId)) return json(res, 403, { error: "This work came in from outside, so it can't open a new thread. Finish it here." });
- if (
- body.depth !== undefined &&
- (!Number.isInteger(body.depth) || body.depth < 0 || body.depth !== internalCapability.depth)
- ) {
- return json(res, 403, { error: "the recursion depth does not match this turn" });
- }
const title = String(body.title ?? "").trim();
const message = String(body.message ?? "").trim();
if (!title || !message) return json(res, 400, { error: "title and message are required" });
diff --git a/server/limit-reset-requests.test.ts b/server/limit-reset-requests.test.ts
index a9468b5bcb..289bb6fc87 100644
--- a/server/limit-reset-requests.test.ts
+++ b/server/limit-reset-requests.test.ts
@@ -60,7 +60,7 @@ describe("create_trigger when=limit_reset", () => {
return { ok: true, status: 201, body: { resultId: "r-1", summary: "When Claude's usage limit resets" } };
},
};
- return { calls, context: { botId: "scout", threadId: "thread-1", depth: 0, externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
+ return { calls, context: { botId: "scout", threadId: "thread-1", externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
}
it("sends a limit-reset schedule for the bot's own engine unless it names one", async () => {
diff --git a/server/room-coordination.e2e.test.ts b/server/room-coordination.e2e.test.ts
index 953b4f19fe..15e1bdc0ee 100644
--- a/server/room-coordination.e2e.test.ts
+++ b/server/room-coordination.e2e.test.ts
@@ -1,5 +1,5 @@
import { spawn, type ChildProcess } from "node:child_process";
-import { closeSync, openSync, readFileSync, writeFileSync } from "node:fs";
+import { closeSync, openSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { expect, it } from "vitest";
@@ -91,6 +91,19 @@ it("coordinates in a room that mixes departments, with a Chief that manages none
expect(children.every((node: any) => node.status === "completed" && node.groupId === f.source.id)).toBe(true);
}), 45_000);
+it("keeps each member's engine through hand-offs between rooms and the person's next messages", () => withRooms(async f => {
+ await f.start(); expect((await f.wait()).status).toBe("settled");
+ for (const round of [2, 3, 4]) {
+ await f.cli("send-channel", "--channel", f.source.id, "--text", `@Director Next assignment ${round}`);
+ expect((await f.wait()).status).toBe("settled");
+ }
+ const native = join(f.session.info.dataDir, "native");
+ const closes = readdirSync(native).flatMap((file) => readFileSync(join(native, file), "utf8").split("\n").filter(Boolean)
+ .map((line) => JSON.parse(line)).filter((row) => row.source === "claude.session" && row.msg?.close).map((row) => row.msg));
+ expect(closes).toEqual([]);
+ expect(f.handoffs().filter((node: any) => node.botId === f.target.id).map((node: any) => node.status)).toEqual(["completed", "completed", "completed", "completed"]);
+}), 90_000);
+
it("runs room-destined work in the room's own conversation, opening no thread on the recipient", () => withRooms(async f => {
const tasksOf = async (botId: string) => (await f.api("/api/bots")).bots.find((bot: any) => bot.id === botId).tasks ?? [];
const before = await tasksOf(f.target.id);
diff --git a/server/webhook-payload-filter.test.ts b/server/webhook-payload-filter.test.ts
index 50a81aea7e..6d415d3095 100644
--- a/server/webhook-payload-filter.test.ts
+++ b/server/webhook-payload-filter.test.ts
@@ -89,7 +89,7 @@ describe("webhook_payload_filter in the trigger tool", () => {
return { ok: true, status: 201, body: { resultId: "t-1", summary: "When another app sends something, Scout follows: Answer." } };
},
};
- return { calls, context: { botId: "scout", threadId: "thread-1", depth: 0, externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
+ return { calls, context: { botId: "scout", threadId: "thread-1", externalRuntime: false, sharedComputers: false, client } as unknown as ToolCallContext };
}
it("sends the filter on a webhook create and update", async () => {