[Bug]: schedule_task gives unbound tasks baseRef "main", which breaks repos without a main branch #16577
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Use a project whose only default branch is
master, with nomainlocally or onorigin. - From an agent thread in that project, call the MCP tool
schedule_taskwithbindToCurrentThread: false. - Open the task in Settings → Scheduled tasks, or read
workspace_strategy_jsoninscheduled_tasks.
Expected behavior#
An agent-created unbound task gets a workspace that resolves in its project, such as a worktree from the project's actual default branch. Failing that, the agent should be able to pass the workspace itself.
Actual behavior#
Every unbound task created over MCP gets {"type":"worktree","baseRef":"main","startFromOrigin":true}, because scheduledTaskWorkspaceStrategy in apps/server/src/mcp/OrchestratorMcpService.ts returns that literal. Tracing a run through ThreadLaunchService:
- It fetches
origin. remoteBranchExistsfinds noorigin/main, sostartReffalls back to the localmain.- There is no local
main, socreateWorktreegets a ref that doesn't exist, and workspace preparation fails.
The creating agent can't see or fix this. schedule_task has no workspace parameter and the response doesn't show the strategy. update_scheduled_task has no workspace parameter either. Passing bindToCurrentThread to update_scheduled_task goes through the same function, so it overwrites a workspace the user had already fixed in the editor.
I corrected the task in the editor before its first run, so this failure comes from reading the code. I didn't watch a run fail.
Impact#
Minor bug or occasional failure
Version or commit#
0.0.46-nightly.20261006.2735, unchanged on main at 3d17862e.
Environment#
Headless server on Linux arm64, desktop client on Windows, Claude Agent provider.
Workaround#
Change the task's workspace in Settings → Scheduled tasks. The editor's branch picker lists real branches, and "Use the project checkout" works too. Afterwards, never pass bindToCurrentThread in an update_scheduled_task call.
Possible fix#
Resolve the project's default branch instead of hardcoding "main". An optional workspaceStrategy on schedule_task and update_scheduled_task, like the one t3_thread_launch takes, would let agents choose root when their prompt manages its own worktrees. The comment on the update path explains that unbound tasks avoid the shared checkout on purpose, so a fresh worktree can stay the default.
juliusmarminge added labelsduplicate
juliusmarminge closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Thanks for the detailed trace! This is the same bug as #16183: unbound
schedule_tasktasks get a hard-codedbaseRef: "main", andupdate_scheduled_taskwrites it again wheneverbindToCurrentThreadis passed. Closing this as a duplicate so the discussion stays in one place.There's already an open fix in #16215, which makes unbound tasks branch from origin's default branch, then the checked-out branch, then
main. If you still want an optionalworkspaceStrategyparameter onschedule_taskandupdate_scheduled_task, please add that as a comment on #16183 or #16215.