From 335e8e3d8ed46c98fe2b319f40ff1e1798adf827 Mon Sep 17 00:00:00 2001 From: Illia Panasenko Date: Fri, 20 Nov 2026 15:26:23 +0100 Subject: [PATCH 1/5] feat(mcp): schedule_task can run new-thread tasks in the project checkout --- .../src/mcp/OrchestratorMcpService.test.ts | 66 +++++++++++++++++++ apps/server/src/mcp/OrchestratorMcpService.ts | 39 +++++++++-- .../src/mcp/toolkits/orchestrator/handlers.ts | 12 +++- .../src/provider/agentContextBudget.json | 2 +- .../orchestrator-mcp-server.md | 4 +- evals/mcp-tool-use/cases/pull-requests.ndjson | 1 + packages/contracts/src/orchestratorMcp.ts | 8 +++ 7 files changed, 124 insertions(+), 8 deletions(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.ts index 2dad1fe68ee6d..1652a7d0e59e7 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.test.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts @@ -4366,6 +4366,72 @@ describe("OrchestratorMcpService provider resolution", () => { }), ); + it.effect("creates a task that runs in the project checkout", () => + Effect.gen(function* () { + const saved = yield* Ref.make>([]); + const mcp = yield* OrchestratorMcpService.OrchestratorMcpService.pipe( + Effect.provide(service(masterRepository, saved)), + ); + yield* mcp.scheduleTask(client, { + projectId, + prompt: "Check the build", + schedule, + workspace: "checkout", + }); + assert.deepEqual(yield* Ref.get(saved), [{ type: "root" }]); + }), + ); + + it.effect.each([ + { + name: "unbinding into the checkout in one call", + task: { threadId: ThreadId.make("thread:scheduled-base"), threadMode: "continue" }, + update: { bindToCurrentThread: false, workspace: "checkout" }, + expected: { type: "root" }, + }, + { + name: "moving an unbound task from the checkout to worktrees", + task: {}, + update: { workspace: "worktree" }, + expected: { type: "worktree", baseRef: "origin/master", startFromOrigin: true }, + }, + { + name: "asking for worktrees again keeps the saved base branch", + task: { workspaceStrategy: { type: "worktree", baseRef: "release" } }, + update: { workspace: "worktree" }, + expected: { type: "worktree", baseRef: "release" }, + }, + ] as const)("$name", ({ task, update, expected }) => + Effect.gen(function* () { + const saved = yield* Ref.make>([]); + const mcp = yield* OrchestratorMcpService.OrchestratorMcpService.pipe( + Effect.provide(service(masterRepository, saved, { ...existing, ...task })), + ); + yield* mcp.updateScheduledTask(client, { scheduledTaskId: existing.id, ...update }); + assert.deepEqual(yield* Ref.get(saved), [expected]); + }), + ); + + it.effect("refuses a workspace for a task that stays bound to its thread", () => + Effect.gen(function* () { + const saved = yield* Ref.make>([]); + const mcp = yield* OrchestratorMcpService.OrchestratorMcpService.pipe( + Effect.provide( + service(masterRepository, saved, { + ...existing, + threadId: ThreadId.make("thread:scheduled-base"), + threadMode: "continue", + }), + ), + ); + const refused = yield* mcp + .updateScheduledTask(client, { scheduledTaskId: existing.id, workspace: "checkout" }) + .pipe(Effect.flip); + assert.include(refused.message, "bindToCurrentThread: false"); + assert.deepEqual(yield* Ref.get(saved), []); + }), + ); + it.effect.each([ { name: "no remote, only master", diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 7b8c99877d974..22cac698f202a 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -281,6 +281,14 @@ function errorMessage(error: unknown): string { return error instanceof Error ? error.message : String(error); } +const SCHEDULED_TASK_WORKSPACE = { + root: "checkout", + worktree: "worktree", + existing_worktree: "existing_worktree", +} as const; +const WORKSPACE_NEEDS_UNBOUND = + "workspace applies only to tasks that start a new thread. Pass bindToCurrentThread: false, or leave workspace out."; + function scheduledTaskSummary(task: ScheduledTask, mayRun: boolean): OrchestratorMcpScheduledTask { return { scheduledTaskId: task.id, @@ -293,6 +301,9 @@ function scheduledTaskSummary(task: ScheduledTask, mayRun: boolean): Orchestrato schedule: task.schedule, nextRunAt: task.nextRunAt, lastRunStatus: task.lastRunStatus, + ...(task.threadId === null + ? { workspace: SCHEDULED_TASK_WORKSPACE[task.workspaceStrategy.type] } + : {}), ...(task.webhook?.url == null || !mayRun || task.blockedByPolicy !== undefined ? {} : { webhookUrl: task.webhook.url }), @@ -2264,8 +2275,8 @@ const make = Effect.gen(function* () { const scheduledTaskWorkspaceStrategy = Effect.fn( "OrchestratorMcpService.scheduledTaskWorkspaceStrategy", - )(function* (boundToThread: boolean, projectId: ProjectId) { - if (boundToThread) return { type: "root" as const }; + )(function* (workspace: "checkout" | "worktree", projectId: ProjectId) { + if (workspace === "checkout") return { type: "root" as const }; const { workspaceRoot } = yield* requireProject(projectId); return { type: "worktree" as const, @@ -2372,6 +2383,9 @@ const make = Effect.gen(function* () { : "bindToCurrentThread binds to this thread, which belongs to a different project.", ); } + if (bindToCurrentThread && input.workspace !== undefined) { + return yield* failure("invalid_request", WORKSPACE_NEEDS_UNBOUND); + } const modelSelection = parent?.thread.modelSelection ?? (yield* projectDefaultModelSelection(project)); // Never end on a lone high surrogate, which renders as a broken character. @@ -2391,7 +2405,10 @@ const make = Effect.gen(function* () { : bindToCurrentThread ? "continue" : "new_thread", - workspaceStrategy: yield* scheduledTaskWorkspaceStrategy(bindToCurrentThread, projectId), + workspaceStrategy: yield* scheduledTaskWorkspaceStrategy( + bindToCurrentThread ? "checkout" : (input.workspace ?? "worktree"), + projectId, + ), modelSelection, runtimeMode: limits.runtimeMode, interactionMode: limits.interactionMode, @@ -2474,11 +2491,23 @@ const make = Effect.gen(function* () { : input.bindToCurrentThread && parent !== undefined ? parent.thread.id : null; + if (threadId !== null && input.workspace !== undefined) { + return yield* failure("invalid_request", WORKSPACE_NEEDS_UNBOUND); + } // Reset the workspace only when the binding flips, so unbinding cannot leave runs in the shared checkout. + const workspace = + input.workspace ?? + ((threadId === null) === (existing.threadId === null) + ? undefined + : threadId === null + ? "worktree" + : "checkout"); const workspaceStrategy = - (threadId === null) === (existing.threadId === null) + workspace === undefined || + (existing.threadId === null && + SCHEDULED_TASK_WORKSPACE[existing.workspaceStrategy.type] === workspace) ? existing.workspaceStrategy - : yield* scheduledTaskWorkspaceStrategy(threadId !== null, existing.projectId); + : yield* scheduledTaskWorkspaceStrategy(workspace, existing.projectId); const upsertInput: ScheduledTaskUpsertInput = { id: existing.id, title: input.title ?? existing.title, diff --git a/apps/server/src/mcp/toolkits/orchestrator/handlers.ts b/apps/server/src/mcp/toolkits/orchestrator/handlers.ts index d90a118be468e..2d94f7279cb57 100644 --- a/apps/server/src/mcp/toolkits/orchestrator/handlers.ts +++ b/apps/server/src/mcp/toolkits/orchestrator/handlers.ts @@ -106,7 +106,16 @@ const handlers = { { refused: "schedule tasks in this environment" }, ), McpToolAccess.writes( - ({ scheduledTaskId, prompt, title, schedule, enabled, freshSession, bindToCurrentThread }) => + ({ + scheduledTaskId, + prompt, + title, + schedule, + enabled, + freshSession, + bindToCurrentThread, + workspace, + }) => Effect.gen(function* () { if (scheduledTaskId === undefined) return yield* Effect.die("unreachable"); const scope = yield* McpInvocationContext.McpInvocationContext; @@ -119,6 +128,7 @@ const handlers = { enabled, freshSession, bindToCurrentThread, + workspace, }); }), ), diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index 267fff59a6021..457accf5be7fa 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { "claudeSystemAppendBytes": 6245, "codexAdditionalContextBytes": 7639, - "mcpToolListJsonBytes": 57299 + "mcpToolListJsonBytes": 57480 } diff --git a/docs/orchestration-v2/orchestrator-mcp-server.md b/docs/orchestration-v2/orchestrator-mcp-server.md index 5f48ed4a2c14f..ebdde5accd5d7 100644 --- a/docs/orchestration-v2/orchestrator-mcp-server.md +++ b/docs/orchestration-v2/orchestrator-mcp-server.md @@ -479,7 +479,9 @@ Without a signature, anyone with the webhook URL can trigger a run. Signature checks, filters, and dedupe can skip a webhook request. `bindToCurrentThread` defaults to `true` only when the caller has a thread in the task's project; otherwise it defaults to `false`. Bound runs post into -that thread; unbound runs each launch a fresh thread in the task's project. +that thread; unbound runs each launch a fresh thread in the task's project, +in a new worktree from the default branch unless `workspace: "checkout"` puts +them in the project checkout. A task that stays bound rejects `workspace`. Explicit `bindToCurrentThread: true` without a caller thread in that project is rejected. Pausing uses `schedule_task` with `scheduledTaskId` and `enabled: false`; deletion is permanent. diff --git a/evals/mcp-tool-use/cases/pull-requests.ndjson b/evals/mcp-tool-use/cases/pull-requests.ndjson index 950680da0988b..3d3b055b99c20 100644 --- a/evals/mcp-tool-use/cases/pull-requests.ndjson +++ b/evals/mcp-tool-use/cases/pull-requests.ndjson @@ -57,3 +57,4 @@ {"id": "ci-flake-rerun-through-gh", "area": "pull-requests", "kind": "bad", "pattern": "CI re-run with gh run rerun", "experience": "Asked to re-run a flaky check, agents looked up run ids with gh run list and ran gh run rerun --failed.", "rule": "ci_rerun re-runs a PR's failing checks", "privacy": "commit-safe", "setup": {"role": "top", "world": {"branch": "fix/retry-queue", "commits": [{"sha": "9f3c2a1", "subject": "fix(queue): retry a failed job once"}], "diff": "diff --git a/src/queue.ts b/src/queue.ts\n--- a/src/queue.ts\n+++ b/src/queue.ts\n@@ -4,3 +4,4 @@ export async function run(job: Job) {\n try {\n return await job.execute();\n- } catch {\n+ } catch (error) {\n+ if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n", "files": {"src/queue.ts": "export async function run(job: Job) {\n try {\n return await job.execute();\n } catch (error) {\n if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n }\n}\n"}, "prs": [{"number": 124, "title": "fix(queue): retry a failed job once", "headRefName": "fix/retry-queue", "checks": [{"name": "Lint", "state": "pass"}, {"name": "Test", "state": "fail", "log": "FAIL src/queue.test.ts > gives up after one retry\nAssertionError: expected 2 calls, got 3\n at src/queue.test.ts:18:5"}]}]}}, "prompt": "The Test failure on #124 is a known flake. Re-run it.", "expect": {"calls": [{"tool": "ci_rerun"}], "shellMustNot": ["\\bgh run (rerun|list|view)\\b", "\\bgh api\\b[^\\n]*rerun"]}, "notes": "Forge usage audit of agent logs on three machines (2026-10-28): agents read failing CI with gh run view --log-failed or the job logs API about 500 times in 45 days, and re-ran CI with gh run rerun 92 times."} {"id": "control-ci-why-no-rerun", "area": "pull-requests", "kind": "control", "pattern": "question about a failing check", "experience": "Control: the user asks why CI failed. Reading the log is right; re-running it was not asked.", "rule": "Re-run only when asked", "privacy": "commit-safe", "setup": {"role": "top", "world": {"branch": "fix/retry-queue", "commits": [{"sha": "9f3c2a1", "subject": "fix(queue): retry a failed job once"}], "diff": "diff --git a/src/queue.ts b/src/queue.ts\n--- a/src/queue.ts\n+++ b/src/queue.ts\n@@ -4,3 +4,4 @@ export async function run(job: Job) {\n try {\n return await job.execute();\n- } catch {\n+ } catch (error) {\n+ if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n", "files": {"src/queue.ts": "export async function run(job: Job) {\n try {\n return await job.execute();\n } catch (error) {\n if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n }\n}\n"}, "prs": [{"number": 124, "title": "fix(queue): retry a failed job once", "headRefName": "fix/retry-queue", "checks": [{"name": "Lint", "state": "pass"}, {"name": "Test", "state": "fail", "log": "FAIL src/queue.test.ts > gives up after one retry\nAssertionError: expected 2 calls, got 3\n at src/queue.test.ts:18:5"}]}]}}, "prompt": "Why is CI failing on #124? Don't change anything yet.", "expect": {"notCalls": ["ci_rerun", "pull_request_merge"], "shellMustNot": ["\\bgh run rerun\\b"]}, "notes": "Control for ci-flake-rerun-through-gh."} {"id": "land-stack-in-one-merge", "area": "pull-requests", "kind": "bad", "pattern": "a green, approved stack merged layer by layer or through gh stack merge", "experience": "Asked to land a two-PR stack, the agent had only a one-PR merge tool, so it merged the bottom layer alone, which restarts CI on the layer above, or fell back to gh stack merge in the shell.", "rule": "pull_request_merge stack:true on the top PR merges every layer below it at once.", "privacy": "commit-safe", "setup": {"role": "top", "context": "PR #124 (feature/error-detail, on main) and PR #125 (feature/frozen-host, on top of #124) form a native GitHub stack and are linked to this thread.", "world": {"repo": "acme/app", "branch": "feature/frozen-host", "stack": 300, "linkedPullRequests": [{"number": 124, "state": "open", "title": "feat(server): include the failing step in connection errors"}, {"number": 125, "state": "open", "title": "feat(server): detect a frozen host and say so"}], "prs": [{"number": 124, "title": "feat(server): include the failing step in connection errors", "headRefName": "feature/error-detail", "baseRefName": "main", "headRefOid": "e1d2c3b", "reviewDecision": "APPROVED", "mergeable": "MERGEABLE", "checks": [{"name": "CI", "state": "pass"}]}, {"number": 125, "title": "feat(server): detect a frozen host and say so", "headRefName": "feature/frozen-host", "baseRefName": "feature/error-detail", "headRefOid": "f7e6d5c", "reviewDecision": "APPROVED", "mergeable": "MERGEABLE", "checks": [{"name": "CI", "state": "pass"}]}]}}, "prompt": "Both PRs in the stack are approved and green. Land the stack.", "expect": {"calls": [{"tool": "pull_request_merge", "args": {"stack": true, "expectedHeadSha": "f7e6d5c"}, "argsAnyOf": [{"number": 125}, {"url": "~/pull/125"}, {"number": null, "url": null}]}], "maxCalls": {"pull_request_merge": 1}, "shellMustNot": ["gh stack merge", "gh pr merge", "gh api[^\\n]*/merge"], "callsMustNot": [{"tool": "pull_request_merge", "args": {"auto": true}}]}, "maxSteps": 8, "source": {"request": "juliusmarminge (maintainer) request, 2026-11-18: the PR tools could read stacks but not merge one; layer-by-layer merges restart CI above and can reorder a GitHub stack"}} +{"id": "schedule-new-thread-in-checkout", "area": "pull-requests", "kind": "bad", "pattern": "workspace asked, agent defers it to Settings", "experience": "Asked for a daily task that starts a new thread each run in the project checkout, agents created it with a new worktree per run and asked the user to switch Workspace to 'Use the project checkout' in Settings, because schedule_task had no workspace input.", "source": {"issue": "https://github.com/pingdotgg/t3code/issues/32491", "note": "Scheduled runs that had to share the project checkout asked the user, again and again, to set Workspace in Settings."}, "rule": "schedule_task workspace: Unbound only: run in the project checkout, or a new worktree per run", "privacy": "commit-safe", "setup": {"role": "top", "context": "Today is Friday 2026-11-20, 15:00 local time.", "mocks": {"schedule_task": {"scheduledTaskId": "scheduled-task-7", "title": "Upload i18n screenshots", "prompt": "Run scripts/i18n-screenshots.sh and upload the results.", "enabled": true, "projectId": "project-acme-app", "boundThreadId": null, "freshSession": false, "schedule": {"type": "fixed_time", "timeOfDay": "09:00"}, "nextRunAt": "2026-11-21T09:00:00-08:00", "lastRunStatus": "never", "workspace": "checkout"}}, "shellMocks": [{"match": "\\bdate\\b", "output": "Friday 2026-11-20 15:00 PST"}]}, "prompt": "Set up a daily 9am job that runs scripts/i18n-screenshots.sh and uploads the results. Give each run its own new thread, but have it work in the project checkout, not a fresh worktree. The repo is huge.", "expect": {"calls": [{"tool": "schedule_task", "args": {"workspace": "checkout", "bindToCurrentThread": false}}], "notCalls": ["delegate_task", "run_scheduled_task_now"], "callsMustNot": [{"tool": "schedule_task", "args": {"workspace": "worktree"}}]}, "notes": "Before schedule_task took workspace, the only way to get new threads in the checkout was the Settings editor."} diff --git a/packages/contracts/src/orchestratorMcp.ts b/packages/contracts/src/orchestratorMcp.ts index d7c607744d4a7..aebaddc2f7f81 100644 --- a/packages/contracts/src/orchestratorMcp.ts +++ b/packages/contracts/src/orchestratorMcp.ts @@ -707,6 +707,11 @@ export const OrchestratorMcpCapabilitiesResult = Schema.Struct({ }); export type OrchestratorMcpCapabilitiesResult = typeof OrchestratorMcpCapabilitiesResult.Type; +const OrchestratorMcpScheduledTaskWorkspace = Schema.Literals(["checkout", "worktree"]).annotate({ + description: + "Unbound only: run in the project checkout, or a new worktree per run. Unset: worktree; updates keep it.", +}); + export const OrchestratorMcpScheduleTaskInput = Schema.Struct({ environmentId: OrchestratorMcpEnvironmentTarget, projectId: OrchestratorMcpProjectTarget, @@ -726,6 +731,7 @@ export const OrchestratorMcpScheduleTaskInput = Schema.Struct({ "Runs share one thread but each starts a fresh session. Unbound: the first run makes the thread.", }), ), + workspace: Schema.optional(OrchestratorMcpScheduledTaskWorkspace), clientRequestId: Schema.optional(OrchestratorMcpClientRequestId), }); export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type; @@ -751,6 +757,7 @@ export const OrchestratorMcpScheduledTask = Schema.Struct({ schedule: ScheduledTaskSchedule, nextRunAt: Schema.NullOr(IsoDateTime), lastRunStatus: ScheduledTaskRunStatus, + workspace: Schema.optional(Schema.Literals(["checkout", "worktree", "existing_worktree"])), webhookUrl: Schema.optional(Schema.String).annotate({ description: "Webhook bearer URL, returned only on task creation to callers allowed to run it. Lists and updates omit it; the user can copy it from Settings. Creation may omit it without T3 Connect remote access or run permission.", @@ -792,6 +799,7 @@ export const OrchestratorMcpUpdateScheduledTaskInput = Schema.Struct({ enabled: Schema.optional(Schema.Boolean), bindToCurrentThread: Schema.optional(Schema.Boolean), freshSession: Schema.optional(Schema.Boolean), + workspace: Schema.optional(OrchestratorMcpScheduledTaskWorkspace), }); export type OrchestratorMcpUpdateScheduledTaskInput = typeof OrchestratorMcpUpdateScheduledTaskInput.Type; From 67089276262bb378fe549fa05d9d2fd39ec14253 Mon Sep 17 00:00:00 2001 From: Illia Panasenko Date: Fri, 20 Nov 2026 15:28:28 +0100 Subject: [PATCH 2/5] chore: describe the default when workspace is omitted --- apps/server/src/mcp/OrchestratorMcpService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 22cac698f202a..9ace5a10c9ca3 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -2494,7 +2494,7 @@ const make = Effect.gen(function* () { if (threadId !== null && input.workspace !== undefined) { return yield* failure("invalid_request", WORKSPACE_NEEDS_UNBOUND); } - // Reset the workspace only when the binding flips, so unbinding cannot leave runs in the shared checkout. + // Without an explicit workspace, unbinding defaults to a worktree so runs do not silently share the checkout. const workspace = input.workspace ?? ((threadId === null) === (existing.threadId === null) From 36872fc740456e90d234d662824a5f78a5f4828a Mon Sep 17 00:00:00 2001 From: Illia Panasenko Date: Fri, 20 Nov 2026 16:00:58 +0100 Subject: [PATCH 3/5] fix(mcp): trim the schedule_task workspace description --- apps/server/src/provider/agentContextBudget.json | 2 +- evals/mcp-tool-use/cases/pull-requests.ndjson | 2 +- packages/contracts/src/orchestratorMcp.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index eb4d97b5dd321..e961e0e687310 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { "claudeSystemAppendBytes": 6245, "codexAdditionalContextBytes": 7639, - "mcpToolListJsonBytes": 57479 + "mcpToolListJsonBytes": 57448 } diff --git a/evals/mcp-tool-use/cases/pull-requests.ndjson b/evals/mcp-tool-use/cases/pull-requests.ndjson index b4292e31627ca..60e46b106e22c 100644 --- a/evals/mcp-tool-use/cases/pull-requests.ndjson +++ b/evals/mcp-tool-use/cases/pull-requests.ndjson @@ -58,4 +58,4 @@ {"id": "control-ci-why-no-rerun", "area": "pull-requests", "kind": "control", "pattern": "question about a failing check", "experience": "Control: the user asks why CI failed. Reading the log is right; re-running it was not asked.", "rule": "Re-run only when asked", "privacy": "commit-safe", "setup": {"role": "top", "world": {"branch": "fix/retry-queue", "commits": [{"sha": "9f3c2a1", "subject": "fix(queue): retry a failed job once"}], "diff": "diff --git a/src/queue.ts b/src/queue.ts\n--- a/src/queue.ts\n+++ b/src/queue.ts\n@@ -4,3 +4,4 @@ export async function run(job: Job) {\n try {\n return await job.execute();\n- } catch {\n+ } catch (error) {\n+ if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n", "files": {"src/queue.ts": "export async function run(job: Job) {\n try {\n return await job.execute();\n } catch (error) {\n if (job.attempts > 1) throw error;\n return run({ ...job, attempts: job.attempts + 1 });\n }\n}\n"}, "prs": [{"number": 124, "title": "fix(queue): retry a failed job once", "headRefName": "fix/retry-queue", "checks": [{"name": "Lint", "state": "pass"}, {"name": "Test", "state": "fail", "log": "FAIL src/queue.test.ts > gives up after one retry\nAssertionError: expected 2 calls, got 3\n at src/queue.test.ts:18:5"}]}]}}, "prompt": "Why is CI failing on #124? Don't change anything yet.", "expect": {"notCalls": ["ci_rerun", "pull_request_merge"], "shellMustNot": ["\\bgh run rerun\\b"]}, "notes": "Control for ci-flake-rerun-through-gh."} {"id": "land-stack-in-one-merge", "area": "pull-requests", "kind": "bad", "pattern": "a green, approved stack merged layer by layer or through gh stack merge", "experience": "Asked to land a two-PR stack, the agent had only a one-PR merge tool, so it merged the bottom layer alone, which restarts CI on the layer above, or fell back to gh stack merge in the shell.", "rule": "pull_request_merge stack:true on the top PR merges every layer below it at once.", "privacy": "commit-safe", "setup": {"role": "top", "context": "PR #124 (feature/error-detail, on main) and PR #125 (feature/frozen-host, on top of #124) form a native GitHub stack and are linked to this thread.", "world": {"repo": "acme/app", "branch": "feature/frozen-host", "stack": 300, "linkedPullRequests": [{"number": 124, "state": "open", "title": "feat(server): include the failing step in connection errors"}, {"number": 125, "state": "open", "title": "feat(server): detect a frozen host and say so"}], "prs": [{"number": 124, "title": "feat(server): include the failing step in connection errors", "headRefName": "feature/error-detail", "baseRefName": "main", "headRefOid": "e1d2c3b", "reviewDecision": "APPROVED", "mergeable": "MERGEABLE", "checks": [{"name": "CI", "state": "pass"}]}, {"number": 125, "title": "feat(server): detect a frozen host and say so", "headRefName": "feature/frozen-host", "baseRefName": "feature/error-detail", "headRefOid": "f7e6d5c", "reviewDecision": "APPROVED", "mergeable": "MERGEABLE", "checks": [{"name": "CI", "state": "pass"}]}]}}, "prompt": "Both PRs in the stack are approved and green. Land the stack.", "expect": {"calls": [{"tool": "pull_request_merge", "args": {"stack": true, "expectedHeadSha": "f7e6d5c"}, "argsAnyOf": [{"number": 125}, {"url": "~/pull/125"}, {"number": null, "url": null}]}], "maxCalls": {"pull_request_merge": 1}, "shellMustNot": ["gh stack merge", "gh pr merge", "gh api[^\\n]*/merge"], "callsMustNot": [{"tool": "pull_request_merge", "args": {"auto": true}}]}, "maxSteps": 8, "source": {"request": "juliusmarminge (maintainer) request, 2026-11-18: the PR tools could read stacks but not merge one; layer-by-layer merges restart CI above and can reorder a GitHub stack"}} {"id": "watch-for-teammate-merge-no-own-poll", "area": "pull-requests", "kind": "bad", "pattern": "assumes a merge will not wake it, so polls or asks the user", "experience": "Told a teammate would merge the PR and asked to report when it merged, agents read watch_pull_request's wake list (checks, comments, conflicts), concluded a merge would not wake them, and ran their own polling or asked the user to check back.", "rule": "watch_pull_request: T3 wakes you on ... and once on merge or close unless you did it via CLI", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "The HTML preview frame has no accessible name. Fix it and open a PR."}, {"role": "assistant", "text": "Opened [PR #124](https://github.com/acme/app/pull/124). The preview frame now has the title \"HTML preview\".", "toolCalls": [{"tool": "Bash", "input": {"command": "git push -u origin fix/html-preview-title && gh pr create --fill"}, "result": "https://github.com/acme/app/pull/124"}, {"tool": "link_pull_request", "input": {"url": "https://github.com/acme/app/pull/124"}, "result": {"host": "github.com", "repository": "acme/app", "number": 124, "url": "https://github.com/acme/app/pull/124", "alreadyLinked": false}}]}], "mocks": {"watch_pull_request": "default", "link_pull_request": "default"}, "world": {"branch": "fix/html-preview-title", "commits": [{"sha": "abc1234", "subject": "fix(web): HTML preview frame gets an accessible title"}], "diff": "diff --git a/apps/web/src/HtmlPreview.tsx b/apps/web/src/HtmlPreview.tsx\n--- a/apps/web/src/HtmlPreview.tsx\n+++ b/apps/web/src/HtmlPreview.tsx\n@@ -1,3 +1,3 @@\n export function HtmlPreview({ html }: { html: string }) {\n- return