Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): schedule_task updates apply freshSession #34801

Mergedjuliusmarmingemerged 0 commits intomain fromrefs/pull/34801/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The 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.

BeforeAfter
4bf5d53d9332948f22c2
Captured MCP responses and database rowCaptured 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

    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: a18a458 · PR result: 32948f2 · Source CI: success

      Scenario 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.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. Approvability

      Verdict: Approved at 32948f2

      Macroscope'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).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The scheduled-task update handler now forwards freshSession to updateScheduledTask. A test updates an existing task with freshSession: true and 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.ts
      The update handler passes freshSession to updateScheduledTask. The test checks that an update to task-auto returns freshSession: true.

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

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related PRs

      • pingdotgg/t3code#31649: Forwards freshSession in the scheduled-task update handler and adds a test for the same defect.
      • pingdotgg/t3code#31696: Forwards freshSession in the update handler and tests updating an existing task.
      • pingdotgg/t3code#32367: Forwards freshSession in the update handler and adds an update test for the same issue.

      Suggested labels: bugfix, size:XS

      Suggested reviewers: t3dotgg, maria-rcks

      Merge Risk: Minimal · up to 32948

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassed[#32258] The issue requires that a schedule_task update with freshSession changes the stored value. The reviewed diff adds freshSession to the destructured input of the update handler in `apps/s…
      Out of Scope Changes checkPassedAll 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 checkPassedThe 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 a schedule_task update with freshSession changes the stored value. The reviewed diff adds freshSession to the destructured input of the update handler in apps/server/src/mcp/toolkits/orchestrator/handlers.ts and forwards it to updateScheduledTask. Before this change the handler did not pass the field, so the update reported success without applying it. The added assertion in apps/server/src/mcp/toolkits/core.test.ts calls schedule_task with scheduledTaskId: "task-auto" and freshSession: true, then checks that structuredContent contains freshSession: true. This covers the issue's update path. Limits: I did not read the updateScheduledTask service 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 #32258 as 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

      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.ts
      • apps/server/src/mcp/toolkits/orchestrator/handlers.ts

      Limit details: You’ve used all 10 included reviews currently available.

    5. juliusmarminge merged this18866e5

    6. juliusmarminge closed this

Sign in to join this conversation.