Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 119 additions & 10 deletions apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11892,30 +11892,49 @@ describe("CodexAdapterV2 post-settle continuation", () => {
const startApprovalTurn = (
scenario: string,
entries: ReadonlyArray<CodexReplay.CodexAppServerReplayEntry>,
runtimeMode: "auto-accept-edits" | "full-access" = "auto-accept-edits",
) =>
Effect.gen(function* () {
const pending = yield* Queue.unbounded<OrchestrationV2RuntimeRequest>();
const harness = yield* makeCodexReplayHarness(
makeCodexReplayTranscript({
scenario,
entries: [...codexReplayPreamble({ nativeThreadId, nativeTurnId, prompt }), ...entries],
entries: [
...codexReplayPreamble({
nativeThreadId,
nativeTurnId,
prompt,
...(runtimeMode === "full-access"
? {}
: {
turnPolicy: {
approvalPolicy: "on-request",
sandboxPolicy: { type: "workspaceWrite" },
},
}),
}),
...entries,
],
}),
(event) =>
event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending"
? Queue.offer(pending, event.runtimeRequest)
: Effect.void,
);
yield* harness.runtime.startTurn(
makeCodexTestTurnInput({
threadId: harness.threadId,
providerThread: harness.providerThread,
now: yield* DateTime.now,
attemptId: RunAttemptId.make(`${scenario}-attempt`),
text: prompt,
}),
);
const turnInput = makeCodexTestTurnInput({
threadId: harness.threadId,
providerThread: harness.providerThread,
now: yield* DateTime.now,
attemptId: RunAttemptId.make(`${scenario}-attempt`),
text: prompt,
});
yield* harness.runtime.startTurn({
...turnInput,
runtimePolicy: { ...turnInput.runtimePolicy, runtimeMode },
});
return {
harness,
pending,
answerNext: Queue.take(pending).pipe(
Effect.tap((request) =>
harness.runtime.respondToRuntimeRequest({
Expand Down Expand Up @@ -12059,6 +12078,96 @@ describe("CodexAdapterV2 post-settle continuation", () => {
),
);

it.effect("answers every approval itself in full access", () =>
Effect.gen(function* () {
const answered = (
id: number,
method: string,
params: Record<string, unknown>,
result: Record<string, unknown>,
): Array<CodexReplay.CodexAppServerReplayEntry> => [
{ type: "emit_inbound", label: method, frame: { id, method, params } },
{ type: "expect_outbound", label: method, frame: { id, result } },
];
const permissions = { fileSystem: { write: ["/w/out"] } };
const { harness, pending } = yield* startApprovalTurn(
"full-access-approvals",
[
...answered(
0,
"item/commandExecution/requestApproval",
{
threadId: nativeThreadId,
turnId: nativeTurnId,
itemId: "rm",
startedAtMs: 2,
command: "rm -rf /w/tmp",
},
{ decision: "accept" },
),
...answered(
1,
"item/fileChange/requestApproval",
{ threadId: nativeThreadId, turnId: nativeTurnId, itemId: "patch", startedAtMs: 2 },
{ decision: "accept" },
),
...answered(
2,
"item/permissions/requestApproval",
{
threadId: nativeThreadId,
turnId: nativeTurnId,
itemId: "perm",
cwd: "/w",
startedAtMs: 2,
permissions,
},
{ permissions, scope: "turn" },
),
...answered(
3,
"execCommandApproval",
{
conversationId: nativeThreadId,
callId: "legacy-rm",
command: ["rm", "-rf", "/w/tmp"],
cwd: "/w",
parsedCmd: [],
},
{ decision: "approved" },
),
...answered(
4,
"applyPatchApproval",
{ conversationId: nativeThreadId, callId: "legacy-patch", fileChanges: {} },
{ decision: "approved" },
),
turnCompleted(nativeTurnId),
],
"full-access",
);
const request = yield* Effect.raceFirst(
harness.firstTerminal.pipe(Effect.as(undefined)),
Queue.take(pending),
);
assert.isUndefined(request, "Full access must not present an approval");
assert.deepEqual(
harness.terminalEvents().map((event) => event.status),
["completed"],
);
}).pipe(
Effect.scoped,
Effect.provide(
Layer.mergeAll(
IdAllocator.layer,
McpProviderSessions.layer,
NodeServices.layer,
NodeCrypto.layer,
),
),
),
);

it.effect("classifies permission requests that only list sandbox entries", () =>
Effect.gen(function* () {
const permissionRequest = (
Expand Down
27 changes: 27 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,11 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
sessionApprovals.set(nativeThreadId, { runtimeMode, kinds });
return kinds;
};
// Codex still asks before commands it deems dangerous; Full access means no prompts
// unless an explicit approval policy overrides it.
const answersApprovalsItself = (context: ActiveCodexTurnContext) =>
context.input.runtimePolicy.runtimeMode === "full-access" &&
context.input.runtimePolicy.approvalPolicy === undefined;
/** Retain settled contexts while background commands run so late item events still project. */
const settledTurns = yield* Ref.make(new Map<string, ActiveCodexTurnContext>());
const runningCommandItemsByTurn = yield* Ref.make(
Expand Down Expand Up @@ -5864,6 +5869,11 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
payload,
);
}
if (answersApprovalsItself(context)) {
return {
decision: "accept",
} satisfies CodexSchema.CommandExecutionRequestApprovalResponse;
}
const allowance = sessionAllowance(payload.threadId, context);
if (allowance.has("command")) {
return {
Expand Down Expand Up @@ -5935,6 +5945,11 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
payload,
);
}
if (answersApprovalsItself(context)) {
return {
decision: "accept",
} satisfies CodexSchema.FileChangeRequestApprovalResponse;
}
const allowance = sessionAllowance(payload.threadId, context);
if (allowance.has("file-change")) {
return {
Expand Down Expand Up @@ -6007,6 +6022,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
payload,
);
}
if (answersApprovalsItself(context)) {
return permissionsResponseFromDecision({
decision: "accept",
permissions: payload.permissions,
});
}

const requestKind = providerRequestKindFromPermissions(payload.permissions);
const artifacts = yield* buildApprovalRequestArtifacts({
Expand Down Expand Up @@ -6152,6 +6173,9 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
payload,
);
}
if (answersApprovalsItself(context)) {
return { decision: "approved" } satisfies CodexSchema.ExecCommandApprovalResponse;
}
const allowance = sessionAllowance(payload.conversationId, context);
if (allowance.has("command")) {
return {
Expand Down Expand Up @@ -6221,6 +6245,9 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
payload,
);
}
if (answersApprovalsItself(context)) {
return { decision: "approved" } satisfies CodexSchema.ApplyPatchApprovalResponse;
}
const allowance = sessionAllowance(payload.conversationId, context);
if (allowance.has("file-change")) {
return {
Expand Down
22 changes: 22 additions & 0 deletions docs/adr/0029-codex-full-access-answers-approvals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ADR 0029: Codex Full access answers approvals itself

- Status: accepted
- Date: 2026-11-18
- Compared with upstream: `pingdotgg/t3code` at `2ebe7f8e2` (2026-11-17)

Upstream [pingdotgg/t3code#37104](https://github.com/pingdotgg/t3code/pull/37104) changed
Codex **Full access** from `approvalPolicy: "never"` to a `granular` policy, so MCP
elicitations (browser and app access) reach T3 Code. With `granular` and
`sandbox_approval: false`, Codex still sends a command approval for any command its
dangerous-command heuristic matches, such as `rm -f` inside a `trap`. Under `never` it rejected
those instead. Upstream showed the request to the user, so Full access threads stopped to ask.

The fork owner's rule: Full access never asks for approval. An elicitation asks what to do, not
whether to proceed, so it may still be answered. The
[Codex adapter](../../apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts) accepts
command, file-change, and permissions approvals (v2 and legacy) in Full access without
showing them, unless the runtime policy carries an explicit approval policy. Dangerous commands now run, where `never` refused them. A mode between Auto
and Full access that still asks for dangerous commands would be a new selector entry, not a
change to Full access.

Drop this if upstream answers these approvals itself in Full access, or returns to `never`.
Loading