Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): wake the agent when Claude exits while it awaits background work #30214

Mergedjuliusmarmingemerged 7 commits intomain fromrefs/pull/30214/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 37 additions and 8 deletions (loading 5).

x
0 of 6 viewed, 6 left
37 additions and 8 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsModified
View file
@@ -7117,13 +7117,15 @@
nativeThreadId: string,
options?: {
readonly status?: OrchestrationV2ProviderThread["status"];
+ /** The process exited on its own, taking work whose outcome had not reached the agent. */
+ readonly exitedUnexpectedly?: boolean;
- const hadRoster =
- rosterForNativeThread(
- yield* Ref.get(pendingBackgroundTasksByNativeThread),
- nativeThreadId,
- ).size > 0;
+ const roster = rosterForNativeThread(
+ yield* Ref.get(pendingBackgroundTasksByNativeThread),
+ nativeThreadId,
+ );
+ const hadRoster = roster.size > 0;
const remembered = (yield* Ref.get(lastProviderThreadByNativeThread)).get(nativeThreadId);
const hadPersistedRoster = (remembered?.pendingBackgroundTasks?.length ?? 0) > 0;
const priorOpaqueTombstones = taskIdSetForNativeThread(
@@ -7142,6 +7144,21 @@
const preservedOpaqueTombstones = [...priorOpaqueTombstones].filter((taskId) =>
bufferedTaskNotificationIds.has(taskId),
+ // Idle outcomes reach Claude only through a wake; a requested one still delivers its buffer.
+ const wakeRequested = (yield* Ref.get(requestedContinuations)).has(nativeThreadId);
+ const lostBackgroundTasks =
+ options?.exitedUnexpectedly === true