@devries-cameron20 / t3code Mirror · read-only / commits / 74ffe35c73
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 21:00 UTC

fix(provider-core): Codex turns refused by a managed access policy say so instead of 'retry' (#34871)

Julius Marminge committed Nov 12, 2026 at 00:01 UTC 74ffe35c731620d2f4bc06f9f01500a91a7662b9
2 files changed +31 -2
packages/provider-core/src/server/failure.test.ts
+17
@@ -170,6 +170,23 @@ it("keeps unrecognized reasons and provider text out of category messages", () =
170 );
171 });
172
173 +it("names a managed Codex policy that refuses the thread's access mode", () => {
174 + const message = makeProviderFailure({
175 + cause: {
176 + _tag: "ProviderAdapterTurnStartError",
177 + cause: {
178 + _tag: "CodexAppServerRequestError",
179 + method: "turn/start",
180 + code: -32600,
181 + message:
182 + "invalid thread settings override: invalid value for `sandbox_mode`: `DangerFullAccess` is not in the allowed set [ReadOnly, WorkspaceWrite] (set by /etc/codex/requirements.toml)",
183 + },
184 + },
185 + }).message;
186 + assert.notInclude(message, "Retry the turn");
187 + assert.match(message, /requirements|policy/iu);
188 +});
189 +
190 it("uses the innermost category without carrying an outer reason into it", () => {
191 assert.equal(
192 makeProviderFailure({
packages/provider-core/src/server/failure.ts
+14 -2
@@ -65,6 +65,10 @@ const PROVIDER_FAILURE_CATEGORIES: Partial<
65 const CODEX_GOAL_VALIDATION_MESSAGE =
66 /^goal objective must (?:not be empty|be at most \d{1,6} characters)$/u;
67
68 +// codex_config::ConstraintError::InvalidValue for a managed requirements.toml or cloud policy.
69 +const CODEX_ACCESS_REQUIREMENT_REJECTION =
70 + /invalid value for `(approval_policy|sandbox_mode)`: `([A-Za-z]{1,32})` is not in the allowed set /u;
71 +
72 const PROVIDER_FAILURE_REASONS: Record<ProviderAdapterFailureReason, string> = {
73 previous_turn_active: "the previous turn is still running",
74 attachment_unreadable: "an attachment could not be read",
@@ -119,8 +123,8 @@ function curatedCauseMessages(cause: unknown): {
123 case "ProviderCompactionUnsupportedError":
124 return { known: stringField(cause, "message"), category: categoryMessage() };
125 case "CodexAppServerRequestError": {
122 - // Only Codex's fixed-shape goal validation text is actionable and
123 - // safe to show; other request error text stays hidden.
126 + // Only Codex's fixed-shape goal validation and managed-requirements
127 + // text is actionable and safe to show; other request error text stays hidden.
128 const rejection = stringField(cause, "message");
129 if (
130 (cause as Record<string, unknown>).method === "thread/goal/set" &&
@@ -129,6 +133,14 @@ function curatedCauseMessages(cause: unknown): {
133 ) {
134 return { known: `Codex rejected the goal: ${rejection}.`, category: categoryMessage() };
135 }
136 + const access =
137 + rejection === undefined ? null : CODEX_ACCESS_REQUIREMENT_REJECTION.exec(rejection);
138 + if (access !== null) {
139 + return {
140 + known: `Codex's managed requirements do not allow \`${access[1]}\` \`${access[2]}\`, which this thread's access mode uses. Switch the thread to an access mode the policy allows.`,
141 + category: categoryMessage(),
142 + };
143 + }
144 break;
145 }
146 case "AcpProcessExitedError": {