Skip to content

Commit 7c2b8fb

Browse files
only21milclaude
andcommitted
test(pi): pin an existing thread's loadout after the gateway opt-out
A thread that loaded every T3 tool while the switch was on keeps that loadout after the switch is turned off. The bridge only adds tools, so the smaller requests apply to new threads and to tools not yet loaded. Refs #19190 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c5751e6 commit 7c2b8fb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎packages/provider-pi/src/server/mcpExtensionSource.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,36 @@ describe("Pi MCP tool exposure", () => {
298298
]);
299299
});
300300

301+
it("keeps an existing thread's eager loadout after the gateway opts out", async () => {
302+
const event = { systemPrompt: "" };
303+
const gatewayContext = {
304+
model: { api: "openai-completions" },
305+
sessionManager: { buildSessionProjection: () => ({ messages: [] }) },
306+
ui: { notify: assert.fail },
307+
};
308+
const eager = await loadMcpBridge({ modern: true, toolSearchAvailable: true });
309+
await eager.handlers.get("session_start")!(event, gatewayContext);
310+
const eagerLoadout = [...eager.getActiveTools()];
311+
assert.include(eagerLoadout, "mcp__t3-code__preview_snapshot");
312+
313+
// Pi restores the thread's saved loadout when it resumes under the opt-out.
314+
const bridge = await loadMcpBridge({
315+
modern: true,
316+
toolSearchAvailable: true,
317+
gatewayTools: "called",
318+
});
319+
bridge.restoreActiveTools(eagerLoadout);
320+
for (const hookName of [
321+
"session_start",
322+
"model_select",
323+
"session_tree",
324+
"before_agent_start",
325+
]) {
326+
await bridge.handlers.get(hookName)!(event, gatewayContext);
327+
assert.deepEqual(bridge.getActiveTools(), eagerLoadout);
328+
}
329+
});
330+
301331
it.each(["legacy Pi", "disabled tool search"])(
302332
"keeps tool execution available with %s",
303333
async (mode) => {

0 commit comments

Comments
 (0)