fix(claude): preserve interactive MCP requests in bypass

The SDK drops the interaction flag from control requests but forwards the CLI decision reason. Use that reason to preserve requests requiring an answer.
This commit is contained in:
Mohamed Boudra
2026-11-15 12:34:24 +01:00
parent 842d70f658
commit 8f34bbb6ec
2 changed files with 9 additions and 6 deletions
@@ -127,16 +127,18 @@ test("bypass allows execution without publishing permission events and follows l
await expect(result).resolves.toMatchObject({ behavior: "allow", updatedInput: input });
expect(events.filter((event) => event.type.startsWith("permission_"))).toEqual([]);
for (const [mode, tool, toolInput] of [
["bypassPermissions", "AskUserQuestion", { questions: [] }],
["bypassPermissions", "ExitPlanMode", { plan: "Review this" }],
["default", "Bash", input],
["plan", "Bash", input],
for (const [mode, tool, toolInput, decisionReason] of [
["bypassPermissions", "AskUserQuestion", { questions: [] }, undefined],
["bypassPermissions", "ExitPlanMode", { plan: "Review this" }, undefined],
["bypassPermissions", "mcp__survey__answer", {}, "requiresUserInteraction"],
["default", "Bash", input, undefined],
["plan", "Bash", input, undefined],
] as const) {
await session.setMode(mode);
const resolution = requestPermission(tool, toolInput, {
signal: new AbortController().signal,
toolUseID: tool,
decisionReason,
});
const requestEvent = events.at(-1);
expect(requestEvent?.type).toBe("permission_requested");
@@ -5312,7 +5312,8 @@ class ClaudeAgentSession implements AgentSession {
const needsUserAnswer =
toolName === "AskUserQuestion" ||
toolName === "ExitPlanMode" ||
("requiresUserInteraction" in options && options.requiresUserInteraction === true);
// The SDK drops requires_user_interaction but forwards this CLI reason.
options.decisionReason === "requiresUserInteraction";
if (this.currentMode === "bypassPermissions" && !needsUserAnswer) {
return { behavior: "allow", updatedInput: input, toolUseID: options.toolUseID };
}