Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
fix(codex): avoid stalled response websocket streams
IgnoreMeBut1b26502eb14e
diff --git a/src/main/features/local_agents/backends/codex.ts b/src/main/features/local_agents/backends/codex.tsindex 7a0bfe3d..3387bdd8 100644--- a/src/main/features/local_agents/backends/codex.ts+++ b/src/main/features/local_agents/backends/codex.ts@@ -1102,10 +1102,21 @@ export function buildCodexTurnRuntimeOverrides(};}-function buildCodexArgs(opts: BackendRunOptions): string[] {+export const CODEX_OPENAI_HTTP_TRANSPORT_OVERRIDE =+ 'model_providers.openai.supports_websockets=false';++export function buildCodexArgs(opts: BackendRunOptions): string[] {// Per multica: `codex app-server --listen stdio://` is the entry// point for the JSON-RPC protocol. customArgs trail.- const args = ['app-server', '--listen', 'stdio://'];+ // Keep the provider stream on HTTPS/SSE. A Responses WebSocket can remain+ // half-open after an output-item start: Codex then emits neither app-server+ // progress nor a transport failure, so its built-in HTTPS fallback never+ // runs. SSE retains Codex's own idle detection/retry without imposing an+ // Orkas-side deadline or cancelling a turn that may still recover.+ const args = [+ 'app-server', '--listen', 'stdio://',+ '-c', CODEX_OPENAI_HTTP_TRANSPORT_OVERRIDE,+ ];// orkas-bridge: codex takes config-layer overrides (`-c key=value`,// TOML-parsed) instead of a config file. Codex spawns stdio MCP servers// with a sanitized env (PATH/HOME only) — it does NOT inherit this Codexdiff --git a/src/renderer/modules/conversation.js b/src/renderer/modules/conversation.jsindex b9d31077..fd01f6b7 100644--- a/src/renderer/modules/conversation.js+++ b/src/renderer/modules/conversation.js@@ -941,6 +941,8 @@ function _createProcessDisplayContext() {cliRunningShown: false,cliRetryActive: false,cliRetrySeries: 0,+ cliIdleActive: false,+ cliIdleSeries: 0,};}@@ -1039,6 +1041,39 @@ function _processCliRetryLifecycle(evt, displayContext) {return { key, terminal: true };}+// Runner idle events are periodic snapshots of one contiguous wait, not new+// actions. Keep updating one presentation row until a real CLI event arrives.+// A directly following terminal status replaces that same row. Persisted raw+// events remain unchanged for diagnostics.+function _processCliIdleLifecycle(evt, displayContext) {+ if (!evt || evt.stream !== 'cli' || !displayContext) return null;+ const data = evt.data && typeof evt.data === 'object' ? evt.data : {};+ const type = String(data.type || '').toLowerCase();+ if (type === 'idle') {+ if (!displayContext.cliIdleActive) {+ displayContext.cliIdleSeries = Math.max(0, Number(displayContext.cliIdleSeries) || 0) + 1;+ displayContext.cliIdleActive = true;+ }+ return { key: `cli-idle:${displayContext.cliIdleSeries}`, terminal: false };+ }+ if (!displayContext.cliIdleActive) return null;++ const status = type === 'status' ? String(data.status || '').toLowerCase() : '';+ if (['timeout', 'error', 'failed', 'cancelled', 'aborted'].includes(status)) {+ const key = `cli-idle:${Math.max(1, Number(displayContext.cliIdleSeries) || 1)}`;+ displayContext.cliIdleActive = false;+ return { key, terminal: true };+ }++ // Synthetic tool/reasoning pulses are bookkeeping, not new protocol+ // progress. All other events close this wait series so a later idle period+ // gets a chronologically separate row.+ if (data.synthetic !== true && data.heartbeat !== true) {+ displayContext.cliIdleActive = false;+ }+ return null;+}+function _isProcessPlanToolName(name) {return ['manage_execution_plan', 'plan_set', 'todo_write', 'todowrite', 'update_plan'].includes(_processToolKey(name));@@ -14228,10 +14263,12 @@ function _projectProcessRow(evt, displayContext, fallbackText = '') {const text = (event ? _formatEventLine(event, displayContext) : '')|| String(fallbackText || '');if (!text) return null;+ // Hidden diagnostics must not split one visible wait into multiple rows.+ const idleLifecycle = event ? _processCliIdleLifecycle(event, displayContext) : null;const kind = event ? _eventProcessKind(event, text) : _processKindOf(text);const lifecycle = kind === 'plan'? null- : (_processToolLifecycle(event) || _processCliRetryLifecycle(event, displayContext));+ : (idleLifecycle || _processToolLifecycle(event) || _processCliRetryLifecycle(event, displayContext));const data = event?.data && typeof event.data === 'object' ? event.data : {};const cliResult = event?.stream === 'cli'&& String(data.type || '').toLowerCase() === 'tool-event'diff --git a/test/main/features/local_agents/bridge_args.test.ts b/test/main/features/local_agents/bridge_args.test.tsindex 887c728f..deb01861 100644--- a/test/main/features/local_agents/bridge_args.test.ts+++ b/test/main/features/local_agents/bridge_args.test.ts@@ -2,7 +2,9 @@ import { describe, expect, it } from 'vitest';import { buildClaudeArgs } from '../../../../src/main/features/local_agents/backends/claude';import {+ buildCodexArgs,buildCodexBridgeOverrides,+ CODEX_OPENAI_HTTP_TRANSPORT_OVERRIDE,codexDeveloperInstructions,codexThreadDeveloperInstructionParams,} from '../../../../src/main/features/local_agents/backends/codex';@@ -62,6 +64,21 @@ describe('claude bridge args', () => {});describe('codex bridge overrides', () => {+ it('uses the recoverable HTTP response stream while leaving user overrides last', () => {+ const userOverride = 'model_providers.openai.supports_websockets=true';+ const args = buildCodexArgs({+ ...BASE,+ customArgs: ['-c', userOverride],+ });++ expect(args.slice(0, 5)).toEqual([+ 'app-server', '--listen', 'stdio://',+ '-c', CODEX_OPENAI_HTTP_TRANSPORT_OVERRIDE,+ ]);+ expect(args.lastIndexOf(userOverride))+ .toBeGreaterThan(args.indexOf(CODEX_OPENAI_HTTP_TRANSPORT_OVERRIDE));+ });+it('emits TOML-quoted -c overrides for command/args and non-secret env', () => {const overrides = buildCodexBridgeOverrides({command: '/usr/local/bin/node',diff --git a/test/renderer/conversation-sidebar.test.ts b/test/renderer/conversation-sidebar.test.tsindex b74458c9..71bb6222 100644--- a/test/renderer/conversation-sidebar.test.ts+++ b/test/renderer/conversation-sidebar.test.ts@@ -4473,6 +4473,71 @@ describe('conversation process metadata formatting', () => {});});+ it('updates one row for a continuous agent-response wait and replaces it when stopped', () => {+ const context = loadConversationRenderer();+ const displayContext = context._createProcessDisplayContext();+ const body: any = {+ children: [],+ appendChild(node: any) { this.children.push(node); },+ };+ context.document.createElement = () => ({ dataset: {}, className: '', innerHTML: '' });+ const append = (data: Record<string, unknown>) => {+ const projection = context._projectProcessRow({ stream: 'cli', data }, displayContext);+ context._appendProjectedProcessRowToBody(body, projection);+ return projection;+ };++ append({ type: 'idle', stalledMs: 289_000 });+ expect(append({ type: 'log', level: 'debug', message: 'internal pulse' })).toBeNull();+ const latestWait = append({ type: 'idle', stalledMs: 709_000 });++ expect(body.children).toHaveLength(1);+ expect(latestWait).toMatchObject({+ lifecycleKey: 'cli-idle:1',+ lifecycleTerminal: false,+ text: 'Wait for agent response · 11m 49s',+ });+ expect(body.children[0].dataset.processText)+ .toBe('Wait for agent response · 11m 49s');++ const stopped = append({ type: 'status', status: 'cancelled' });+ expect(body.children).toHaveLength(1);+ expect(stopped).toMatchObject({+ lifecycleKey: 'cli-idle:1',+ lifecycleTerminal: true,+ kind: 'warn',+ text: 'Stopped',+ });+ expect(body.children[0].dataset).toMatchObject({+ processCallId: 'cli-idle:1',+ processTerminal: '1',+ processText: 'Stopped',+ });+ });++ it('starts a new wait row after genuine CLI activity resumes', () => {+ const context = loadConversationRenderer();+ const displayContext = context._createProcessDisplayContext();++ const firstWait = context._projectProcessRow({+ stream: 'cli', data: { type: 'idle', stalledMs: 90_000 },+ }, displayContext);+ const activity = context._projectProcessRow({+ stream: 'cli',+ data: {+ type: 'tool-event', phase: 'use', tool: 'web_fetch', callId: 'fetch-1',+ input: { url: 'https://example.com' },+ },+ }, displayContext);+ const secondWait = context._projectProcessRow({+ stream: 'cli', data: { type: 'idle', stalledMs: 120_000 },+ }, displayContext);++ expect(firstWait.lifecycleKey).toBe('cli-idle:1');+ expect(activity.lifecycleKey).toBe('cli:fetch-1');+ expect(secondWait.lifecycleKey).toBe('cli-idle:2');+ });+it('keeps safe duration and error details without exposing credentials or absolute paths', () => {const context = loadConversationRenderer();const displayContext = context._createProcessDisplayContext();