fix(server): keep Claude CLI alive across Stop #8997
ClosedTONiiV(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/8997/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -4614,0 +4616,21 @@4616+ // `git status` in the cached prefix, so a dirty tree re-bills the4617+ // whole conversation as cache writes (anthropics/claude-code#78720,4618+ // pingdotgg/t3code#7338). interrupt() alone can leave subagents4619+ // running, so stop live tasks first. If any remain, fall back to4620+ // close — that is the hard stop from #5891 for runaway fleets.4621+ if (context.query.stopTask && context.liveTaskIds.size > 0) {4622+ const liveIds = Array.from(context.liveTaskIds);4623+ yield* Effect.forEach(4624+ liveIds,4625+ (taskId) =>4626+ Effect.gen(function* () {4627+ const stopAcknowledged = yield* Effect.tryPromise({4628+ // Invoke through the query object: SDK methods rely on `this`.4629+ try: () => context.query.stopTask!(taskId),4630+ catch: () => undefined,4631+ }).pipe(4632+ Effect.timeout("3 seconds"),4633+ Effect.as(true),4634+ Effect.catch(() => Effect.succeed(false)),4635+ );4636+ if (!stopAcknowledged || !context.liveTaskIds.delete(taskId)) {@@ -4614,0 +4653,21 @@4653+ payload: {4654+ taskId: RuntimeTaskId.make(taskId),4655+ status: "stopped",4656+ ...taskLinkageFor(context.taskAgents, taskId),4657+ },4658+ providerRefs: nativeProviderRefs(context),4659+ });4660+ }).pipe(Effect.ignore),4661+ { concurrency: 8, discard: true },4662+ ).pipe(Effect.timeout("10 seconds"), Effect.ignore);4663+ }4664+4665+ if (context.liveTaskIds.size > 0) {4666+ yield* stopSessionInternal(context);4667+ return;4668+ }4669+4670+ yield* Effect.tryPromise({4671+ try: () => context.query.interrupt(),4672+ catch: (cause) => toRequestError(threadId, "turn/interrupt", cause),4673+ });
- @@ -4614,0 +4657,21 @@4657+ },4658+ providerRefs: nativeProviderRefs(context),4659+ });4660+ }).pipe(Effect.ignore),4661+ { concurrency: 8, discard: true },4662+ ).pipe(Effect.timeout("10 seconds"), Effect.ignore);4663+ }4664+4665+ if (context.liveTaskIds.size > 0) {4666+ yield* stopSessionInternal(context);4667+ return;4668+ }4669+4670+ yield* Effect.tryPromise({4671+ try: () => context.query.interrupt(),4672+ catch: (cause) => toRequestError(threadId, "turn/interrupt", cause),4673+ });4674+4675+ if (context.turnState) {4676+ yield* completeTurn(context, "interrupted");4677+ }@@ -4614,0 +4657,21 @@4657+ },4658+ providerRefs: nativeProviderRefs(context),4659+ });4660+ }).pipe(Effect.ignore),4661+ { concurrency: 8, discard: true },4662+ ).pipe(Effect.timeout("10 seconds"), Effect.ignore);4663+ }4664+4665+ if (context.liveTaskIds.size > 0) {4666+ yield* stopSessionInternal(context);4667+ return;4668+ }4669+4670+ yield* Effect.tryPromise({4671+ try: () => context.query.interrupt(),4672+ catch: (cause) => toRequestError(threadId, "turn/interrupt", cause),4673+ });4674+4675+ if (context.turnState) {4676+ yield* completeTurn(context, "interrupted");4677+ }
TONiiV(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed