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
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,12 @@ export function projectRuntimeEventToActivities(
tone: "warning",
kind: "provider.config.warning",
summary: event.payload.summary,
// The row already shows the summary; a detail line repeating it
// would print the same warning twice.
payload: {
detail: event.payload.details ?? event.payload.summary,
...(event.payload.details && event.payload.details !== event.payload.summary
? { detail: event.payload.details }
: {}),
...(event.payload.path ? { path: event.payload.path } : {}),
...(event.payload.range !== undefined ? { range: event.payload.range } : {}),
},
Expand Down
38 changes: 38 additions & 0 deletions apps/server/src/provider/Layers/CodexAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,44 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
}),
);

it.effect("shows a config warning once, not again for each thread Codex opens", () =>
Effect.gen(function* () {
const { adapter, runtime } = yield* startLifecycleRuntime();
const eventsFiber = yield* Stream.take(adapter.streamEvents, 2).pipe(
Stream.runCollect,
Effect.forkChild,
);
const stale = "`[features].multi_agent` is deprecated.";
const warning = (id: string, method: string, payload: unknown, threadId = "thread-1") =>
runtime.emit({
id: asEventId(id),
kind: "notification",
provider: ProviderDriverKind.make("codex"),
threadId: asThreadId("thread-1"),
createdAt: "2026-01-01T00:00:00.000Z",
method,
payload: { ...(payload as object), threadId },
} as ProviderEvent);

yield* warning("evt-config", "configWarning", { summary: stale, details: null });
yield* warning("evt-main", "warning", { message: stale });
yield* warning("evt-subagent", "warning", { message: stale }, "child-thread");
yield* warning("evt-other", "warning", { message: "Something else went wrong." });

const events = Array.from(yield* Fiber.join(eventsFiber));
assert.deepStrictEqual(
events.map((event) =>
event.type === "config.warning"
? event.payload.summary
: event.type === "runtime.warning"
? event.payload.message
: event.type,
),
[stale, "Something else went wrong."],
);
}),
);

it.effect("maps realtime started notifications with upstream realtime session ids", () =>
Effect.gen(function* () {
const { adapter, runtime } = yield* startLifecycleRuntime();
Expand Down
27 changes: 27 additions & 0 deletions apps/server/src/provider/Layers/CodexAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,25 @@ function mapNativeSubagentMetadata(
};
}

/**
* The text of a plain Codex config or runtime warning, or undefined for any
* other event. Codex reports a config problem once as `configWarning` when the
* app server starts, then again as a `warning` for every thread it opens,
* subagents included, so one stale setting would otherwise show once per
* agent. A session keeps the texts it has shown and drops repeats.
*/
function plainWarningText(event: ProviderEvent): string | undefined {
if (event.method === "configWarning") {
return trimText(
readPayload(EffectCodexSchema.V2ConfigWarningNotification, event.payload)?.summary,
);
}
if (event.method === "warning") {
return trimText(readPayload(EffectCodexSchema.V2WarningNotification, event.payload)?.message);
}
return undefined;
}

export function mapToRuntimeEvents(
event: ProviderEvent,
canonicalThreadId: ThreadId,
Expand Down Expand Up @@ -3481,6 +3500,7 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
making: undefined,
};
let resendingTurn = false;
const shownWarnings = new Set<string>();

// The session context owns and explicitly interrupts this fiber. It
// must not inherit the short-lived caller that happens to start the
Expand Down Expand Up @@ -3521,6 +3541,13 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
yield* options.releaseRealtimeAudio(event.threadId);
}
yield* writeNativeEvent(event);
const warningText = plainWarningText(event);
if (warningText !== undefined) {
if (shownWarnings.has(warningText)) {
return;
}
shownWarnings.add(warningText);
}
const mappedEvents = yield* withUsageLimitReset(
mapToRuntimeEvents(event, event.threadId),
);
Expand Down
Loading