Skip to content

Commit dc48a23

Browse files
committed
fix(server): hint turn-start run items to the run ordinal index
1 parent 3a4f1d1 commit dc48a23

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/ProjectionStore.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3406,7 +3406,10 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
34063406
detail.includes("orchestration_v2_projection_turn_items"),
34073407
);
34083408
assert.lengthOf(lookup, 1);
3409-
assert.match(lookup[0]!, /^SEARCH .*\(thread_id=\? AND run_id=\?\)$/);
3409+
assert.match(
3410+
lookup[0]!,
3411+
/^SEARCH .*\((?:thread_id=\? AND )?run_id=\?(?: AND thread_id=\?)?\)$/,
3412+
);
34103413
}
34113414
}),
34123415
);

‎apps/server/src/orchestration-v2/ProjectionStore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4299,7 +4299,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
42994299
const turnItems = yield* sql<PayloadRow>`
43004300
SELECT payload_json FROM orchestration_v2_projection_turn_items
43014301
-- Look up one run's items by key, not by walking the thread's whole history in ordinal order.
4302-
INDEXED BY orchestration_v2_projection_turn_items_thread_run_idx
4302+
INDEXED BY orchestration_v2_projection_turn_items_run_ordinal_idx
43034303
WHERE thread_id = ${threadId} AND run_id = ${runId} ORDER BY ordinal ASC, turn_item_id ASC
43044304
`.pipe(Effect.flatMap(decodeRows(decodeTurnItemPayload, threadId)));
43054305
const providerSessions = yield* sql<PayloadRow>`

0 commit comments

Comments
 (0)