Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server): compact idle threads before the prompt cache expires #19662

Closedmaria-rckswants to merge 28 commits intomain fromt3/idle-session-compactionopened View on GitHub

Showing 59 changed files with 17 additions and 3 deletions (loading 56).

x
0 of 59 viewed, 59 left
4 additions and 1 deletionapps/mobile/src/state/use-thread-selection.tsModified
View file
@@ -46,9 +46,12 @@
function latestUserMessageAt(
projection: OrchestrationV2ThreadProjection,
): OrchestrationV2ThreadShell["latestUserMessageAt"] {
+ const idleRunIds = new Set(
+ projection.runs.filter((run) => run.idleCompactionOfRunId !== undefined).map((run) => run.id),
+ );
for (let index = projection.messages.length - 1; index >= 0; index -= 1) {
const message = projection.messages[index];
- if (message?.role === "user") {
+ if (message?.role === "user" && (message.runId === null || !idleRunIds.has(message.runId))) {
return message.createdAt;
8 additions and 0 deletionsapps/server/src/cli/config.tsModified
View file
@@ -100,6 +100,13 @@
traceMaxBytes: Config.Int("T3CODE_TRACE_MAX_BYTES").pipe(Config.withDefault(10 * 1024 * 1024)),
traceMaxFiles: traceMaxFilesConfig,
traceBatchWindowMs: Config.Int("T3CODE_TRACE_BATCH_WINDOW_MS").pipe(Config.withDefault(1_000)),
+ idleCompactionDelayMs: Config.Int("T3CODE_IDLE_COMPACTION_DELAY_MS").pipe(
+ Config.option,
+ Config.map((value) => {
+ const delay = Option.getOrUndefined(value);
+ return delay === undefined ? undefined : Math.max(0, delay);
+ }),
+ ),
otlpTracesUrl: Config.String("T3CODE_OTLP_TRACES_URL").pipe(