fix(server): settled and idle-released threads no longer stay Waiting #19355
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits into
main fromrefs/pull/19355/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsmacroscope-review
- apps/server/src/orchestration-v2/ProviderSessionManager.ts line 856OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -776,0 +836,21 @@836+ Effect.gen(function* () {837+ const projection = yield* projectionStore.getThreadRecords(threadId, [838+ "providerThreads",839+ ]);840+ const providerThread = projection.providerThreads.find(841+ (candidate) => candidate.id === providerThreadId,842+ );843+ const tasks = providerThread?.pendingBackgroundTasks ?? [];844+ const remaining = tasks.filter((task) => !taskIds.has(task.taskId));845+ if (providerThread === undefined || remaining.length === tasks.length) return;846+ const now = yield* DateTime.now;847+ yield* eventSink.write({848+ events: [849+ {850+ id: yield* idAllocator.allocate.event({ threadId, providerSessionId }),851+ type: "provider-thread.updated",852+ threadId,853+ driver: providerThread.driver,854+ providerInstanceId: providerThread.providerInstanceId,855+ occurredAt: now,856+ payload: {
- apps/server/src/orchestration-v2/ProviderSessionManager.ts line 826Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -776,0 +799,21 @@799+ ]);800+ for (const providerThread of projection.providerThreads) {801+ const tasks = providerThread.pendingBackgroundTasks ?? [];802+ if (providerThread.providerSessionId !== providerSessionId || tasks.length === 0) {803+ continue;804+ }805+ released.push({806+ threadId,807+ providerSessionId,808+ providerThreadId: providerThread.id,809+ taskIds: new Set(tasks.map((task) => task.taskId)),810+ });811+ }812+ }813+ return released;814+ }).pipe(815+ Effect.catchCause((cause) =>816+ Effect.logWarning("orchestration-v2.provider-session-release-roster-read-failed", {817+ providerSessionId: input.entry.runtime.providerSessionId,818+ cause,819+ }).pipe(Effect.as([])),
- apps/server/src/orchestration-v2/ProviderSessionManager.ts lines 846 to 876Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -776,0 +850,21 @@850+ const { committed } = yield* eventSink.writeIfProviderThreadUnchanged({851+ providerThreadId,852+ expectedUpdatedAt: providerThread.updatedAt,853+ events: [854+ {855+ id: yield* idAllocator.allocate.event({ threadId, providerSessionId }),856+ type: "provider-thread.updated",857+ threadId,858+ driver: providerThread.driver,859+ providerInstanceId: providerThread.providerInstanceId,860+ occurredAt: now,861+ payload: {862+ ...providerThread,863+ pendingBackgroundTasks: remaining,864+ updatedAt: now,865+ },866+ },867+ ],868+ });869+ if (committed) return;870+ }
t3dotgg(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