Repository navigation
fix(server): report scheduled worktree preparation failures - #19774
realhasanshoaib wants to merge 10 commits into
Conversation
…s failed A scheduled task that launches a fresh thread per run with a worktree strategy was recorded as "succeeded" as soon as the thread launch was accepted, even when its worktree could never be made, such as in a folder that is not a Git repository. The run then failed inside its thread before the agent started, and the scheduler never said so. - The pre-launch worktree check now also refuses a folder with no `.git` in it or above it. A repository Git refuses to read is still left to the launch. - The scheduler runs that check before launching, so such a run is recorded as failed with the reason, and no dead thread is created. - schedule_task and update_scheduled_task take an optional workspace (root or worktree), so an agent can choose to run in the project folder; an explicit worktree that cannot be made is refused up front. The task summary now shows the workspace, and an update keeps it unless the binding or the workspace changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused scheduler fix that records impossible worktree launches as failed without creating dead threads. The new MCP workspace selection is optional and preserves existing defaults, with coverage for repository validation and update behavior. You can add or adjust custom eligibility rules. Learn more. |
Root runs have nothing to check, and skipping the call keeps scheduler fixtures that stub only `launch` working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orted as failed A launch is accepted before its workspace is prepared, so a run whose worktree fetch or setup script failed still read "succeeded". The scheduler now waits for the launched run to leave preparation and, if it failed, marks that run failed. The write is guarded by the run's start time, so a later run's status is never overwritten. It also covers the hint that t3_thread_launch gives for a folder that is not a Git repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The watcher read the run's current status, so a retried preparation could hide its first failure, and a provider failure after setup could be blamed on setup. It now replays the new thread's run updates and decides from the run's first status other than "preparing". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
If an agent updates a worktree schedule and passes
The agent can't see this happen. The tool description promises "Only the provided fields change", so I'd treat a repeated type as no change: const workspaceStrategy =
!rebound &&
(input.workspace === undefined || input.workspace === existing.workspaceStrategy.type)
? existing.workspaceStrategy
: yield* scheduledTaskWorkspaceStrategy(existing.projectId, threadId !== null, input.workspace);I checked this with a scratch test at e0fd539. The three bad cases keep their saved strategy. The binding and type transitions (root to worktree, worktree to root, existing_worktree to worktree, bound to unbound and back) behave as before. The existing test "an update keeps the workspace unless the binding or the workspace changes" only asserts |
|
Taking over this one for batch worktree-git-16b. I will keep the scheduled preparation failure fix, remove the separate MCP workspace feature, merge current main, and rebuild the focused tests and implementation before independent review. Thanks @realhasanshoaib for the diagnosis and reproduction. |
Problem
Scheduled runs can show succeeded when their new worktree never finishes preparation. Launch acceptance happens before checkout and setup complete.
Change
Check worktree eligibility before launching a scheduled thread, and follow its first exit from preparation. A preparation failure corrects the scheduled run to failed. A provider failure after starting does not. The correction checks task creation time, run timestamp, and count so delayed feedback cannot overwrite another run.
This takeover keeps the status fix from @realhasanshoaib in #19774. The separate MCP workspace configuration feature was removed. Scratch projects retain current main’s thread-owned-folder behavior.
Scope and approval
Focused correction to existing scheduled-run status. No new scheduling API or client contract. This addresses the failure reporting described in #17309.
Verification
The preparation monitor is scoped to the running service; it is not restored after a server restart.
Linux verification only. macOS, Windows, iOS, Android, and Electron desktop were not exercised. Screenshots are not applicable to this server status change; the current-head live check used the server API, without a graphical client.
Implementation: GPT-6.1 Sol, Codex harness in T3 Code. Tests: GPT-6 Astra (high). Independent reviews: Claude Opus 5.5 and GPT-6 Sol.