Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): turn starts in long threads no longer read the whole thread #35723

Openjuliusmarmingewants to merge 7 commits intomain fromrefs/pull/35723/headopened View on GitHub

Showing 2 changed files with 26 additions and 0 deletions.

x
0 of 2 viewed, 2 left
24 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionStore.test.tsModified
View file
@@ -7435,6 +7435,30 @@
lookupPlans.push(plan);
+ // A retry handoff reads its missed runs' history; that must not walk every item of the thread.
+ const history = traceSqlStatements();
+ const missedItems = yield* projectionStore
+ .getTurnStartHistory(threadId, [selectedRunId])
+ .pipe(Effect.withTracer(history.tracer));
+ assert.deepEqual(
+ missedItems.map((item) => item.id),
+ selectedIds,
+ );
+ const historyLookup = history.statements.find((statement) =>
+ statement.includes("FROM orchestration_v2_projection_turn_items"),
+ );
+ assert.isDefined(historyLookup);
+ const historyPlan = (yield* sql.unsafe<{ readonly detail: string }>(
+ `EXPLAIN QUERY PLAN ${historyLookup}`,
+ [threadId, selectedRunId],
+ ))
+ .map((row) => row.detail)
+ .join("\n");
+ assert.match(
+ historyPlan,
+ /^SEARCH .*\((?:thread_id=\? AND )?run_id=\?(?: AND thread_id=\?)?\)/m,
+ );
+​
assert.deepEqual((yield* readItems(threadId, emptyRunId)).ids, []);
assert.deepEqual(