Multiplayer agent harness for work.
End shared web turns on their reply instead of finish_silently (#1737)
Joshua France88511bdbcebc
diff --git a/src/api/app-ambient.ts b/src/api/app-ambient.tsindex c51002168..f869d9a77 100644--- a/src/api/app-ambient.ts+++ b/src/api/app-ambient.ts@@ -23,7 +23,11 @@ import type { App, AppDeps } from "./app-types.ts";export function createAmbientHelpers(deps: AppDeps, app: App) {function shouldRouteToSpine(input: OrchestratorInput): boolean {const { conversation } = input;- return conversation.kind !== "dm" && (input.origin.kind === "human" || input.origin.kind === "ambient");+ return (+ input.surface !== "web" &&+ conversation.kind !== "dm" &&+ (input.origin.kind === "human" || input.origin.kind === "ambient")+ );}function markTriggerHandled(input: OrchestratorInput): void {diff --git a/src/harness/agent-tools.ts b/src/harness/agent-tools.tsindex 1d686b874..dd9e29587 100644--- a/src/harness/agent-tools.ts+++ b/src/harness/agent-tools.ts@@ -3748,9 +3748,9 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):name: "finish_silently",label: "finish_silently",description:- "End this turn immediately with no closing reply. Use on surface turns after posting or when " +- "choosing not to reply, and on scheduled background fires with nothing worth reporting. " +- "Keeps the audit log and any messages already posted. Do not write a closing status line. " ++ "Ends this turn silently. Use on surface turns when choosing not to reply at all, and on " ++ "scheduled background fires with nothing worth reporting. After posting a reply, just stop; " ++ "this is not needed. Keeps the audit log and any messages already posted. " +"On a direct human turn without surface tools this does nothing — just answer.",parameters: Type.Object({reason: Type.Optional(diff --git a/src/resolution/protocols/mode-autonomous.md b/src/resolution/protocols/mode-autonomous.mdindex 229be0ff2..691aaf93d 100644--- a/src/resolution/protocols/mode-autonomous.md+++ b/src/resolution/protocols/mode-autonomous.md@@ -1,5 +1,5 @@# This session-You are {{botName}}, present in this conversation. Your words reach people ONLY through the `{{surfaceTool}}` tool — `post` to reply here, `reach` to send elsewhere. When the work is done, call `finish_silently` to end the turn. It keeps the audit log and anything already posted; do not write a closing log line or reply.+You are {{botName}}, present in this conversation. Your words reach people ONLY through the `{{surfaceTool}}` tool — `post` to reply here, `reach` to send elsewhere. Once you've posted, just stop: the turn ends on its own. Do not write a closing log line or repeat the reply.You see every message posted here as it arrives — you do NOT need to be @mentioned, and you never poll, scan, or run a timer to keep up; new messages come to you. Most of them aren't for you.diff --git a/test/prompt-modes.test.ts b/test/prompt-modes.test.tsindex 01edb95b8..917a9aeb2 100644--- a/test/prompt-modes.test.ts+++ b/test/prompt-modes.test.ts@@ -234,7 +234,7 @@ test("Mode 2 (spine channel): autonomous-worklog frame, org policy once, no tempconst prompt = await sysprompt(orch, spineChannelTurn(""));assertNoTemplateTokens(prompt, "Mode 2 (spine channel)");- assert.match(prompt, /call `finish_silently` to end the turn/);+ assert.match(prompt, /Once you.ve posted, just stop/);assert.doesNotMatch(prompt, /stay_silent|Nothing to add|end with a short log line/);assert.doesNotMatch(prompt, /no one ever reads this transcript|private worklog/);diff --git a/test/surface-spine-routing.test.ts b/test/surface-spine-routing.test.tsindex e7e3897d5..d3d5573ed 100644--- a/test/surface-spine-routing.test.ts+++ b/test/surface-spine-routing.test.ts@@ -640,3 +640,28 @@ for (const command of ["!finish-silent-approval", "!finish-silent-paused"]) {assert.equal((await built.deliveries.pending("slack")).length, 0);});}++test("a shared web project turn answers with its final text, not surface tools", async () => {+ const built = freshApp();+ built.runtime.start();+ try {+ const project = await built.app.createProject("U1", "Launch");+ assert.ok(project);+ const ref = project.scopeId.slice("group:".length);+ const result = await built.app.turn({+ surface: "web",+ actor,+ conversation: { kind: "group", threadRef: `web:U1:${crypto.randomUUID()}`, channelRef: ref, audience: [actor] },+ text: "hello project",+ liveActor: true,+ });+ assert.equal(result.status, "ok", result.reason);+ assert.ok(result.reply, "the final text is the reply");+ const run = (await built.runs.list()).find((r) => r.request.text === "hello project");+ assert.ok(run);+ assert.notEqual(run.request.surfaceTools, true, "web project turns do not get the Slack surface-tools protocol");+ assert.equal(((await built.deliveries.pending("slack")) as unknown[]).length, 0);+ } finally {+ await built.runtime.stop();+ }+});