@devries-cameron20 / t3code-1 / commits / 1dfc746c8f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-acp): approving a Devin plan never picks its bypass-permissions option (#34474)

Julius Marminge committed Nov 14, 2026 at 20:45 UTC 1dfc746c8f4b22814b16da35cb54900233bfdb27
4 files changed +130 -4
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+110 -1
@@ -234,6 +234,7 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* (
234 }).pipe(Effect.andThen(Queue.offer(offered, undefined)), Effect.asVoid),
235 };
236 const instanceId = ProviderInstanceId.make("claude-lifecycle");
237 + const outgoing = yield* Queue.unbounded<unknown>();
238 let onTermination: NonNullable<
239 AcpSessionRuntime.AcpSessionRuntimeOptions["onTermination"]
240 > = () => Effect.die("Runtime has not started");
@@ -255,7 +256,17 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* (
256 ...(continuationEnabled ? { continuationRequests } : {}),
257 makeRuntime: (runtimeInput: Parameters<typeof replayRuntime>[0]) => {
258 onTermination = runtimeInput.onTermination;
258 - return replayRuntime(runtimeInput);
259 + return replayRuntime({
260 + ...runtimeInput,
261 + protocolLogging: {
262 + logIncoming: false,
263 + logOutgoing: true,
264 + logger: (event) =>
265 + event.stage === "raw" && typeof event.payload === "string"
266 + ? Queue.offer(outgoing, JSON.parse(event.payload)).pipe(Effect.asVoid)
267 + : Effect.void,
268 + },
269 + });
270 },
271 };
272 const adapter = yield* makeAcpRegistryAdapterV2(adapterOptions).pipe(
@@ -365,6 +376,7 @@ const openClaudeReplaySession = Effect.fn("openClaudeReplaySession")(function* (
376 terminal,
377 offers,
378 offered,
379 + outgoing,
380 terminate: () =>
381 onTermination(
382 new EffectAcpErrors.AcpTransportError({
@@ -2274,6 +2286,103 @@ describe("AcpRegistryAdapterV2", () => {
2286 }).pipe(Effect.provide(layerTest)),
2287 );
2288
2289 + it.effect("approves Devin's plan without choosing a bypass option it lists first", () =>
2290 + Effect.gen(function* () {
2291 + const session = yield* openClaudeReplaySession(
2292 + [
2293 + ...claudeFrames.open.map((entry) =>
2294 + entry.frame.method === "initialize" && entry.type === "emit_inbound"
2295 + ? {
2296 + ...entry,
2297 + frame: {
2298 + ...entry.frame,
2299 + result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] },
2300 + },
2301 + }
2302 + : entry,
2303 + ),
2304 + {
2305 + type: "expect_outbound",
2306 + frame: { kind: "request", method: "session/prompt", params: "<any>" },
2307 + },
2308 + claudeFrames.update(CLAUDE_ROOT_SESSION, {
2309 + sessionUpdate: "tool_call",
2310 + toolCallId: "exit-plan",
2311 + title: "Exit plan mode",
2312 + kind: "switch_mode",
2313 + status: "pending",
2314 + }),
2315 + {
2316 + type: "emit_inbound",
2317 + frame: {
2318 + kind: "request",
2319 + method: "session/request_permission",
2320 + params: {
2321 + sessionId: CLAUDE_ROOT_SESSION,
2322 + toolCall: { toolCallId: "exit-plan" },
2323 + // Devin gives both plan approvals allow_once and does not promise their order.
2324 + options: [
2325 + {
2326 + optionId: "plan_bypass",
2327 + name: "Yes, implement plan and bypass permissions",
2328 + kind: "allow_once",
2329 + },
2330 + {
2331 + optionId: "plan_accept_edits",
2332 + name: "Yes, implement plan and accept edits",
2333 + kind: "allow_once",
2334 + },
2335 + { optionId: "reject_once", name: "No, plan needs changes", kind: "reject_once" },
2336 + ],
2337 + },
2338 + },
2339 + },
2340 + {
2341 + type: "expect_outbound",
2342 + frame: {
2343 + kind: "response",
2344 + method: "session/request_permission",
2345 + result: { outcome: { outcome: "selected", optionId: "<any>" } },
2346 + },
2347 + },
2348 + {
2349 + type: "emit_inbound",
2350 + frame: {
2351 + kind: "response",
2352 + method: "session/prompt",
2353 + result: { stopReason: "end_turn" },
2354 + },
2355 + },
2356 + claudeFrames.closeRequest,
2357 + claudeFrames.closed,
2358 + ],
2359 + undefined,
2360 + false,
2361 + "devin",
2362 + );
2363 + yield* session.runtime.startTurn(session.turnInput(1)).pipe(Effect.forkScoped);
2364 + const seen = yield* session.until(
2365 + (event) =>
2366 + event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending",
2367 + );
2368 + const request = seen.at(-1)!;
2369 + if (request.type !== "runtime_request.updated") throw new Error("Missing request");
2370 + yield* session.runtime.respondToRuntimeRequest({
2371 + requestId: request.runtimeRequest.id,
2372 + decision: "accept",
2373 + });
2374 + let answer: unknown;
2375 + while (answer === undefined) {
2376 + const frame = (yield* Queue.take(session.outgoing)) as {
2377 + readonly result?: { readonly outcome?: { readonly optionId?: string } };
2378 + };
2379 + answer = frame.result?.outcome;
2380 + }
2381 + assert.deepEqual(answer, { outcome: "selected", optionId: "plan_accept_edits" });
2382 + assert.equal((yield* session.terminal).status, "completed");
2383 + }).pipe(Effect.provide(layerTest), Effect.scoped),
2384 + );
2385 +
2386 it.effect("keeps stopped child tools interrupted when a late output chunk arrives", () =>
2387 Effect.gen(function* () {
2388 const { update } = claudeFrames;
packages/provider-acp-registry/src/server/adapter.ts
+2
@@ -7,6 +7,7 @@ import {
7 normalizeDevinSessionUpdate,
8 normalizeDevinToolCall,
9 extractDevinSubagentUpdate,
10 + devinAnswerablePermissionOptions,
11 } from "./devinAcp.ts";
12 import { extractDroidElicitationForm } from "./droidAcp.ts";
13 import { extractOmpElicitationForm } from "./ompAcp.ts";
@@ -268,6 +269,7 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
269 normalizeSessionUpdate: normalizeDevinSessionUpdate,
270 normalizeToolCall: normalizeDevinToolCall,
271 extractSubagentUpdate: extractDevinSubagentUpdate,
272 + answerablePermissionOptions: devinAnswerablePermissionOptions,
273 }
274 : {}),
275 ...(copilotRouting === undefined
packages/provider-acp-registry/src/server/devinAcp.ts
+7
@@ -54,3 +54,10 @@ export function extractDevinSubagentUpdate(
54 result: typeof completed?.summary === "string" ? completed.summary : null,
55 };
56 }
57 +
58 +// Devin's plan exit offers several allow_once options in no promised order; T3 never answers with bypass.
59 +export function devinAnswerablePermissionOptions(
60 + request: AcpSchema.RequestPermissionRequest,
61 +): ReadonlyArray<AcpSchema.PermissionOption> {
62 + return request.options.filter((option) => option.optionId.trim() !== "plan_bypass");
63 +}
packages/provider-acp/src/server/adapter.ts
+11 -3
@@ -486,6 +486,10 @@ export interface AcpAdapterV2Flavor {
486 readonly approvalOptions?: (
487 request: EffectAcpSchema.RequestPermissionRequest,
488 ) => ReadonlyArray<ProviderApprovalOption>;
489 + /** Options T3 may answer with; the rest (e.g. Devin's bypass-permissions plan exit) are never sent. */
490 + readonly answerablePermissionOptions?: (
491 + request: EffectAcpSchema.RequestPermissionRequest,
492 + ) => ReadonlyArray<EffectAcpSchema.PermissionOption>;
493 readonly onSessionEvent?: (
494 event: AcpSessionRuntime.AcpSessionRuntimeEvent,
495 ) => Effect.Effect<void>;
@@ -6861,6 +6865,10 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6865 yield* userInput.acknowledgeNativeResponse;
6866 return response ?? ({ outcome: { outcome: "cancelled" } } as const);
6867 }
6868 + const answerableParams =
6869 + flavor.answerablePermissionOptions === undefined
6870 + ? params
6871 + : { ...params, options: flavor.answerablePermissionOptions(params) };
6872 const dispositionFor = (
6873 policy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
6874 request: EffectAcpSchema.RequestPermissionRequest = params,
@@ -6887,7 +6895,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6895 : params,
6896 );
6897 if (disposition === "allow") {
6890 - const optionId = selectAutoApprovedPermissionOption(params);
6898 + const optionId = selectAutoApprovedPermissionOption(answerableParams);
6899 return {
6900 _tag: "Immediate" as const,
6901 response:
@@ -6897,7 +6905,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6905 };
6906 }
6907 if (disposition === "deny") {
6900 - const optionId = selectPermissionOptionId(params, "decline");
6908 + const optionId = selectPermissionOptionId(answerableParams, "decline");
6909 return {
6910 _tag: "Immediate" as const,
6911 response:
@@ -6979,7 +6987,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6987 if (decision === "cancel") {
6988 return { outcome: { outcome: "cancelled" } } as const;
6989 }
6982 - const optionId = selectPermissionOptionId(params, decision);
6990 + const optionId = selectPermissionOptionId(answerableParams, decision);
6991 return optionId === undefined
6992 ? ({ outcome: { outcome: "cancelled" } } as const)
6993 : ({ outcome: { outcome: "selected", optionId } } as const);