fix(server): idle reaper no longer kills in-flight background agent work #4994
ClosedZeus-Deus(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/4994/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- @@ -70,3 +70,4 @@7070 continue;7171 }727273+ // Checked immediately before the stop so the window in which a task can@@ -283,0 +489,21 @@489+ // saw the `task.started`, and an untracked running task is exactly the490+ // case the reaper must not miss.491+ case "task.progress":492+ return Effect.map(Clock.currentTimeMillis, (nowMs) =>493+ rememberOutstandingTask(494+ event.threadId,495+ event.payload.taskId,496+ {497+ provider: event.provider,498+ ...(event.providerInstanceId !== undefined499+ ? { providerInstanceId: event.providerInstanceId }500+ : {}),501+ },502+ nowMs,503+ ),504+ );505+ // The only terminal task event, for every status it can carry.506+ case "task.completed":507+ return Effect.map(Clock.currentTimeMillis, (nowMs) =>508+ forgetOutstandingTask(event.threadId, event.payload.taskId, nowMs),509+ );
- @@ -855,3 +1125,12 @@8551125 if (routed.isActive) {8561126 yield* routed.adapter.stopSession(routed.threadId);8571127 }1128+ // Settled after the adapter stop so that any terminal event the adapter1129+ // had already handed us wins. This is not a complete drain: adapter1130+ // events reach us through a forked per-instance pump, so `stopSession`1131+ // returning does not mean the queue is empty, and a `task.started`1132+ // still in flight can re-add an entry right after `forgetThreadState`.1133+ // The staleness ceiling in `hasOutstandingBackgroundTasks` is what1134+ // bounds those leftovers.1135+ yield* settleOutstandingTasks(input.threadId, TASK_SETTLED_BY_STOP_SUMMARY);1136+ forgetThreadState(input.threadId);
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
596b750d-db15-4d17-b084-7848978d2c43You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share