Skip to content
Merged
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
9 changes: 4 additions & 5 deletions apps/server/src/orchestration-v2/WireProjection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,10 @@ function remember<K, V>(memory: Map<K, V>, key: K, value: V): void {
}

/**
* One per subscription, applied after coalescing so it only remembers records the client
* received, in the snapshot or in events. A record event comes before the turn item that repeats
* its body (adapters and the orchestrator emit them in that order), so the item can ship blank
* and marked; so can a repeated subagent record. Emitting in the other order, or forgetting a
* record, only costs bytes: the repeat ships whole.
* One per subscription, after coalescing, so it remembers only records the client received. A
* record event comes before the turn item that repeats its body, so the item (or a repeated
* subagent record) ships blank and marked. The other order, or a forgotten record, only costs
* bytes: the repeat ships whole.
*/
export function makeLiveBodyDeduper(): (
item: OrchestrationV2ThreadStreamItem,
Expand Down
10 changes: 4 additions & 6 deletions packages/contracts/src/orchestrationV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,10 @@ export const OrchestrationV2SubagentWorkflow = Schema.Struct({
export type OrchestrationV2SubagentWorkflow = typeof OrchestrationV2SubagentWorkflow.Type;

/**
* Wire-only. Set for clients that opted in with `acceptDedupedBodies` or `dedupeBodies=1` when the
* marked field was blanked because the client already holds the same value: in the record it
* received earlier on the same response or stream. Restore with
* `@t3tools/shared/orchestrationV2DedupedBodies` before use; never store or forward a marked
* value. Clients that opted in restore only these fields, so blanking another field needs a new
* opt-in.
* Wire-only, for clients that opted in with `acceptDedupedBodies` or `dedupeBodies=1`: the field
* was blanked because an earlier record on the same response or stream holds the same value.
* Restore with `@t3tools/shared/orchestrationV2DedupedBodies`; never store or forward a marked
* value. Clients restore only these fields, so blanking another field needs a new opt-in.
*/
const DedupedBodyMarker = Schema.optionalKey(Schema.Literal(true));

Expand Down
9 changes: 4 additions & 5 deletions packages/shared/src/orchestrationV2DedupedBodies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {
import * as Schema from "effect/Schema";

/**
* A turn item repeats a body its record already carries: message text, checkpoint files, a
* subagent's prompt and result. For clients that opt in, the server blanks the repeat and marks
* the field (`textOmitted`, `filesOmitted`, `promptOmitted`, `resultOmitted`), and the client
* copies the value back from the record it already holds. Only a body equal to the record's is
* blanked, so the restore is exact.
* For clients that opt in, the server blanks a turn item's body that its record already carries
* (message text, checkpoint files, a subagent's prompt and result) and marks the field. The client
* copies the value back from the record. Only a body equal to the record's is blanked, so the
* restore is exact.
*/
export interface DedupedBodySource {
readonly messageText: (id: MessageId) => string | undefined;
Expand Down
Loading