fix(server): schedule_task can switch an existing task to fresh sessions#31649

open1
main
GitHub fork: fix/scheduled-tasks
opened6d agobyMMarcoDotIO
View on GitHubTwo-way sync enabledPR last imported 20h ago

Problem

An agent cannot switch an existing scheduled task to fresh sessions. schedule_task with scheduledTaskId and freshSession: true returns success, but the task keeps its old destination and the result shows freshSession: false.

Call path: the schedule_task tool's update branch in apps/server/src/mcp/toolkits/orchestrator/handlers.ts picks out prompt, title, schedule, enabled and bindToCurrentThread before it calls OrchestratorMcpService.updateScheduledTask, and leaves out freshSession. #30326 added freshSession to the update input and taught updateScheduledTask to map it to a thread mode, but its tests call the service directly, so they never went through the handler. Because the field never reaches the service, the refusal in updateScheduledTask that tells agents to "set freshSession: true in a second call" also gives advice the real tool silently ignores.

Change

The update branch now passes freshSession through to updateScheduledTask, like the other fields.

Scope and approval

This is a one-line fix for an obvious bug in the feature #30326 just added. The tool's schema and the service already accept the field; the handler dropped it. It changes nothing outside this tool call.

Verification

New test in apps/server/src/mcp/toolkits/core.test.ts, "schedule_task switches an existing task to fresh sessions". It calls the real schedule_task tool through the in-process MCP server and checks both the saved thread mode and the tool result.

Before the fix (upstream/main):

1- Expected
2+ Received
3 [
4- "fresh_session",
5+ "new_thread",
6 ]
7 Tests 1 failed | 20 skipped (21)

With the fix:

1 Test Files 1 passed (1)
2 Tests 21 passed (21)

Other checks: targeted vp lint and vp fmt --check on apps/server/src/mcp/toolkits, and the apps/server typecheck (0 errors).

Not checked: a live agent calling the tool against a running server.

Claude Opus 5.5 (Claude Code desktop app)

🤖 Generated with Claude Code

Checks

21 successful · 13 skipped
All checks passed
7080a89

Added 1 commit

  • fix(server): schedule_task can switch an existing task to fresh sessions7080a89
Synced from GitHub

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The scheduled-task update handler now forwards freshSession to updateScheduledTask. A test verifies that the update input sets threadMode to "fresh_session" and that the response reports freshSession: true.

Changes: Scheduled-task update

Layer / File(s)Summary
Forward and verify fresh-session updates
apps/server/src/mcp/toolkits/orchestrator/handlers.ts, apps/server/src/mcp/toolkits/core.test.ts
The handler passes freshSession to updateScheduledTask. The test checks that the upsert input uses threadMode: "fresh_session" and that the response reports freshSession: true.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#16183: The change enables an existing task to switch to fresh-session mode, but does not change the main worktree base that the issue identifies.
  • pingdotgg/t3code#27488: The change enables an existing task to switch to fresh-session mode, but does not change the branch selection described in the issue.

Suggested reviewers: t3dotgg

Merge Risk: External image Minimal · up to 7080a

The change enables existing scheduled tasks to use fresh sessions. No merge-blocking issue was established.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title names the main change: schedule_task can now switch an existing task to fresh sessions. The raw summary and objectives confirm the handler now passes freshSession to updateScheduledTask. The…
Description checkPassedThe description follows the template sections (Problem, Change, Scope and approval, Verification). The Problem section gives the expected behavior, the reproduction path, and the root cause in the han…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: schedule_task can now switch an existing task to fresh sessions. The raw summary and objectives confirm the handler now passes freshSession to updateScheduledTask. The title is specific, uses a conventional commit prefix, and is a single sentence. It is 72 characters, which is slightly long but acceptable.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope and approval, Verification). The Problem section gives the expected behavior, the reproduction path, and the root cause in the handler. The Change section explains the one-line fix. Scope and approval explains why no prior issue is needed: a one-line fix for an obvious bug in a just-added feature. Verification gives a new focused test, before and after results, and lint, format, and typecheck runs, and it states what was not checked. The description does not link a triaged issue or maintainer approval. It relies on the small-obvious-fix exemption, which the template allows, so this is a reasonable pass.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between 37481f044e749a658d94a927b33b268a733f94c5 and 7080a89dc2091b07854b34b75ff5140446442795.

External image Files selected for processing: 2

  • apps/server/src/mcp/toolkits/core.test.ts
  • apps/server/src/mcp/toolkits/orchestrator/handlers.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.