| … | … | @@ -832,7 +897,9 @@ export const layer = Layer.effect( | |
| 834 | 899 | const runSucceeded = result._tag === "Success"; | |
| 835 | - | const lastRunStatus = runSucceeded ? ("succeeded" as const) : ("failed" as const); | |
| 900 | + | if (!runSucceeded) runOutcomes.forget(messageId); | |
| 901 | + | // A dispatched run is 'running' until its turn ends (see runOutcomes). | |
🟡 Medium scheduledTasks/ScheduledTaskService.ts:901
When a turn outcome arrives before dispatch returns, runTask returns lastRunStatus: "running" and no error even though recordRunOutcome has already stored a terminal succeeded or failed result; runNow therefore reports stale state to its caller. The response derives its status from runSucceeded instead of the reread task, so preserve the matching run’s terminal status and error from current.
🤖 Copy this AI Prompt to have your agent fix this:
| 1 | In file @apps/server/src/scheduledTasks/ScheduledTaskService.ts around line 901: |
| 2 | |
| 3 | When a turn outcome arrives before dispatch returns, `runTask` returns `lastRunStatus: "running"` and no error even though `recordRunOutcome` has already stored a terminal `succeeded` or `failed` result; `runNow` therefore reports stale state to its caller. The response derives its status from `runSucceeded` instead of the reread task, so preserve the matching run’s terminal status and error from `current`. |
Note
🤖 Claude Fable 5.1 on behalf of Mnigos
Fixed in 7886e61d38: runNow re-reads the task after the dispatch is recorded and returns that row, so an outcome that landed first comes back with its status and lastRunError; runTask still reports the dispatch itself, which the webhook delivery log relies on. The outcome-first test now asserts the returned value as well as the stored row.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.