Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix: show in the chat that a Codex session runs another model than configured

raullopez-sandbox9721d1b621ea
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx
index c2b2b02b3..15cd9e3f0 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-activity-block.tsx
@@ -129,6 +129,11 @@ export function AgentRow({
);
}
+/** The host's warnings during a turn (a model it could not use, say), which the work log shows. */
+export function turnWarnings(turn: TurnActivity): ChatActivityItem[] {
+ return turn.items.filter((item) => item.kind === 'notice' && item.status === 'warning');
+}
+
/** Whether a turn has anything to show in its work log. */
export function turnShown(activity: AgentActivity, turn: TurnActivity): boolean {
const running = turn.status === 'queued' || turn.status === 'running';
@@ -140,7 +145,8 @@ export function turnShown(activity: AgentActivity, turn: TurnActivity): boolean
isThinking(turn) ||
turn.status === 'interrupted' ||
turn.status === 'error' ||
- turn.requests.length > 0
+ turn.requests.length > 0 ||
+ turnWarnings(turn).length > 0
);
}
@@ -198,6 +204,15 @@ export const ChatActivityBlock = observer(function ChatActivityBlock({
) : (
<ToolRows items={work} turn={turn} activity={activity} />
)}
+ {turnWarnings(turn).map((notice) => (
+ <WorkLogRow
+ key={notice.itemId}
+ icon={<FailedIcon />}
+ label={notice.title}
+ title={notice.text}
+ tone="passive"
+ />
+ ))}
{thinking && (
<WorkLogRow
icon={<ThinkingIcon />}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/retry-turn.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/retry-turn.test.tsx
index 982a032bd..dd70af612 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/retry-turn.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/retry-turn.test.tsx
@@ -51,7 +51,8 @@ const failedTurn: ChatActivityItem = {
async function render(
support: 'yes' | 'no' | 'unknown',
- control: ActivityApi['control']
+ control: ActivityApi['control'],
+ items: ChatActivityItem[] = [failedTurn]
): Promise<HTMLDivElement> {
const api: ActivityApi = {
resolve: async () => ({
@@ -62,7 +63,7 @@ async function render(
}),
reasoning: async () => null,
watchPlacements: () => () => {},
- roomActivity: async () => ({ items: [failedTurn], approvals: [] }),
+ roomActivity: async () => ({ items, approvals: [] }),
roomMessages: () => [],
control,
retrySupport: async () => support,
@@ -146,3 +147,20 @@ it('says the server’s refusal and offers Retry again', async () => {
expect(el.querySelector('[role="alert"]')?.textContent).toContain('took no turn');
expect(retryButton(el)!.disabled).toBe(false);
});
+
+it('shows the host’s warning in the turn, such as a model this sign-in cannot use', async () => {
+ const warning =
+ 'This Codex sign-in cannot use gpt-6.1-sol, the model its configuration names, so this session runs gpt-6-astra.';
+ const el = await render('yes', vi.fn(), [
+ { ...failedTurn, status: 'running' },
+ {
+ ...failedTurn,
+ itemId: 'notice:12',
+ kind: 'notice',
+ status: 'warning',
+ title: warning,
+ text: warning,
+ },
+ ]);
+ expect(el.textContent).toContain('cannot use gpt-6.1-sol');
+});
diff --git a/console/packages/agent-providers/src/codex/codex-adapter.test.ts b/console/packages/agent-providers/src/codex/codex-adapter.test.ts
index 255032f2b..9d0565bdb 100644
--- a/console/packages/agent-providers/src/codex/codex-adapter.test.ts
+++ b/console/packages/agent-providers/src/codex/codex-adapter.test.ts
@@ -208,6 +208,21 @@ describe('CodexAdapter', () => {
expect(eventsOf(events, 'runtime.warning').map((event) => event.message)).toEqual([
expect.stringContaining('cannot use gpt-6.1-sol'),
]);
+ // Said again once the first turn runs, where the chat shows it, and only then.
+ for (const [turnId, native] of [
+ ['first', 'native-1'],
+ ['second', 'native-2'],
+ ] as const) {
+ server.reply('turn/start', { turn: { id: native, status: 'inProgress' } });
+ await adapter.sendTurn({ sessionId: 'inherits', turnId, text: 'hi' });
+ server.notify('turn/started', turnNotification(native, 'inProgress'));
+ server.notify('turn/completed', turnNotification(native, 'completed'));
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ }
+ const kinds = events
+ .filter((event) => event.type === 'turn.started' || event.type === 'runtime.warning')
+ .map((event) => event.type);
+ expect(kinds.slice(1)).toEqual(['turn.started', 'runtime.warning', 'turn.started']);
await adapter.stopAll();
} finally {
await rm(home, { recursive: true, force: true });
diff --git a/console/packages/agent-providers/src/codex/codex-adapter.ts b/console/packages/agent-providers/src/codex/codex-adapter.ts
index dba269ac6..80379ec77 100644
--- a/console/packages/agent-providers/src/codex/codex-adapter.ts
+++ b/console/packages/agent-providers/src/codex/codex-adapter.ts
@@ -129,6 +129,8 @@ interface CodexSessionState {
client: StdioJsonRpcClient;
model?: string;
effort?: string;
+ /** A warning about the session's setup to say again once its first turn is running. */
+ firstTurnNotice?: string;
compaction?: { resolve: () => void; reject: (error: Error) => void };
activeNativeTurnId?: string;
/** Caller turn ids handed to `turn/start` but not yet bound to a native id. */
@@ -503,6 +505,7 @@ export class CodexAdapter implements ProviderAdapter {
if (fallback) {
state.model = fallback.model;
modelWarning = fallback.warning;
+ state.firstTurnNotice = fallback.warning;
}
if (sandbox !== configured)
sandboxWarning = `Auto mode runs Codex in the ${sandbox} sandbox instead of the configured ${configured}: unsandboxed, nothing would reach its automatic review.`;
@@ -926,6 +929,12 @@ export class CodexAdapter implements ProviderAdapter {
turnId,
raw: { source: CODEX_SERVER_NOTIFICATIONS.turnStarted, payload },
});
+ // Said again inside the first turn, where the chat shows it: a warning
+ // from before any turn reaches only the host's own log.
+ if (state.firstTurnNotice) {
+ this.emit(state, { type: 'runtime.warning', message: state.firstTurnNotice });
+ state.firstTurnNotice = undefined;
+ }
});
client.onNotification(CODEX_SERVER_NOTIFICATIONS.turnCompleted, (params) => {