fix(server): a PR watch the agent owns keeps its thread working until the PR merges #38926
Mergedjuliusmarmingemerged 3 commits into
main fromrefs/pull/38926/headmerged by juliusmarminge View on GitHubPushedb1a64a5
- @@ -324,3 +325,9 @@324325 .annotate(Tool.Idempotent, true)325326 .annotate(Tool.OpenWorld, false);326327328+const WatchPullRequestInput = Schema.Struct({329+ ...PullRequestTargetInput.fields,330+ until: Schema.optional(331+ PullRequestWatchUntil.annotate({332+ description:333+ 'How long this thread stays working. "checks" (default): until checks finish, for a PR you hand to the user. "merged": until it merges or closes or you unwatch it, when you will act on it yourself, such as merging after someone else approves.',@@ -37,3 +37,4 @@3737 {"id": "link-one-pr", "area": "pull-requests", "privacy": "commit-safe", "kind": "control", "pattern": "single link stays single", "experience": "Linking one named PR is ordinary work.", "setup": {"role": "top", "context": "No pull requests are linked to this thread.", "world": {"repo": "acme/app", "branch": "main"}}, "prompt": "link https://github.com/acme/app/pull/130 here", "expect": {"calls": [{"tool": "link_pull_request", "args": {"url": "~/pull/130"}}], "notCalls": ["link_pull_requests"]}, "maxSteps": 6, "source": {"thread": "Synthetic control for batch link"}}3838 {"id": "schedule-one-time-date", "area": "pull-requests", "kind": "bad", "pattern": "one-off date scheduled as a daily task", "experience": "Theo asked whether a scheduled task can run at a specific date and time. schedule_task only had daily times, intervals, and webhooks, so a one-off request became a daily task.", "source": {"report": "maintainer request, 2026-10-31: scheduled tasks could not run at one date and time"}, "rule": "schedule: {type:'once',runAt} for one date and time", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"schedule_task": {"scheduledTaskId": "scheduled-task-4", "title": "Cut 2.0 release branch", "schedule": {"type": "once", "runAt": "2026-11-03T09:00:00.000Z"}, "enabled": true, "nextRunAt": "2026-11-03T09:00:00.000Z"}}}, "prompt": "On November 3rd at 9am UTC, start a new thread that cuts the 2.0 release branch from main in acme/app. Only that one time.", "expect": {"calls": [{"tool": "schedule_task", "args": {"schedule.type": "once", "schedule.ru3939 {"id": "schedule-fresh-session-per-run", "area": "pull-requests", "kind": "guard", "pattern": "recurring task that should not accumulate context", "experience": "A recurring triage task kept one thread so the user could read its history, but each run carried every earlier run's context into the next.", "rule": "schedule_task `freshSession: true` keeps runs in one thread while each run starts a fresh session.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Today is Monday 2026-11-02, 10:00 local time.", "mocks": {"schedule_task": {"scheduledTaskId": "scheduled-task-7", "title": "Triage new issues", "enabled": true, "projectId": "project-1", "boundThreadId": null, "freshSession": true, "schedule": {"type": "fixed_time", "timeOfDay": "09:00"}, "nextRunAt": "2026-11-03T09:00:00-08:00", "lastRunStatus": "never"}}}, "prompt": "Every morning at 9, triage new issues in acme/app. Keep all the runs in one thread so I can scroll back, but each run should start clean without remem40+{"id": "babysit-merge-after-approval-until-merged", "area": "pull-requests", "kind": "bad", "pattern": "babysit until a teammate approves, then merge, watching only until checks finish", "experience": "Asked to babysit a PR and merge it once a teammate approved, the agent watched it only until checks finished, so the thread left Working as soon as checks passed while the agent still owned the merge.", "rule": "until: merged when you will act on the PR yourself, such as merging it after someone else approves", "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
Sign in to join this conversation.
coderabbitai[bot](GitHub profile, opens in a new tab) reviewed
Actionable comments posted: 2
85490156-d6cf-443b-82b3-a83752e4c09fReviewing files that changed from the base of the PR and between cae23994d9afedcbaffdc663532f3dafba1c1b52 and b1a64a53f45fb9c2ca9102b3e2cd8a43a88a6e32.
apps/server/src/mcp/toolkits/pullRequests/handlers.tsapps/server/src/mcp/toolkits/pullRequests/tools.tsapps/server/src/orchestration-v2/Orchestrator.tsapps/server/src/orchestration-v2/PullRequestWatchReactor.tsapps/server/src/orchestration-v2/pullRequestWatch.tsapps/server/src/orchestration-v2/runtimeLayer.test.tsapps/server/src/provider/agentContextBudget.jsonapps/server/src/pullRequest/PullRequestWatchService.tsevals/mcp-tool-use/cases/pull-requests.ndjsonpackages/contracts/src/orchestrationV2.tspackages/contracts/src/threadPullRequest.tspackages/shared/src/orchestrationV2PendingBackgroundWork.test.tspackages/shared/src/orchestrationV2PendingBackgroundWork.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.