Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 3868e63

Browse files
committed
fix(agent): guard codex reviewer pin from override
1 parent ac7a0bf commit 3868e63

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

packages/agent/src/adapters/codex-app-server/spawn.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ describe("buildAppServerArgs", () => {
4242
);
4343
});
4444

45+
it("lets a caller override the reviewer pin without emitting a shadowed duplicate", () => {
46+
const args = buildAppServerArgs({
47+
binaryPath: "/bundle/codex",
48+
apiBaseUrl: "https://gateway.example/v1",
49+
configOverrides: { approvals_reviewer: "auto_review" },
50+
});
51+
52+
// codex's `-c` is last-wins, so the default pin must not be emitted alongside
53+
// the caller's value — exactly one reviewer entry, and it's the caller's.
54+
expect(args.filter((arg) => arg.startsWith("approvals_reviewer="))).toEqual(
55+
['approvals_reviewer="auto_review"'],
56+
);
57+
});
58+
4559
it("forwards http headers as a quoted TOML inline table on the posthog provider", () => {
4660
const args = buildAppServerArgs({
4761
binaryPath: "/bundle/codex",

packages/agent/src/adapters/codex-app-server/spawn.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ export function buildAppServerArgs(
126126
// The host owns approvals (surfaced via approvals.ts → requestPermission). Codex's
127127
// guardian reviewer is enabled by default and routes approvals to its dedicated
128128
// `codex-auto-review` model, which our gateway's posthog_code allowlist doesn't
129-
// serve — so every command review 403s. Pin codex's own default `user` reviewer
130-
// so approval decisions stay with the host.
131-
args.push("-c", `approvals_reviewer="user"`);
129+
// serve — so every command review 403s. Default codex's own `user` reviewer so
130+
// approval decisions stay with the host. Skipped when a caller sets the reviewer
131+
// via configOverrides (appended last, and codex's `-c` is last-wins) so we never
132+
// emit a conflicting duplicate that could shadow the pin back to the auto reviewer.
133+
if (options.configOverrides?.approvals_reviewer === undefined) {
134+
args.push("-c", `approvals_reviewer="user"`);
135+
}
132136

133137
// Disable the user's ambient ~/.codex MCP servers so the adapter only exposes
134138
// MCP servers PostHog injects per-thread; otherwise codex fails connecting to them.

0 commit comments

Comments
 (0)