@@ -967,7 +967,10 @@ describe("ClaudeAdapterV2 append-system-prompt-file launch argument", () => {
967967describe("ClaudeAdapterV2 approval cancellation", () => {
968968 it.effect("observes an approval signal that was already aborted", () =>
969969 Effect.gen(function* () {
970- const decision = yield* Deferred.make<ProviderApprovalDecision>();
970+ const decision = yield* Deferred.make<{
971+ decision: ProviderApprovalDecision;
972+ feedback?: string;
973+ }>();
971974 const controller = new AbortController();
972975 controller.abort();
973976
@@ -976,7 +979,7 @@ describe("ClaudeAdapterV2 approval cancellation", () => {
976979 controller.signal,
977980 );
978981
979- assert.equal (result, "cancel");
982+ assert.deepEqual (result, { decision: "cancel" } );
980983 }),
981984 );
982985});
@@ -2873,12 +2876,14 @@ describe("ClaudeAdapterV2 background wake turns", () => {
28732876 turn: Effect.Success<ReturnType<typeof openPlanTurn>>,
28742877 toolName: string,
28752878 toolInput: Record<string, unknown>,
2879+ options?: { toolUseID: string; agentID?: string },
28762880 ) {
28772881 const decision = yield* Effect.promise(() =>
28782882 turn.canUseTool(toolName, toolInput, {
28792883 signal: new AbortController().signal,
2880- toolUseID: "tool-plan-write",
2884+ toolUseID: options?.toolUseID ?? "tool-plan-write",
28812885 requestId: "request-plan-write",
2886+ ...(options?.agentID === undefined ? {} : { agentID: options.agentID }),
28822887 }),
28832888 ).pipe(Effect.forkScoped);
28842889 const first = yield* Effect.raceFirst(
@@ -2954,6 +2959,61 @@ describe("ClaudeAdapterV2 background wake turns", () => {
29542959 ),
29552960 );
29562961
2962+ it.effect(
2963+ "returns approval feedback to the requesting tool without sending a parent prompt",
2964+ () =>
2965+ Effect.gen(function* () {
2966+ const turn = yield* openPlanTurn("full-access");
2967+ const parentPermission = yield* requestWrite(
2968+ turn,
2969+ "Bash",
2970+ { command: "git status" },
2971+ { toolUseID: "parent-command" },
2972+ );
2973+ assert.equal(parentPermission.first.type, "request");
2974+ if (parentPermission.first.type !== "request") return;
2975+ const permission = yield* requestWrite(
2976+ turn,
2977+ "Bash",
2978+ { command: "rm -f $W/*/*.obj" },
2979+ { toolUseID: "child-command", agentID: "child-worker" },
2980+ );
2981+ assert.equal(permission.first.type, "request");
2982+ if (permission.first.type !== "request") return;
2983+ const request = permission.first.event.runtimeRequest;
2984+ assert.equal(request.responseCapability.type, "live");
2985+ assert.isTrue(
2986+ request.responseCapability.type === "live" &&
2987+ request.responseCapability.supportsFeedback,
2988+ );
2989+ yield* turn.runtime.respondToRuntimeRequest({
2990+ requestId: request.id,
2991+ decision: "decline",
2992+ feedback: "Run it in a safer manner.",
2993+ });
2994+ const result = yield* Fiber.join(permission.decision);
2995+ assert.equal(result?.behavior, "deny");
2996+ if (result?.behavior === "deny") {
2997+ assert.include(result.message, "Run it in a safer manner.");
2998+ assert.notProperty(result, "interrupt");
2999+ }
3000+ assert.equal(turn.offeredMessages.length, 1);
3001+ yield* turn.runtime.respondToRuntimeRequest({
3002+ requestId: parentPermission.first.event.runtimeRequest.id,
3003+ decision: "accept",
3004+ });
3005+ const parentResult = yield* Fiber.join(parentPermission.decision);
3006+ assert.equal(parentResult?.behavior, "allow");
3007+ if (parentResult?.behavior === "allow")
3008+ assert.equal(parentResult.toolUseID, "parent-command");
3009+ }).pipe(
3010+ Effect.scoped,
3011+ Effect.provide(
3012+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
3013+ ),
3014+ ),
3015+ );
3016+
29573017 it.effect("still captures ExitPlanMode when Plan approvals are never allowed", () =>
29583018 Effect.gen(function* () {
29593019 const turn = yield* openPlanTurn("full-access", "never");
0 commit comments