Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/server/src/orchestration-v2/freshProviderContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ it.effect.each(["none", "background", "turn", "metadata"] as const)(
bootstrap: "Role; complete handoff; lessons pointer.",
},
};
// The idle policy is the client's: a just-completed, unchanged snapshot is accepted.
assert.equal(
typeof prepareFreshProviderThread(before, command, now),
"string",
"NO: less than 30 minutes",
"object",
"server must not re-impose a thread-updatedAt idle window",
);
yield* TestClock.adjust("31 minutes");
yield* TestClock.adjust("1 minute");
const later = yield* DateTime.now;
const refuse = (records: typeof before, cmd = command) =>
assert.equal(typeof prepareFreshProviderThread(records, cmd, later), "string");
Expand Down
8 changes: 2 additions & 6 deletions apps/server/src/orchestration-v2/freshProviderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export function preserveFreshContext(

// Refuse before emitting anything. The command's timestamp is a compare-and-swap
// against the saved handoff's snapshot, including input queued since that snapshot.
// The idle window is the client's: automated turns bump updatedAt, so only the
// client can measure time since the human's last message.
export function prepareFreshProviderThread(
records: ProjectionRecords<
"providerThreads" | "runs" | "providerTurns" | "runtimeRequests" | "subagents" | "turnItems"
Expand Down Expand Up @@ -57,12 +59,6 @@ export function prepareFreshProviderThread(
) {
return "Thread changed since the handoff snapshot.";
}
if (
DateTime.toEpochMillis(now) - DateTime.toEpochMillis(records.thread.updatedAt) <
30 * 60_000
) {
return "Thread has not been idle for 30 minutes.";
}
if (!seed.bootstrap.trim() || new TextEncoder().encode(seed.bootstrap).length >= 5_000) {
return "Bootstrap must contain fewer than 5000 UTF-8 bytes.";
}
Expand Down
Loading