Skip to content

Commit cd19ee2

Browse files
roboclaw-botVACInc
andauthored
fix(codex): keep managed Code Mode warning out of chat (#131943)
Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Vito Cappello <[email protected]>
1 parent 4e2ff79 commit cd19ee2

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎extensions/codex/src/app-server/event-projector-events.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ function normalizeApprovalReviewStatus(status: string | undefined): string | und
9393
const GUARDIAN_TIMEOUT_WARNING =
9494
"Automatic approval review timed out while evaluating the requested approval.";
9595

96+
// These routine Codex diagnostics lack structured codes. Match complete templates so only
97+
// host-managed notices stay log-only and other actionable warnings still reach chat.
98+
const LOG_ONLY_CODEX_WARNING_PATTERNS = [
99+
/^Configured service tier `[^`\r\n]+` is not advertised as supported for model `[^`\r\n]+` and will be omitted from requests\.$/,
100+
/^Code Mode is enabled in configuration, but model `[^`\r\n]+` does not advertise Code Mode support\. This may degrade model performance\. Disable `features\.code_mode` and `features\.code_mode_only`, or select a model whose metadata enables Code Mode\.$/,
101+
];
102+
96103
export function projectNormalizedToolItem(params: {
97104
phase: "start" | "result";
98105
item: CodexThreadItem | undefined;
@@ -275,13 +282,7 @@ export class CodexEventProjection {
275282
const summary = readString(params, "summary") ?? readString(params, "message");
276283
const details = readString(params, "details");
277284
const message = [summary, details].filter(Boolean).join("\n");
278-
// Codex's unsupported_service_tier_warning has no structured code. Match its
279-
// complete template so this routine diagnostic stays log-only, not other warnings.
280-
if (
281-
/^Configured service tier `[^`\r\n]+` is not advertised as supported for model `[^`\r\n]+` and will be omitted from requests\.$/.test(
282-
message,
283-
)
284-
) {
285+
if (LOG_ONLY_CODEX_WARNING_PATTERNS.some((pattern) => pattern.test(message))) {
285286
embeddedAgentLog.warn(message);
286287
} else if (message) {
287288
this.emitAgentEvent({ stream: "notice", data: { phase: "warning", message } });

‎extensions/codex/src/app-server/event-projector.reasoning.test.ts‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,25 @@ describe("CodexAppServerEventProjector reasoning and guardian projection", () =>
426426
});
427427

428428
it.each([
429-
{ tier: "priority", model: "test-no-tier-model" },
430-
{ tier: "flex", model: "test-no-tier-model" },
431-
])("logs unsupported $tier tiers without projecting a UI notice", async ({ tier, model }) => {
429+
{
430+
name: "unsupported service tier",
431+
message:
432+
"Configured service tier `priority` is not advertised as supported for model `test-no-tier-model` and will be omitted from requests.",
433+
},
434+
{
435+
name: "unsupported flex tier",
436+
message:
437+
"Configured service tier `flex` is not advertised as supported for model `test-no-tier-model` and will be omitted from requests.",
438+
},
439+
{
440+
name: "host-managed Code Mode metadata",
441+
message:
442+
"Code Mode is enabled in configuration, but model `gpt-5.6-sol` does not advertise Code Mode support. This may degrade model performance. Disable `features.code_mode` and `features.code_mode_only`, or select a model whose metadata enables Code Mode.",
443+
},
444+
])("logs $name warnings without projecting a UI notice", async ({ message }) => {
432445
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => {});
433446
const onAgentEvent = vi.fn();
434447
const projector = await createProjector({ ...(await createParams()), onAgentEvent });
435-
const message = `Configured service tier \`${tier}\` is not advertised as supported for model \`${model}\` and will be omitted from requests.`;
436448

437449
await projector.handleNotification({
438450
method: "warning",
@@ -447,6 +459,7 @@ describe("CodexAppServerEventProjector reasoning and guardian projection", () =>
447459
"Project hooks were disabled.",
448460
"Configured service tier `priority` requires account access.",
449461
"Configured service tier `priority` is not advertised as supported for model `test-no-tier-model` and will be omitted from requests. Additional action required.",
462+
"Code Mode is enabled in configuration, but model `gpt-5.6-sol` does not advertise Code Mode support. This may degrade model performance. Disable `features.code_mode` and `features.code_mode_only`, or select a model whose metadata enables Code Mode. Additional action required.",
450463
])("surfaces startup and thread warnings: %s", async (message) => {
451464
const onAgentEvent = vi.fn();
452465
const projector = await createProjector({ ...(await createParams()), onAgentEvent });

0 commit comments

Comments
 (0)