Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): sending to a long compacted thread skips its old prompts #36289

Mergedbrauliobo(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/36289/headmerged by maria-rcks View on GitHub

Showing 5 changed files with 98 additions and 15 deletions (loading 3).

x
0 of 5 viewed, 5 left
4 additions and 4 deletionsapps/server/src/orchestration-v2/Orchestrator.tsModified
View file
@@ -6820,9 +6820,9 @@
events: Ref.Ref<Array<OrchestrationV2DomainEvent>>,
effects: Ref.Ref<Array<PendingOrchestrationEffectV2>>,
- // A compacted thread reads every run and turn item, but attempts, nodes, messages and provider
- // turns only for its recent runs and the runs this command names. An idle compaction reads
- // in full: its busy check below looks for a delegated result's message under any old run.
+ // A compacted thread reads every run, but attempts, nodes, messages, provider turns and prompts
+ // only for its recent runs and the runs this command names. An idle compaction reads in full:
+ // its busy check below looks for a delegated result's message under any old run.
let projection = yield* getProjectionWithPendingEvents(
command.threadId,
events,
@@ -7094,7 +7094,7 @@
const userMessages = projection.messages.filter((message) => message.role === "user");
// The recent runs of a compacted thread can hold only a `/compact` while an older prompt
- // exists. Every prompt's turn item is loaded; without one, every user message is checked.
+ // exists, so when every loaded prompt is one, every user message is checked.
const onlyMaintenanceHistory = [
...userMessages,
...projection.turnItems.flatMap((item) => (item.type === "user_message" ? [item] : [])),
94 additions and 11 deletionsapps/server/src/orchestration-v2/ProjectionStore.test.tsModified
View file
@@ -857,7 +857,7 @@
​
// One thread holds every way a run can still matter after a compaction. A run is requested at