Multiplayer agent harness for work.
fix: prevent agents from pausing their own goals (#1637)
Joshua France54e04d1f354b
diff --git a/src/harness/agent-tools.ts b/src/harness/agent-tools.tsindex d089c1bdf..4033bdb9f 100644--- a/src/harness/agent-tools.ts+++ b/src/harness/agent-tools.ts@@ -3864,24 +3864,19 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):name: "update",label: "update",description:- 'Close, pause, or resume the goal. status "complete" ONLY when the objective is achieved and verified against ' ++ 'Close or resume the goal. status "complete" ONLY when the objective is achieved and verified against ' +'current evidence. status "blocked" ONLY at a genuine impasse that has recurred across ' +`${GOAL_BLOCKED_MIN_ROUNDS} separate continuation rounds — never because the work is hard, slow, or unclear. ` +- 'status "paused" suspends enforcement (the user asked to set it aside; a halted turn also pauses it); ' ++ "Only the user can pause a goal by stopping the turn; agents cannot pause goals. " +'status "active" resumes a paused goal.',parameters: Type.Object({- status: Type.Union([- Type.Literal("complete"),- Type.Literal("blocked"),- Type.Literal("paused"),- Type.Literal("active"),- ]),+ status: Type.Union([Type.Literal("complete"), Type.Literal("blocked"), Type.Literal("active")]),note: Type.Optional(Type.String({ description: "complete: what evidence proves it. blocked: the exact impasse (required)." }),),}),async execute(callId, params) {- const p = params as { status: "complete" | "blocked" | "paused" | "active"; note?: string };+ const p = params as { status: "complete" | "blocked" | "active"; note?: string };await recordCall(callId, {tool: "goal",action: "update",@@ -3914,15 +3909,6 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):text("Goal resumed. It is enforced again; keep working toward it."),);}- if (p.status === "paused") {- goal.status = "paused";- goal.updatedAt = Date.now();- return recordCoreAuthoredResult(- callId,- { tool: "goal", action: "update", goal },- text('Goal paused. Enforcement is off until it is resumed with goal action update status "active".'),- );- }if (goal.status === "paused") {return recordCoreAuthoredResult(callId,diff --git a/src/harness/goal.ts b/src/harness/goal.tsindex 0d38028bd..9a0c379f7 100644--- a/src/harness/goal.ts+++ b/src/harness/goal.ts@@ -13,9 +13,9 @@* floor works the same way (matching Codex/Claude Code goal features):* completing or stopping under an unmet floor is answered with a* keep-going prompt, never a hard tool rejection.- * - Goals are pausable: the agent can pause/resume via goal action update, and- * halting a turn (the user's stop button) pauses an in-flight goal —- * a deliberate stop should not leave enforcement armed.+ * - Only the user can pause a goal by halting a turn (the stop button):+ * a deliberate stop should not leave enforcement armed. The agent can+ * resume a paused goal via goal action update.* - Opting out is deliberately hard: `blocked` is accepted only after the* same impasse has been claimed across three separate continuation* rounds, and never merely because the work is hard or slow.diff --git a/test/goal-tools.test.ts b/test/goal-tools.test.tsindex 01781a1d3..6e1dc1f06 100644--- a/test/goal-tools.test.ts+++ b/test/goal-tools.test.ts@@ -100,12 +100,10 @@ test("update blocked: needs a reason and three claims in distinct rounds", asyncassert.equal(ref.goal?.status, "blocked");});-test("update pause/resume round-trip", async () => {+test("update resumes a user-paused goal", async () => {const { ref, create, update } = toolbox();await create.execute("c1", { objective: "long haul" });- const paused = await update.execute("u1", { status: "paused" });- assert.match(textOf(paused as never), /Goal paused/);- assert.equal(ref.goal?.status, "paused");+ ref.goal!.status = "paused";const closeWhilePaused = await update.execute("u2", { status: "complete" });assert.match(textOf(closeWhilePaused as never), /paused. Resume it first/);assert.equal(ref.goal?.status, "paused");@@ -169,10 +167,35 @@ test("goal mutation receipts are durable before returning and rehydrate withoutawait create.execute("c1", { objective: "keep working", floor: { minMs: 1000 } });assert.equal(rehydrateOpenGoal(entries)?.status, "active");await update.execute("u1", { status: "paused" });- assert.equal(rehydrateOpenGoal(entries)?.status, "paused");+ assert.equal(rehydrateOpenGoal(entries)?.status, "active");+ ref.goal!.status = "paused";await update.execute("u2", { status: "active" });assert.equal(rehydrateOpenGoal(entries)?.status, "active");await update.execute("u3", { status: "complete", note: "verified" });assert.equal(rehydrateOpenGoal(entries), null);assert.ok(entries.every((entry) => entry.type !== "system"));});++test("agent cannot pause a goal or bypass its work floor", async () => {+ const { ref, create, update } = toolbox();+ await create.execute("c1", { objective: "keep working", floor: { minMs: 86_400_000 } });+ const before = structuredClone(ref.goal);+ const result = await update.execute("u1", { status: "paused", note: "I choose to stop" });+ assert.match(textOf(result), /Invalid arguments/);+ assert.deepEqual(ref.goal, before);+});++test("goal update schema does not offer pause", () => {+ const { tools } = toolbox();+ const goal = tools.find((tool) => tool.name === "goal")!;+ assert.doesNotMatch(JSON.stringify(goal.parameters), /"paused"/);+});++test("invalid goal status cannot fall through to completion", async () => {+ const { ref, create, update } = toolbox();+ await create.execute("c1", { objective: "keep working" });+ const before = structuredClone(ref.goal);+ const result = await update.execute("u1", { status: "cancelled" });+ assert.match(textOf(result), /Invalid arguments/);+ assert.deepEqual(ref.goal, before);+});