Skip to content
TypeScript

perf(server): seek live nodes for the subagent recovery probe (#29644)

Julius Marminge8648aea3db09
diff --git a/apps/server/src/orchestration-v2/ProjectionStore.ts b/apps/server/src/orchestration-v2/ProjectionStore.ts
index b214349d90f..1fd0944aa25 100644
--- a/apps/server/src/orchestration-v2/ProjectionStore.ts
+++ b/apps/server/src/orchestration-v2/ProjectionStore.ts
@@ -4098,9 +4098,10 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
AND EXISTS (
SELECT 1 FROM orchestration_v2_projection_nodes AS node
WHERE node.thread_id = subagents.child_thread_id
- AND node.run_id IS NULL
+ -- Matches nodes_live_idx; +run_id keeps thread_run_idx from scanning settled nodes.
+ AND node.status IN ('pending', 'starting', 'running', 'waiting')
+ AND +node.run_id IS NULL
AND node.kind = 'root_turn'
- AND node.status IN ('pending', 'running', 'waiting')
)
UNION
-- No native subagent outlives the provider process that ran it.