Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): settling no longer ends background work the agent is waiting on #31449

MergedKazuya-Hibara(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/31449/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 165 additions and 2 deletions.

x
0 of 2 viewed, 2 left
26 additions and 2 deletionsapps/server/src/orchestration-v2/Orchestrator.tsModified
View file
@@ -4632,7 +4632,14 @@
if (command.type === "thread.settle") {
- const projection = yield* loadProjectionForCommand(command, ["runs", "runtimeRequests"]);
+ const projection = yield* loadProjectionForCommand(
+ command,
+ ["runs", "runtimeRequests", "providerThreads", "turnItems"],
+ {
+ turnItemTypes: ["command_execution", "dynamic_tool", "subagent"],
+ turnItemStatuses: ["pending", "running", "waiting"],
+ },
+ );
command.expectedLatestRunId !== undefined &&
projection.runs.reduce<OrchestrationV2Run | undefined>(
@@ -4679,13 +4686,30 @@
const blockingRequestExists = pendingRequests.some(
(request) => request.kind !== "user_input" || request.responseCapability.type !== "message",
+ // Settling detaches the provider session, which ends the work running inside it. Hold for
+ // the work auto-settle waits on. Delegated tasks run in their own thread and survive.
+ const awaitedSessionWorkExists =
+ !runningRunExists &&
+ backgroundWorkHoldsCompletion(
+ derivePendingBackgroundWork({
+ latestRun: projection.runs.findLast((run) => run.status !== "queued"),
+ providerThreads: projection.providerThreads,
+ turnItems: projection.turnItems.filter(