Skip to content

Commit b776216

Browse files
committed
test(copilot): keep replay tests inside core boundary
1 parent b5f02b6 commit b776216

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

src/agents/embedded-agent-runner.sanitize-session-history.test.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,23 @@ vi.mock("../plugins/provider-runtime.js", async () => {
7979
const actual = await vi.importActual<typeof import("../plugins/provider-runtime.js")>(
8080
"../plugins/provider-runtime.js",
8181
);
82-
const githubCopilotReplay = await vi.importActual<
83-
typeof import("../../extensions/github-copilot/replay-policy.js")
84-
>("../../extensions/github-copilot/replay-policy.js");
82+
const stripCopilotThinking = (message: AgentMessage): AgentMessage => {
83+
if (message.role !== "assistant" || !Array.isArray(message.content)) {
84+
return message;
85+
}
86+
const content = message.content.filter((block) => {
87+
const type = (block as { type?: unknown }).type;
88+
return type !== "thinking" && type !== "redacted_thinking";
89+
});
90+
if (content.length === message.content.length) {
91+
return message;
92+
}
93+
return {
94+
...message,
95+
content:
96+
content.length > 0 ? content : [{ type: "text", text: OMITTED_ASSISTANT_REASONING_TEXT }],
97+
} as AgentMessage;
98+
};
8599
return {
86100
...actual,
87101
sanitizeProviderReplayHistoryWithPlugin: vi.fn(
@@ -112,7 +126,14 @@ vi.mock("../plugins/provider-runtime.js", async () => {
112126
];
113127
}
114128
if (provider === "github-copilot") {
115-
return githubCopilotReplay.sanitizeGithubCopilotReplayHistory(context as never);
129+
const modelId = ((context as { modelId?: string | null }).modelId ?? "").toLowerCase();
130+
if (!modelId.includes("claude")) {
131+
return context.messages;
132+
}
133+
const messages = context.messages.map(stripCopilotThinking);
134+
return messages.some((message, index) => message !== context.messages[index])
135+
? messages
136+
: context.messages;
116137
}
117138
return context.messages;
118139
},

0 commit comments

Comments
 (0)