Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a failed scheduled run shows its error without a stack trace #29889

Mergedsaphid(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/29889/headmerged by maria-rcks View on GitHub

Problem

When a scheduled task run fails to start, lastRunError holds Cause.pretty(cause). That is the error name plus a multi-line stack trace with server file paths. Triggers include a webhook delivery, a timed run, or Run now, whenever the thread launch or the send to a bound thread fails (for example, the bound thread was deleted). Settings on web ("Scheduled tasks" row) and mobile ("Last run failed: …") show this text, and the MCP list_scheduled_tasks result returns it to agents. So the user sees ThreadManagementThreadNotFoundError: … at file:///…/ScheduledTaskService.ts:… where a plain message would do.

Change

errorMessage in ScheduledTaskService.ts now squashes the cause to its main error and keeps only the message. This matches the existing errorMessage(Cause.squash(cause)) pattern in apps/server/src/mcp/WorktreeMcpService.ts. Both callers benefit: the run-completion record and releaseStuckRun. Webhook delivery-log entries already use fixed messages, so they do not change.

Scope and approval

This is a very small, focused fix for an obvious bug, so there is no prior issue. Users should never see an internal stack trace in a status line. The fix changes 3 lines of one helper and adds one assertion to an existing test.

Overlap search: the local PR index and GitHub search for lastRunError, "stack trace" and scheduled-task error PRs. #23131 (scheduled runs record how their turn ended) and #19774 (report scheduled worktree preparation failures) are open and touch the same file. Neither changes errorMessage or how a cause is turned into the message. #19097 fixed the same class of problem for the provider session banner and was closed without merging.

Verification

  • Red on main: I extended start failures release both replay keys and relay claims for redelivery in ScheduledTaskService.webhook.test.ts to assert lastRunError after the injected start failure. It failed with AssertionError: expected 'Error: injected start failure\n at…' to equal 'injected start failure'.
  • Green: vp test run src/scheduledTasks passed 9 files and 104 tests.
  • vp run check:changed passed format, lint, knip, graphql, typecheck (3 packages) and tests (5 files, 79 tests).
  • Probe of Cause.squash: a typed failure gives its message ("Thread not found."), a defect gives the Error message, and an interrupt-only cause gives "All fibers interrupted without error". The failure types that launch and send declare are Error subclasses.
  • Not checked: a real client capture. The text change has no layout effect.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol on high. Sol verdict: approved.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at 0d6d391

      Macroscope's review found this PR approvable — Failed scheduled runs now show the underlying error message rather than an internal stack trace. The change is confined to failure-status text and does not alter scheduling or execution behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Walkthrough

      The scheduled-task error formatter now uses the message from a squashed Effect Cause when it is an Error, and otherwise stringifies the result. A webhook test checks the recorded error after a failed start.

      Changes: Scheduled task error reporting

      Layer / File(s)Summary
      Format recorded task errors
      apps/server/src/scheduledTasks/ScheduledTaskService.ts, apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts
      The formatter uses the squashed Cause's Error.message when available and otherwise stringifies the result. The webhook test checks that lastRunError is "injected start failure" after a failed start.

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

      Change: Bug fix

      Possibly related PRs

      • pingdotgg/t3code#24561: Changes scheduled-run completion and failure recording in ScheduledTaskService, which uses the error formatter changed here.
      • pingdotgg/t3code#28474: Changes interrupted-run cleanup and releaseStuckRun in ScheduledTaskService, which records errors using the formatter changed here.
      • pingdotgg/t3code#21793: Makes run completion and stuck-run release transactional in the same scheduled-run transition paths.

      Suggested reviewers: juliusmarminge, macroscopeapp

      Merge Risk: Minimal · up to 0d6d3

      The change prevents scheduled-task status errors from exposing stack details while preserving useful failure messages, with no merge-blocking risk identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: scheduled-run errors no longer expose stack traces.
      Description checkPassedThe description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the bug, the implementation, the focused scope, test results, and the unverified client ca…
      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: Description check

      Explanation

      The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the bug, the implementation, the focused scope, test results, and the unverified client capture.

      Finishing Touches
      Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Warning

      Some tools did not complete. Review the errors below.

      ast-grep (0.51.1)

      ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/scala/security/jwt-scala-hardcode-scala.yml

      Usage-based review receipt

      Note

      This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

      CodeRabbit Verify

      • Run CodeRabbit Verify to test the changes in this pull request.
      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between 61c3794c32b0eeebfac09add43e403618c65d2d7 and 0d6d391fd9174f358382a03fead4a65556693a00.

      Files selected for processing: 2
      • apps/server/src/scheduledTasks/ScheduledTaskService.ts
      • apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts

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

    4. maria-rckscommented

      Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      verified as-is at 0d6d391fd9174f358382a03fead4a65556693a00 on a linux boat vm. no source changes or pushes were needed.

      used separate main and pr checkouts, vp i, and one background vp run dev server at a time with isolated state. drove the actual web client with repository playwright and /usr/bin/google-chrome. created a project pointing to a real git checkout and a scheduled task using codex gpt-6.1-sol through the app. no mocks, fixtures, or replay provider.

      • on main 61c3794c32, disabled codex in providers, then used scheduled tasks > actions > run now. the failed row displayed ThreadManagementProviderInstanceDisabledError, server paths, and stack frames.
      • on the exact pr head with the same app-created data, repeated run now. the failed row displayed only Provider instance "codex" is disabled for project 29f719ee-076e-4e4f-bc9e-b629e09d9c3b.
      • re-enabled codex and ran the same task. status became succeeded and the error cleared. the resulting real provider turn completed and rendered SCHEDULED_RUN_OK. repeated failure and recovery successfully; both codex turns completed. pausing the task persisted after reload.
      • blacksmith: vp test run apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts passed 57 tests. vp run check:changed 61c3794c32b0eeebfac09add43e403618c65d2d7 passed format, lint, knip, graphql, typechecks, and 82 tests across 5 files.

      before, main:

      main failed scheduled run exposes stack frames

      after, pr:

      pr failed scheduled run displays only the error message

      run now changes the task from succeeded to a concise failure

      real codex scheduled turn completes with SCHEDULED_RUN_OK

      read-only runtime transcript records main's persisted stack, pr recovery with a null error, and completed codex turns. inspected all captures and checked uploaded video playback and seeking.

      Not verified

      native ios/android and electron shells were not exercised on this linux web-client pass. live webhook delivery, automatic timer firing, bound-thread failures, interruption cleanup, and the mcp listing were not exercised; the real failure used manual run now and a disabled provider. existing automated webhook tests passed, but do not substitute for those live paths.

    5. maria-rcks merged this741bcae

    6. maria-rcks closed this

Sign in to join this conversation.