Skip to content

[Bug]: schedule_task gives unbound tasks baseRef "main", which breaks repos without a main branch #16577

Closed as not planned

Description

@AngeloTadeucci

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

  1. Use a project whose only default branch is master, with no main locally or on origin.
  2. From an agent thread in that project, call the MCP tool schedule_task with bindToCurrentThread: false.
  3. Open the task in Settings → Scheduled tasks, or read workspace_strategy_json in scheduled_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:

  1. It fetches origin.
  2. remoteBranchExists finds no origin/main, so startRef falls back to the local main.
  3. There is no local main, so createWorktree gets 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.

Activity

  1. juliusmarminge commented on Oct 6, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Thanks for the detailed trace! This is the same bug as #16183: unbound schedule_task tasks get a hard-coded baseRef: "main", and update_scheduled_task writes it again whenever bindToCurrentThread is 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 optional workspaceStrategy parameter on schedule_task and update_scheduled_task, please add that as a comment on #16183 or #16215.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions