Skip to content

Commit 8682a42

Browse files
fix(server): Plan session grants leave hook-forced asks to the user
A PreToolUse hook that returns permissionDecision "ask" reaches canUseTool with decisionReasonType "hook". Such asks no longer record or reuse the cached Plan session grant. AI-assisted; verified with the tests and tools listed above.
1 parent 4a4b434 commit 8682a42

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
47034703
for (const [toolUseID, askFlags] of [
47044704
["read-ask-rule", { matchedAskRule: { source: "userSettings", toolName } }],
47054705
["read-rule-reason", { decisionReasonType: "rule" }],
4706+
["read-hook-ask", { decisionReasonType: "hook" }],
47064707
["read-needs-person", { requiresUserInteraction: true }],
47074708
["read-safety-check", { decisionReasonType: "safetyCheck" }],
47084709
] as const) {

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,7 @@ export function permissionResultFromDecision(input: {
37903790
}
37913791

37923792
// The SDK forwards these at runtime without typing them. Each marks an ask that no stored
3793-
// grant may answer: an ask rule, a safety check, or a card the user answers on.
3793+
// grant may answer: an ask rule, a hook's ask, a safety check, or a card the user answers on.
37943794
function askNeedsPerson(callbackOptions: Parameters<CanUseTool>[2]): boolean {
37953795
const untyped = callbackOptions as Parameters<CanUseTool>[2] & {
37963796
readonly requiresUserInteraction?: boolean;
@@ -3799,6 +3799,7 @@ function askNeedsPerson(callbackOptions: Parameters<CanUseTool>[2]): boolean {
37993799
return (
38003800
untyped.requiresUserInteraction === true ||
38013801
untyped.decisionReasonType === "rule" ||
3802+
untyped.decisionReasonType === "hook" ||
38023803
untyped.decisionReasonType === "safetyCheck"
38033804
);
38043805
}

0 commit comments

Comments
 (0)