Multiplayer agent harness for work.
Fix live Slack catalog setup and sandbox startup latency (#1712)
Joshua France715dea0b5185
diff --git a/cli/src/backends/dev-ci.ts b/cli/src/backends/dev-ci.tsindex 20634833c..227413dcb 100644--- a/cli/src/backends/dev-ci.ts+++ b/cli/src/backends/dev-ci.ts@@ -1,7 +1,7 @@import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";import { basename, join } from "node:path";import { die, note, ok } from "../log.ts";-import { envNum, gitTopLevel, spawnBackground, stopPid, tail, waitForLog, which } from "../util.ts";+import { envNum, gitTopLevel, runInherit, spawnBackground, stopPid, tail, waitForLog, which } from "../util.ts";import { serviceDef } from "../services.ts";const ciDir = (root: string): string => join(root, process.env.CI_INSTANCE_DIR ?? ".ci-instance");@@ -58,6 +58,7 @@ export async function devCiUp(): Promise<void> {const root = gitTopLevel();requireEnv();requireDeps(root);+ runInherit("npm", ["run", "build:connector-sdk"], { cwd: root });const dir = ciDir(root);mkdirSync(dir, { recursive: true });diff --git a/cli/test/dev-ci-routing.test.ts b/cli/test/dev-ci-routing.test.tsindex 8bb4771a5..226c6b049 100644--- a/cli/test/dev-ci-routing.test.ts+++ b/cli/test/dev-ci-routing.test.ts@@ -1,7 +1,7 @@import { test } from "node:test";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";-import { mkdtempSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";@@ -10,16 +10,18 @@ const cliDir = join(dirname(fileURLToPath(import.meta.url)), "..");const bin = join(cliDir, "bin", "qm.ts");function runCli(args: string[]): { code: number; stderr: string; stdout: string } {+ const root = mkdtempSync(join(tmpdir(), "qm-ci-routing-"));+ execFileSync("git", ["init", "--quiet", root]);const env = {...process.env,SLACK_BOT_TOKEN: "",QM_DEV_WAIT: "0",- QM_POOL_STORE: mkdtempSync(join(tmpdir(), "qm-pool-")),+ QM_POOL_STORE: join(root, "pool"),};try {const stdout = execFileSync(process.execPath, [bin, ...args], {encoding: "utf8",- cwd: cliDir,+ cwd: root,env,timeout: 20000,stdio: ["ignore", "pipe", "pipe"],@@ -28,6 +30,8 @@ function runCli(args: string[]): { code: number; stderr: string; stdout: string} catch (e) {const err = e as { status?: number; stdout?: string; stderr?: string };return { code: err.status ?? 1, stdout: err.stdout ?? "", stderr: err.stderr ?? "" };+ } finally {+ rmSync(root, { recursive: true, force: true });}}@@ -55,3 +59,35 @@ test("'dev --ci=down' routes to CI teardown (no pool lease)", () => {assert.equal(r.code, 0);assert.match(r.stdout, /ci instance down|nothing to tear down/);});++test("CI startup builds the connector SDK and stops before spawning services if the build fails", (t) => {+ const root = mkdtempSync(join(tmpdir(), "qm-ci-build-"));+ t.after(() => rmSync(root, { recursive: true, force: true }));+ execFileSync("git", ["init", "--quiet", root]);+ mkdirSync(join(root, "node_modules"));+ mkdirSync(join(root, "bin"));+ writeFileSync(+ join(root, "bin", "npm"),+ '#!/bin/sh\n[ "$1" = run ] && [ "$2" = build:connector-sdk ] || exit 1\necho "SDK build failed" >&2\nexit 7\n',+ { mode: 0o755 },+ );+ assert.throws(+ () =>+ execFileSync(process.execPath, [bin, "dev", "--ci", "up"], {+ cwd: root,+ encoding: "utf8",+ stdio: "pipe",+ timeout: 10_000,+ env: {+ PATH: `${join(root, "bin")}:${process.env.PATH}`,+ SLACK_BOT_TOKEN: "xoxb-test",+ SLACK_APP_TOKEN: "xapp-test",+ ANTHROPIC_API_KEY: "test",+ CORE_SIGNING_SECRET: "test",+ CI_INSTANCE_READY_TIMEOUT: "1",+ },+ }),+ (error: unknown) => /SDK build failed/.test(String((error as { stderr?: string }).stderr)),+ );+ assert.equal(existsSync(join(root, ".ci-instance")), false);+});diff --git a/deploy/connector-sdk/build.mjs b/deploy/connector-sdk/build.mjsindex b6e0470c9..fae37541c 100644--- a/deploy/connector-sdk/build.mjs+++ b/deploy/connector-sdk/build.mjs@@ -3,6 +3,7 @@ import { mkdir, writeFile, readdir, readFile } from "node:fs/promises";import { fileURLToPath } from "node:url";import { resolve } from "node:path";import { createHash } from "node:crypto";+import { createRequire } from "node:module";const root = fileURLToPath(new URL(".", import.meta.url));const output = process.argv[2]@@ -22,6 +23,8 @@ const data = result.outputFiles[0].contents;const sha = createHash("sha256").update(data).digest("hex");await mkdir(output, { recursive: true });await writeFile(`${output}/sdk.cjs`, data);+if (typeof createRequire(import.meta.url)(`${output}/sdk.cjs`).Composio !== "function")+ throw new Error("Connector SDK bundle does not export Composio");await writeFile(`${output}/sha256`, `${sha}\n`);console.log(`Connector SDK: ${data.length} bytes, sha256 ${sha}`);diff --git a/src/sandbox/connector-sdk.ts b/src/sandbox/connector-sdk.tsindex 5dd055612..d4a3f2147 100644--- a/src/sandbox/connector-sdk.ts+++ b/src/sandbox/connector-sdk.ts@@ -46,33 +46,31 @@ export async function installConnectorSdk(const current = `${root}/current`;const nonce = randomUUID();const link = `${root}/.link-${nonce}`;+ const stage = `${root}/.stage-${nonce}`;const baked = "/opt/qm/composio";const probe = (dir: string) => `printf '%s\\n' ${shq(`${bundle.sha} ${dir}/sdk.cjs`)} | sha256sum -c --status`;- const activate = (dir: string) =>- `node -e ${shq(`const fs = require('node:fs'); fs.symlinkSync(${JSON.stringify(dir)}, ${JSON.stringify(link)}); fs.renameSync(${JSON.stringify(link)}, ${JSON.stringify(current)});`)}`;- const result = await io.exec(- `mkdir -p ${shq(root)} && { if ${probe(current)}; then exit 0; fi; if ${probe(baked)}; then ${activate(baked)}; elif ${probe(target)}; then ${activate(target)}; else exit 44; fi; }`,- 60,- );- if (result.code === 0) return;- if (result.code !== 44) throw new Error(`Connector SDK probe failed (rc=${result.code})`);- const stage = `${root}/.stage-${nonce}`;+ const activate = (dir: string) => `ln -s ${shq(dir)} ${shq(link)} && mv -Tf ${shq(link)} ${shq(current)}`;try {- const prep = await io.exec(`mkdir -p ${shq(stage)} ${shq(target)}`, 60);- if (prep.code !== 0) throw new Error(`Connector SDK staging failed (rc=${prep.code})`);+ const result = await io.exec(+ `mkdir -p ${shq(root)} && { if ${probe(current)}; then exit 0; fi; if ${probe(baked)}; then ${activate(baked)}; elif ${probe(target)}; then ${activate(target)}; else mkdir -p ${shq(stage)} ${shq(target)} && exit 44; fi; }`,+ 60,+ );+ if (result.code === 0) return;+ if (result.code !== 44) throw new Error(`Connector SDK probe failed (rc=${result.code})`);await io.writeAbs(`${stage}/sdk.cjs`, bundle.sdk);await io.writeAbs(`${stage}/LICENSES.txt`, bundle.licenses);const commit = await io.exec(- `${probe(stage)} && node -e ${shq(`if(typeof require(${JSON.stringify(`${stage}/sdk.cjs`)}).Composio !== 'function') process.exit(1)`)} && chmod 0644 ${shq(stage)}/sdk.cjs ${shq(stage)}/LICENSES.txt && mv -f ${shq(stage)}/LICENSES.txt ${shq(target)}/LICENSES.txt && mv -f ${shq(stage)}/sdk.cjs ${shq(target)}/sdk.cjs && ${activate(target)} && ${probe(current)}`,+ `${probe(stage)} && chmod 0644 ${shq(stage)}/sdk.cjs ${shq(stage)}/LICENSES.txt && mv -f ${shq(stage)}/LICENSES.txt ${shq(target)}/LICENSES.txt && mv -f ${shq(stage)}/sdk.cjs ${shq(target)}/sdk.cjs && ${activate(target)} && ${probe(current)} && rmdir ${shq(stage)}`,60,);if (commit.code !== 0) throw new Error(`Connector SDK installation failed (rc=${commit.code})`);- } finally {+ } catch (error) {await io.exec(`rm -f ${shq(stage)}/sdk.cjs ${shq(stage)}/LICENSES.txt ${shq(link)}; rmdir ${shq(stage)} 2>/dev/null || true`,60,).catch(() => {});+ throw error;}}diff --git a/test/connector-sdk.test.ts b/test/connector-sdk.test.tsindex b2f302b72..84ffbeebc 100644--- a/test/connector-sdk.test.ts+++ b/test/connector-sdk.test.ts@@ -3,7 +3,7 @@ import assert from "node:assert/strict";import { createHash } from "node:crypto";import { execFile } from "node:child_process";import { promisify } from "node:util";-import { mkdtemp, readFile, rm, writeFile, mkdir, symlink } from "node:fs/promises";+import { mkdtemp, readFile, readdir, rm, writeFile, mkdir, symlink } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";import { createServer } from "node:http";@@ -19,6 +19,7 @@ async function localIo(t: TestContext) {await mkdir(bin);if (process.platform === "darwin") {await symlink((await exec("which", ["gsha256sum"])).stdout.trim(), join(bin, "sha256sum"));+ await symlink((await exec("which", ["gmv"])).stdout.trim(), join(bin, "mv"));}let writes = 0;const io: LayerToolInstallIo = {@@ -39,7 +40,7 @@ async function localIo(t: TestContext) {await writeFile(path, data);},};- return { home, io, writes: () => writes };+ return { home, bin, io, writes: () => writes };}const fixture = () => {@@ -47,6 +48,34 @@ const fixture = () => {return { sdk, sha: createHash("sha256").update(sdk).digest("hex"), licenses: Buffer.from("license") };};+test("SDK installation verifies and activates bytes without starting Node", async (t) => {+ const { home, bin, io } = await localIo(t);+ await writeFile(join(bin, "node"), "#!/bin/sh\nexit 91\n", { mode: 0o755 });+ const bundle = fixture();+ await installConnectorSdk(io, home, bundle);+ assert.deepEqual(await readFile(`${home}/.qm/composio/current/sdk.cjs`), bundle.sdk);+});++test("SDK installation cleans staging after a lost preparation response", async (t) => {+ const { home, io } = await localIo(t);+ await assert.rejects(+ installConnectorSdk(+ {+ ...io,+ async exec(script, timeoutSec) {+ const result = await io.exec(script, timeoutSec);+ if (result.code === 44) throw new Error("connection lost after preparation");+ return result;+ },+ },+ home,+ fixture(),+ ),+ /connection lost/,+ );+ assert.ok((await readdir(`${home}/.qm/composio`)).every((name) => !name.startsWith(".")));+});+test("concurrent installation activates complete bytes and subsequent provision does not upload", async (t) => {const { home, io, writes } = await localIo(t);const bundle = fixture();diff --git a/test/live-slack-catalog.test.ts b/test/live-slack-catalog.test.tsnew file mode 100644index 000000000..4356e3deb--- /dev/null+++ b/test/live-slack-catalog.test.ts@@ -0,0 +1,169 @@+import assert from "node:assert/strict";+import test from "node:test";+import { setImmediate } from "node:timers/promises";+import { Ctx, type Env } from "./live-slack/harness.ts";+import { SlackClient, type SlackMessage } from "./live-slack/slack.ts";+import { scenarios } from "./live-slack/scenarios.ts";++function context(name: string) {+ const scenario = scenarios.find((item) => item.name === name)!;+ const qa = new SlackClient("test", "http://127.0.0.1");+ qa.createChannel = async () => "CHANNEL";+ qa.invite = async () => {};+ qa.post = async () => "1";+ qa.getPermalink = async () => "https://example.test/message";+ const env = {+ qa,+ botUserId: "BOT",+ runId: "catalog",+ targetChannel: "CTARGET123",+ actors: new Map([["alice", { name: "alice", client: qa, userId: "ALICE" }]]),+ } as Env;+ return { scenario, qa, ctx: new Ctx(env, scenario, 1) };+}++test("channel-audience check sees broadcasts but still rejects a missing marker", async (t) => {+ t.mock.timers.enable({ apis: ["Date", "setTimeout"], now: 100_000 });+ const { scenario, qa, ctx } = context("mu-audience-answer-in-channel");+ qa.replies = async () => [];+ qa.history = async () => [+ { ts: "2", user: "BOT", text: "Monday" },+ { ts: "3", user: "OTHER", text: ctx.marker() },+ { ts: "4", thread_ts: "unrelated", user: "BOT", text: ctx.marker() },+ ...(Date.now() >= 110_000 ? [{ ts: "5", thread_ts: "5", user: "BOT", text: `Monday ${ctx.marker()}` }] : []),+ ];+ let settled = false;+ let failure: unknown;+ const result = scenario.run(ctx).then(+ () => {+ settled = true;+ },+ (error) => {+ settled = true;+ failure = error;+ },+ );+ await setImmediate();+ for (let i = 0; i < 3; i++) {+ t.mock.timers.tick(2500);+ await setImmediate();+ }+ assert.equal(settled, false);+ for (let i = 0; i < 100 && !settled; i++) {+ t.mock.timers.tick(2500);+ await setImmediate();+ }+ await result;+ assert.ifError(failure);+ assert.equal(ctx.timeline.botMessages().at(-1)?.ts, "5");+});++for (const progress of ["reaction", "acknowledgment", "other-user-reaction", "late-acknowledgment", "none"]) {+ test(`long task progress: ${progress}`, async (t) => {+ t.mock.timers.enable({ apis: ["Date", "setTimeout"], now: 100_000 });+ const { scenario, qa, ctx } = context("long-task-streaming");+ qa.replies = async () =>+ [+ {+ ts: "1",+ user: "QA",+ reactions: progress.includes("reaction")+ ? [{ name: "eyes", users: [progress === "reaction" ? "BOT" : "OTHER"] }]+ : [],+ },+ ...(progress === "acknowledgment" ? [{ ts: "2", user: "BOT", text: "I'll explain how DNS works." }] : []),+ ...(Date.now() >= 102_500 ? [{ ts: "3", user: "BOT", text: "DNS ".repeat(150) }] : []),+ ...(progress === "late-acknowledgment" && Date.now() >= 105_000+ ? [{ ts: "4", user: "BOT", text: "All done." }]+ : []),+ ] as SlackMessage[];+ const run = scenario.run(ctx);+ const result =+ progress === "reaction" || progress === "acknowledgment" ? run : assert.rejects(run, /acknowledgment/);+ await setImmediate();+ for (let i = 0; i < 4; i++) {+ t.mock.timers.tick(2500);+ await setImmediate();+ }+ await result;+ });+}++for (const name of ["context-pull-cross-channel", "channel-reach"]) {+ test(`${name} names the channel actually seeded by the fixture`, async () => {+ const { scenario, ctx, qa } = context(name);+ qa.history = async () => [{ ts: "2", user: "BOT", text: ctx.marker() }];+ ctx.freshChannel = async () =>+ ({+ mention: async (text: string) => {+ assert.ok(text.includes("CTARGET123"));+ return "1";+ },+ waitForBotReply: async () => ({ text: ctx.marker("xchan") }),+ }) as never;+ await scenario.run(ctx);+ });+}++for (const [name, tool] of [+ ["execute-turn", "execute"],+ ["perf-budget", "execute"],+ ["perf-budget", "sandbox"],+]) {+ test(`${name} waits past an acknowledgment for successful ${tool} output`, async (t) => {+ t.mock.timers.enable({ apis: ["Date", "setTimeout"], now: 100_000 });+ const { scenario, qa, ctx } = context(name!);+ const output = name === "execute-turn" ? "Linux test 6.1.0-test" : ctx.marker("executed");+ qa.replies = async () => [+ { ts: "2", user: "BOT", text: "I'll run that now." },+ ...(Date.now() >= 120_000 ? [{ ts: "3", user: "BOT", text: output }] : []),+ ];+ ctx.env.core = {+ findSessionByThread: async () => ({+ id: "session",+ entries: [+ {+ type: "tool_result",+ payload: { tool, action: "exec", code: 0, isError: false, timedOut: false, stdout: `${output}\n` },+ },+ ],+ }),+ getSession: async () => ({+ entries: Date.now() >= 130_000 ? [{ type: "assistant", payload: { workFinishedAt: 130_000 } }] : [],+ }),+ getSessionLlm: async () => {+ assert.ok(Date.now() >= 130_000, "metrics must be read after the turn finishes");+ return { requests: [{ stepGapMs: 1, gapPhases: {} }] };+ },+ } as never;+ let settled = false;+ const result = scenario.run(ctx).then(() => {+ settled = true;+ });+ await setImmediate();+ for (let i = 0; i < 3; i++) {+ t.mock.timers.tick(2500);+ await setImmediate();+ }+ assert.equal(settled, false);+ for (let i = 0; i < 12; i++) {+ t.mock.timers.tick(2500);+ await setImmediate();+ }+ await result;+ });+}++test("performance check rejects failed execution before evaluating timing", async () => {+ const { scenario, ctx } = context("perf-budget");+ ctx.freshChannel = async () =>+ ({ id: "CHANNEL", mention: async () => "1", waitForBotReply: async () => ({}) }) as never;+ ctx.env.core = {+ findSessionByThread: async () => ({+ id: "session",+ entries: [{ type: "tool_result", payload: { tool: "execute", isError: true } }],+ }),+ getSessionLlm: async () => ({ requests: [{ stepGapMs: 1, gapPhases: {} }] }),+ } as never;+ await assert.rejects(scenario.run(ctx), /successful.*execut/);+});diff --git a/test/live-slack/README.md b/test/live-slack/README.mdindex 091d9d0cb..e7c2d21f9 100644--- a/test/live-slack/README.md+++ b/test/live-slack/README.md@@ -6,7 +6,7 @@ runner — core (`SESSION_STORE=memory`) + Slack plugin in Socket Mode on a **CIpool app** (`qm dev --ci`) — then `run.ts` drives the catalog in`scenarios.ts` posting as a real example **user** (the "QA Human" account), so everymessage takes the exact path a teammate's would: classification, lazy directory push,-threads, streaming `chat.update` edits.+threading, acknowledgments, tool execution, and file delivery.## Layout@@ -20,9 +20,13 @@ threads, streaming `chat.update` edits.- `slack.ts` / `core.ts` — fetch-based Slack Web API + source-auth-signed core adminclients (transcripts via `/v1/admin/sessions`, crons via `/v1/admin/crons`).-A bot reply is **final** when its text is not a live-status frame (`⚙ Working… 12s`,-`⏳ Waiting…`, `💭 …`, trailing `▌` streaming cursor — see `src/slack/status.ts`)-and has stopped changing for 5s.+A bot reply is accepted after it has stopped changing for 5s and satisfies the+scenario's content or attachment assertion. Legacy status text is ignored.+The long-task scenario requires a bot reaction or an acknowledgment before the+substantive answer. The audience scenario accepts an answer at the channel top+level or in the original thread; the threading scenario still requires a thread reply.+The performance scenario runs alone and requires successful command execution+before evaluating its timing budgets.## Run locallydiff --git a/test/live-slack/harness.ts b/test/live-slack/harness.tsindex d38ad9763..559329dec 100644--- a/test/live-slack/harness.ts+++ b/test/live-slack/harness.ts@@ -84,6 +84,7 @@ export interface WaitOpts {accept?: (message: SlackMessage) => boolean;afterTs?: string;onFrame?: (text: string) => void;+ onMessages?: (messages: SlackMessage[]) => void;record?: (msgTs: string, text: string) => void;}@@ -99,6 +100,7 @@ async function waitForFinalBotMessage(let lastSeen = "";while (Date.now() < deadline) {const messages = await fetchMessages();+ opts.onMessages?.(messages);const fromBot = messages.filter((m) => m.user === botUserId && Number(m.ts) > Number(afterTs));for (const m of fromBot) {const text = m.text ?? "";@@ -253,9 +255,16 @@ export class ChannelHandle {return ts;}- async waitForBotReply(rootTs: string, opts: WaitOpts = {}): Promise<SlackMessage> {+ async waitForBotReply(rootTs: string, opts: WaitOpts & { includeChannel?: boolean } = {}): Promise<SlackMessage> {const msg = await waitForFinalBotMessage(- () => this.env.qa.replies(this.id, rootTs),+ async () => {+ const replies = await this.env.qa.replies(this.id, rootTs);+ if (!opts.includeChannel) return replies;+ const channel = await this.env.qa.history(this.id, rootTs);+ return [...replies, ...channel.filter((m) => !m.thread_ts || m.thread_ts === m.ts)].sort(+ (a, b) => Number(a.ts) - Number(b.ts),+ );+ },this.env.botUserId,opts.afterTs ?? rootTs,{diff --git a/test/live-slack/scenarios-multiuser.ts b/test/live-slack/scenarios-multiuser.tsindex c5b78f14e..5368a1cca 100644--- a/test/live-slack/scenarios-multiuser.ts+++ b/test/live-slack/scenarios-multiuser.ts@@ -169,8 +169,12 @@ export const multiUserScenarios: Scenario[] = [async run(ctx) {const ch = await ctx.freshChannel();const marker = ctx.marker();- const root = await ch.as(ctx.actor("alice")).mention(`what day of the week is it in London? include ${marker}.`);- const reply = await ch.waitForBotReply(root, { match: new RegExp(marker) });+ const root = await ch+ .as(ctx.actor("alice"))+ .mention(+ `What day of the week is it in London? Answer here in this channel and end your answer with the exact token ${marker}.`,+ );+ const reply = await ch.waitForBotReply(root, { match: new RegExp(marker), includeChannel: true });assert.ok(reply.text?.includes(marker),`channel answer missing marker (was it sent elsewhere?): ${reply.text?.slice(0, 160)}`,diff --git a/test/live-slack/scenarios.ts b/test/live-slack/scenarios.tsindex eccb8d1df..e9c1b5b05 100644--- a/test/live-slack/scenarios.ts+++ b/test/live-slack/scenarios.ts@@ -1,6 +1,6 @@import { readFileSync } from "node:fs";import path from "node:path";-import { assert, isLiveStatusText, type Scenario } from "./harness.ts";+import { assert, type Scenario } from "./harness.ts";import { sleep, type SlackMessage } from "./slack.ts";import { assertRuntimeHandoff } from "./runtime-handoff.ts";import { multiUserScenarios } from "./scenarios-multiuser.ts";@@ -143,12 +143,9 @@ export const scenarios: Scenario[] = [async run(ctx) {const ch = await ctx.freshChannel();const root = await ch.mention("Run `uname -a` in your sandbox and paste the exact output line.");- const reply = await ch.waitForBotReply(root, { timeoutMs: SANDBOX_TIMEOUT - 30_000 });- assert.match(- reply.text ?? "",- /Linux \S+ \d+\.\d+\.\S+/,- `no uname output in reply: ${reply.text?.slice(0, 300)}`,- );+ const uname = /Linux \S+ \d+\.\d+\.\S+/;+ const reply = await ch.waitForBotReply(root, { match: uname, timeoutMs: SANDBOX_TIMEOUT - 30_000 });+ assert.match(reply.text ?? "", uname, `no uname output in reply: ${reply.text?.slice(0, 300)}`);const session = await ctx.core.findSessionByThread(ch.id, root);assert.ok(session, "no core session found for the thread");const ran = session.entries.some(@@ -162,19 +159,36 @@ export const scenarios: Scenario[] = [},{name: "perf-budget",- lane: "parallel",- tags: ["sandbox", "quarantine"],+ lane: "exclusive",+ tags: ["sandbox"],timeoutMs: SANDBOX_TIMEOUT,async run(ctx) {const ch = await ctx.freshChannel();- const root = await ch.mention("Run `ls /` in your sandbox and paste the first line of output.");- await ch.waitForBotReply(root, { timeoutMs: SANDBOX_TIMEOUT - 30_000 });+ const marker = ctx.marker("executed");+ const root = await ch.mention(+ `Run \`printf '%s%s\\n' '${marker.slice(0, -8)}' '${marker.slice(-8)}'\` in your sandbox and paste the exact output.`,+ );+ await ch.waitForBotReply(root, { match: new RegExp(marker), timeoutMs: SANDBOX_TIMEOUT - 30_000 });const session = await ctx.core.findSessionByThread(ch.id, root);assert.ok(session, "no core session found for the thread");- const ran = session.entries.some((e: any) => e.type === "tool_result");- assert.ok(ran, "core transcript has no tool_result — turn never exercised the platform's tool path");+ const ran = session.entries.some(+ (e: any) =>+ e.type === "tool_result" &&+ (e.payload?.tool === "execute" || (e.payload?.tool === "sandbox" && e.payload.action === "exec")) &&+ e.payload.isError === false &&+ e.payload.code === 0 &&+ e.payload.timedOut === false &&+ e.payload.stdout === `${marker}\n`,+ );+ assert.ok(ran, "core transcript has no successful command execution — cannot evaluate performance");+ for (let attempt = 0; ; attempt++) {+ const { entries } = await ctx.core.getSession(session.id);+ if (entries.some((e: any) => e.type === "assistant" && typeof e.payload?.workFinishedAt === "number")) break;+ assert.ok(attempt < 30, "turn did not finish recording its performance metrics");+ await sleep(1000);+ }const { requests } = (await ctx.core.getSessionLlm(session.id)) as {requests: Array<{ stepGapMs: number | null; gapPhases: Record<string, number> | null }>;};@@ -272,7 +286,7 @@ export const scenarios: Scenario[] = [const marker = ctx.marker();const before = String(Date.now() / 1000 - 5);const root = await ch.mention(- `Please post this status update to the #ci-target channel (you are a member there): "Live e2e check ${marker} — all systems normal." Then confirm here once it's posted.`,+ `Please post this status update to channel <#${target}> (you are a member there): "Live e2e check ${marker} — all systems normal." Then confirm here once it's posted.`,);await ch.waitForBotReply(root, { timeoutMs: SANDBOX_TIMEOUT - 60_000 });let found = false;@@ -281,7 +295,7 @@ export const scenarios: Scenario[] = [found = msgs.some((m) => m.user === ctx.env.botUserId && (m.text ?? "").includes(marker));if (!found) await sleep(5000);}- assert.ok(found, `no bot message containing ${marker} appeared in #ci-target`);+ assert.ok(found, `no bot message containing ${marker} appeared in channel ${target}`);},},{@@ -320,7 +334,7 @@ export const scenarios: Scenario[] = [const secret = ctx.marker("xchan");await ctx.env.qa.post(target!, `Heads-up for the bots: today's deploy ticket id is ${secret}.`);const root = await ch.mention(- "Someone just posted today's deploy ticket id in the #ci-target channel (you're a member there). " ++ `Someone just posted today's deploy ticket id in channel <#${target}> (you're a member there). ` +"Read that channel's recent messages and reply with the ticket id exactly.",);const reply = await ch.waitForBotReply(root, { match: new RegExp(secret), timeoutMs: SANDBOX_TIMEOUT - 30_000 });@@ -358,21 +372,27 @@ export const scenarios: Scenario[] = [{name: "long-task-streaming",lane: "parallel",- tags: ["quarantine"],timeoutMs: 5 * 60_000,async run(ctx) {const ch = await ctx.freshChannel();const frames: string[] = [];+ let sawReaction = false;const root = await ch.mention("Write a roughly 300-word explanation of how DNS resolution works, structured into four titled sections.",);- const reply = await ch.waitForBotReply(root, { timeoutMs: 4 * 60_000, onFrame: (t) => frames.push(t) });+ const reply = await ch.waitForBotReply(root, {+ timeoutMs: 4 * 60_000,+ accept: (message) => (message.text ?? "").length > 500,+ onFrame: (text) => frames.push(text),+ onMessages: (messages) => {+ if (messages.some((m) => m.user === ctx.env.botUserId && (m.text ?? "").length > 500)) return;+ sawReaction ||=+ messages.find((m) => m.ts === root)?.reactions?.some((r) => r.users.includes(ctx.env.botUserId)) === true;+ },+ });assert.ok((reply.text ?? "").length > 500, `final reply suspiciously short (${reply.text?.length} chars)`);- const sawProgress = frames.some(isLiveStatusText);- assert.ok(- sawProgress,- "never observed a streaming/status frame before the final reply (placeholder pipeline broken?)",- );+ const sawProgress = sawReaction || frames.slice(0, frames.indexOf(reply.text ?? "")).some((text) => text.trim());+ assert.ok(sawProgress, "never observed a bot reaction or acknowledgment before the final reply");},},{diff --git a/test/live-slack/slack.ts b/test/live-slack/slack.tsindex 6ee09386b..a5be5e2dd 100644--- a/test/live-slack/slack.ts+++ b/test/live-slack/slack.ts@@ -9,6 +9,7 @@ export interface SlackMessage {files?: Array<{ id?: string; name?: string; title?: string }>;subtype?: string;blocks?: Array<Record<string, unknown>>;+ reactions?: Array<{ name: string; users: string[] }>;}function apiUrlOf(raw: string): string {