Skip to content
TypeScript

fix(server): handoff context names every file of a multi-file patch (#29905)

Alex Southwelle5d071087607
diff --git a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
index c4068702e3a..71d9cf3dada 100644
--- a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
+++ b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
@@ -137,6 +137,19 @@ describe("handoff budget", () => {
assert.equal(command?.kind, "command_execution");
assert.include(command!.text, "Exit code: 1");
assert.include(command!.text, "界".repeat(300));
+ assert.equal(
+ historicalMessage({
+ ...base,
+ type: "file_change",
+ fileName: "src/a.ts",
+ changes: [
+ { operation: "update", path: "src/a.ts" },
+ { operation: "add", path: "src/b.ts" },
+ { operation: "update", path: "src/new.ts", oldPath: "src/old.ts" },
+ ],
+ })?.text,
+ "File change: src/a.ts, src/b.ts, src/new.ts",
+ );
assert.isNull(
historicalMessage({
...base,
diff --git a/apps/server/src/orchestration-v2/ContextHandoffService.test.ts b/apps/server/src/orchestration-v2/ContextHandoffService.test.ts
index 0282819d81b..78958c2e317 100644
--- a/apps/server/src/orchestration-v2/ContextHandoffService.test.ts
+++ b/apps/server/src/orchestration-v2/ContextHandoffService.test.ts
@@ -210,6 +210,36 @@ it.effect("caps the side chat context block without summarizing discarded parent
});
assert.isTrue(framingOnly.startsWith("You are in a side chat beside the main thread."));
assert.notInclude(framingOnly, "Main thread activity");
+
+ const multiFilePatch = ContextHandoffService.makeSideChatContext({
+ parentThreadId,
+ digest: [
+ {
+ id: TurnItemId.make("turn-item:patch"),
+ threadId: parentThreadId,
+ runId: null,
+ nodeId: null,
+ providerThreadId: null,
+ providerTurnId: null,
+ nativeItemRef: null,
+ parentItemId: null,
+ ordinal: 60,
+ status: "completed",
+ title: null,
+ startedAt: null,
+ completedAt: null,
+ updatedAt: DateTime.makeUnsafe(0),
+ type: "file_change",
+ fileName: "src/a.ts",
+ changes: [
+ { operation: "update", path: "src/a.ts" },
+ { operation: "add", path: "src/b.ts" },
+ { operation: "update", path: "src/new.ts", oldPath: "src/old.ts" },
+ ],
+ },
+ ],
+ });
+ assert.include(multiFilePatch, "- File change: src/a.ts, src/b.ts, src/new.ts");
}).pipe(Effect.provide(layerTest)),
);
diff --git a/apps/server/src/orchestration-v2/ContextHandoffService.ts b/apps/server/src/orchestration-v2/ContextHandoffService.ts
index dcfffa018c8..10f27014462 100644
--- a/apps/server/src/orchestration-v2/ContextHandoffService.ts
+++ b/apps/server/src/orchestration-v2/ContextHandoffService.ts
@@ -213,7 +213,7 @@ function summarizeDeltaItem(item: OrchestrationV2TurnItem): string | null {
case "command_execution":
return `- Command: ${compactText(item.input)}`;
case "file_change":
- return `- File change: ${item.fileName}`;
+ return `- File change: ${compactText(item.changes?.map((change) => change.path).join(", ") ?? item.fileName)}`;
case "checkpoint":
return `- Checkpoint: ${item.files.length} files`;
case "handoff":
diff --git a/packages/provider-core/src/server/handoffBudget.ts b/packages/provider-core/src/server/handoffBudget.ts
index 4658bc44fc6..b1c98806f29 100644
--- a/packages/provider-core/src/server/handoffBudget.ts
+++ b/packages/provider-core/src/server/handoffBudget.ts
@@ -147,7 +147,7 @@ export function historicalMessage(
text = item.message;
break;
case "file_change":
- text = `File change: ${item.fileName}`;
+ text = `File change: ${item.changes?.map((change) => change.path).join(", ") ?? item.fileName}`;
break;
case "proposed_plan":
text = item.markdown;