fix(server): schedule_task updates apply freshSession #34801
main fromrefs/pull/34801/head·merged by juliusmarminge View on GitHubThe schedule_task update handler (apps/server/src/mcp/toolkits/orchestrator/handlers.ts) passed scheduledTaskId, prompt, title, schedule, enabled and bindToCurrentThread to OrchestratorMcpService.updateScheduledTask but not freshSession. The input was dropped, so the call returned success while the task kept its thread mode. updateScheduledTask already handles freshSession, including rejecting bindToCurrentThread:false together with freshSession:true on a bound task, so the fix is to pass freshSession from the handler. No new regex or parser. The bug was reproduced through the failing test from factory/repro-32258, which is kept on the branch and now passes.
Fixes pingdotgg/t3code#32258
Reproduction on main#
On origin/main 4bf5d53d93 I started T3CODE_DEV_SEED=0 vp run dev:server (fresh database, port 13984). A scratch driver issued a short-lived full-access MCP client session the same way t3 thread does and called the server's /mcp endpoint. Steps: (1) t3_project_create, then t3_project_update to set a default model; (2) schedule_task {projectId, prompt:'Weekly check', schedule:{type:'fixed_time', timeOfDay:'09:00', weekdays:[1]}, enabled:false, freshSession:false} returned freshSession:false; (3) schedule_task {scheduledTaskId, projectId, freshSession:true} returned success with freshSession:false; (4) list_scheduled_tasks showed freshSession:false, and the scheduled_tasks row in the worktree's statev2.sqlite still had thread_mode=new_thread. Driver: https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/3a370173a3c2bcfa/driver.mts. The task was unbound; the reporter's was bound, but the field is dropped in the handler before binding is considered. Separately, a test in apps/server/src/mcp/toolkits/core.test.ts that updates an existing task with freshSession:true fails on main (received false) and passes once the handler forwards freshSession.
Evidence#
Create a project and default model through MCP, create a disabled Monday 09:00 task with freshSession:false, then update the existing task with freshSession:true. List tasks and inspect the persisted row. Both sides ran real servers with fresh isolated databases and the same driver.
| Before | After |
|---|---|
| 4bf5d53d93 | 32948f22c2 |
| Captured MCP responses and database row | Captured MCP responses and database row |
Update succeeds but returns freshSession:false; list also returns false; storage remains new_thread. | Update returns freshSession:true; list retains true; storage becomes fresh_session. |
Reproduction driver. Provider and model configuration are supplied through environment variables; no provider turn executes.
AI-assisted; verified with the tests and tools listed above.
Not shown:
- Bound-task behavior was not exercised; this proof follows the supplied unbound-task reproduction.
- Scheduled execution was not exercised because the task remained disabled; the proof covers updating, reading back, and persisting freshSession.
Tests#
vp test run src/mcp/toolkits/core.test.ts -t 'scheduled task that runs above' (apps/server): fails before the fix (freshSession received false). vp test run src/mcp/toolkits/core.test.ts: 20/20 pass after the fix. vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (2 files) all pass.
AI-assisted; verified with the tests and tools listed above.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
32948f2Macroscope's review found this PR approvable — Scheduled-task updates now honor the existing freshSession option. The change preserves defaults and existing access checks, limiting its effect to explicitly requested session-mode updates.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Walkthrough
-
The scheduled-task update handler now forwards
freshSessiontoupdateScheduledTask. A test updates an existing task withfreshSession: trueand checks the returned structured content.Changes: Scheduled-task update
Layer / File(s) Summary Forward and verify freshSession
apps/server/src/mcp/toolkits/orchestrator/handlers.ts,apps/server/src/mcp/toolkits/core.test.tsThe update handler passes freshSessiontoupdateScheduledTask. The test checks that an update totask-autoreturnsfreshSession: true.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- pingdotgg/t3code#31649: Forwards
freshSessionin the scheduled-task update handler and adds a test for the same defect. - pingdotgg/t3code#31696: Forwards
freshSessionin the update handler and tests updating an existing task. - pingdotgg/t3code#32367: Forwards
freshSessionin the update handler and adds an update test for the same issue.
Suggested labels:
bugfix,size:XSSuggested reviewers:
t3dotgg,maria-rcks - pingdotgg/t3code#31649: Forwards
Merge Risk:
Minimal · up to32948-
Updating a scheduled task with freshSession now takes effect instead of silently succeeding without a change. No merge-blocking risk was identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title "fix(server): schedule_task updates apply freshSession" states the main change: the schedule_task update handler now forwards freshSession to updateScheduledTask. It is a conventional commit… Linked Issues check [ #32258] The issue requires that aschedule_taskupdate withfreshSessionchanges the stored value. The reviewed diff addsfreshSessionto the destructured input of the update handler in `apps/s…Out of Scope Changes check All changed hunks serve #32258. The handler change forwards the one missing field. The test change adds a regression assertion for that field on the same update path. The changes do not touch unrelate…Description check The description clearly covers the problem (the schedule_task update handler drops freshSession before calling updateScheduledTask), the change (forwarding freshSession from the handler), and the scop… Full details: Title check
-
Explanation
The title "fix(server): schedule_task updates apply freshSession" states the main change: the schedule_task update handler now forwards freshSession to updateScheduledTask. It is a conventional commit title, specific, and matches the changeset and linked issue
#32258.
Full details: Linked Issues check
-
Explanation
[
#32258] The issue requires that aschedule_taskupdate withfreshSessionchanges the stored value. The reviewed diff addsfreshSessionto the destructured input of the update handler inapps/server/src/mcp/toolkits/orchestrator/handlers.tsand forwards it toupdateScheduledTask. Before this change the handler did not pass the field, so the update reported success without applying it. The added assertion inapps/server/src/mcp/toolkits/core.test.tscallsschedule_taskwithscheduledTaskId: "task-auto"andfreshSession: true, then checks thatstructuredContentcontainsfreshSession: true. This covers the issue's update path. Limits: I did not read theupdateScheduledTaskservice source. I could not locate it within the allowed inspections. Service-side persistence and the bound-task rejection rule rest on the test result and the PR description. The 'Evidence' section is unfinished, but it is not a coding requirement.
Full details: Out of Scope Changes check
-
Explanation
All changed hunks serve
#32258. The handler change forwards the one missing field. The test change adds a regression assertion for that field on the same update path. The changes do not touch unrelated behavior, and the PR adds no new parser or regex, as the description states.
Full details: Description check
-
Explanation
The description clearly covers the problem (the schedule_task update handler drops freshSession before calling updateScheduledTask), the change (forwarding freshSession from the handler), and the scope (links issue
#32258as the bug source). It also gives verification detail: a reproduction on origin/main with before/after commits, unit test results, and the check:changed run. It meets the template's intent. Gaps: the Evidence section links to external transcripts and a driver script, and the Before/After proof covers only unbound tasks, which the author discloses. The Verification section's stated test results are concrete. The template's AI-model attribution line is present ('AI-assisted'), but it does not name the model and harness as the template asks. The template's preamble (conventional commit title) is not evidenced in the title shown in the objectives, which names 'fix(server): schedule_task updates apply freshSession', so that requirement appears satisfied.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-32258
- File: .coderabbit.config.ts
- Commit: 32948f2
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
c101e80c-86f0-4f7b-b923-af1fefbbbc27
Commits-
Reviewing files that changed from the base of the PR and between a18a458f2552ac5cd9dd561a834049b98b202ae9 and 32948f22c2bf116580f44bfb16c8c2b7980bfb44.
Files selected for processing: 2-
apps/server/src/mcp/toolkits/core.test.tsapps/server/src/mcp/toolkits/orchestrator/handlers.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
juliusmarminge merged this18866e5
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
a18a458· PR result:32948f2· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.