codex icon indicating copy to clipboard operation
codex copied to clipboard

[WSL2][CLI voice] F8 session starts then stops with WSLg PulseAudio

Open pellorao opened this issue 2 months ago • 18 comments

What version of Codex CLI is running?

codex-cli 0.156.0 (standalone Linux package)

What subscription do you have?

ChatGPT Pro

Which model were you using?

gpt-6-sol for the CLI conversation. The realtime voice model was not independently identified.

What platform is your computer?

Ubuntu 26.04.1 LTS in WSL2 with WSLg audio, x86_64. uname -mprs: Linux 6.18.33.2-microsoft-standard-WSL2 x86_64 unknown.

What terminal emulator and version are you using (if applicable)?

Windows Terminal running the WSL shell; terminal version not checked.

Codex doctor report

{
  "note": "Sanitized summary only. This diagnostic ran later in a restricted troubleshooting shell, not the interactive terminal that reproduced the voice failure. Full output contained local paths.",
  "codexVersion": "0.156.0",
  "checks": {
    "installation": "ok",
    "config.load": "ok",
    "auth.credentials": "ok",
    "network.provider_reachability": "fail: HTTP connection was denied by the restricted diagnostic shell",
    "network.websocket_reachability": "warning: DNS lookup returned Operation not permitted in the restricted diagnostic shell"
  }
}

The restricted-shell network checks are not evidence of the interactive voice failure: that attempt reached a realtime WebSocket 101 Switching Protocols response.

What issue are you seeing?

Pressing F8 in Codex CLI starts a voice conversation, but it stops almost immediately:

Voice conversation started. Use /voice mute to mute or /voice to stop.
Voice conversation failed: voice audio session stopped unexpectedly

After a reproduction on 2026-09-22 UTC, the local Codex debug log recorded:

21:20:51.246Z realtime websocket connected status=101 Switching Protocols
21:20:52.876Z voice helper output closed phase=Some(Device) exit_code=Some(37)
21:20:52.876Z voice session operation failed stage=AudioSession kind="closed"

The helper's exact device error was not surfaced, so the underlying failure is still unknown.

What steps can reproduce the bug?

  1. Run Codex CLI 0.156.0 in Ubuntu 26.04.1 under WSL2/WSLg using Windows Terminal.
  2. Use WSLg PulseAudio audio devices. pactl list short sources shows RDPSource (s16le, mono, 44100 Hz); speaker playback uses WSLg's RDPSink.
  3. Install ALSA's PulseAudio plugin and configure both default ALSA PCM and control to use pulse.
  4. Restart Codex and press F8. The conversation reports that it started, then immediately reports that the audio session stopped unexpectedly. This was reproduced more than once.

Before the ALSA/PulseAudio bridge was configured, F8 instead reported Failed to connect voice mode: voice audio devices could not open; check microphone and speaker setup and the helper exited in OpenDevices with code 25. After the bridge, it proceeds further and exits in Device with code 37.

What is the expected behavior?

Voice mode should keep the audio session open and accept microphone input. If opening or running an audio device fails, Codex should report the underlying device error.

Additional information

  • Built-in Codex feedback was uploaded for this conversation. Thread ID for maintainers to correlate with the uploaded diagnostics: 01a0caf1-29c0-7b31-91eb-4caee95e9c40.
  • A concurrent ALSA playback/recording test at 48 kHz float32 succeeded: speaker-test played an audible tone and exited 0; arecord wrote a six-second mono WAV and exited 0. A second concurrent test requested a 10 ms period and 40 ms buffer; both commands again exited 0. The recorded WAV's speech content was not independently checked.
  • The observed successful ALSA tests establish that basic WSLg playback and capture streams can open concurrently. They do not establish why the Codex voice helper exits.
  • Related issue #46630 concerns an Ubuntu PipeWire ALSA plugin path failure in Codex 0.155.1 during device opening. This report concerns WSLg PulseAudio on 0.156.0 after the voice session starts and the helper reaches the Device phase.
  • No raw rollout, recording, private project content, or local log file is attached.

pellorao avatar Sep 22 '26 21:09 pellorao

I’m seeing the same issue on WSL2.

My environment:

  • Windows 11 host
  • WSL2
  • Ubuntu 26.04
  • Windows Terminal
  • Codex CLI 0.156.1 (standalone Linux build)

Voice mode starts, then stops immediately with:

Voice conversation started. Use /voice mute to mute or /voice to stop.

Voice conversation failed: voice audio session stopped unexpectedly

savvy773 avatar Sep 24 '26 22:09 savvy773

A source-level diagnostic suggestion for this report, based on the public code for build 00c972ed5d6ff6499317fd41b7f23605b8e6850d:

  • In devices.rs, handle_stream_error ignores Xrun and reduces other CPAL errors to the shared failed flag, without preserving the error or whether it came from input or output.
  • In device_buffers.rs, take_state() turns that flag into the generic audio device failed error. The flag has other writers, including the non-finite input-sample check, so the reported Device/37 exit alone does not prove that the CPAL error callback ran.
  • client.rs:192 intentionally drains and discards helper stderr.

Could an opt-in, structured diagnostic preserve the failure origin (input/output callback or another flag writer), CPAL error kind / underlying ALSA error where available, and negotiated sample format, rate, channels, and buffer size before the helper exits?

A bounded diagnostic with those fields, without raw audio, SDP, credentials, or unfiltered native stderr, would make the next reproduction more actionable while preserving the existing privacy boundary. This is an instrumentation suggestion, not a claim about the root cause or a confirmed fix.

servrox avatar Sep 25 '26 14:09 servrox

Follow-up: the workaround below restored /voice in a separate NixOS WSL2/WSLg reproduction using Codex CLI 0.157.0, CPAL 0.18.2, and ALSA plugins 1.2.12. This is a confirmed local fix; it does not establish that every Device/37 report has the same cause. The original report above used Ubuntu and Codex 0.156.0.

The dependency bug is tracked in alsa-project/alsa-plugins#65. In pulse/pcm_pulse.c, pulse_delay() compares a negative return code against positive PA_ERR_NODATA:

- if (err != PA_ERR_NODATA) {
+ if (err != -PA_ERR_NODATA) {

Without the correction, temporarily unavailable PulseAudio timing data becomes -EIO. The observed CPAL error was ALSA function 'snd_pcm_avail_delay' failed with error 'I/O error (5)'. Correcting the sign preserves the plugin's existing wait/retry behavior instead of treating missing startup timing as a fatal device error.

The useful reproducer was reopening speaker output while microphone input remained active. Basic concurrent playback/capture passed with the stock plugin, so it missed this failure. The local reproduction used F32, stereo, 48 kHz, requesting 2400-frame callbacks (CPAL configures a two-period ring); these were the local test settings, not universal Codex defaults.

Validation:

  • Stock plugin: ordinary duplex passed; output reopen produced repeated ALSA I/O errors.
  • Source-built plugin with only the sign correction: the output-reopen test passed 3/3 runs, with active input/output callbacks and zero device errors.
  • A real /voice conversation using the corrected plugin was confirmed working.
  • The correction was then packaged persistently in Nix. The system build, focused Codex/WSL-audio checks, activation, and installed voice-runtime initialization check passed. A further spoken conversation on that final persistent package has not been separately repeated.

Nix applies this change to pulse/pcm_pulse.c before compiling alsa-plugins, producing a patched libasound_module_pcm_pulse.so. The Codex voice helper's launcher sets ALSA_PLUGIN_DIR to that build, so its audio stack loads the corrected plugin. The Codex executable itself is unchanged, and existing ALSA/Pulse routing and bundled runtime setup remain in place. Its source patch uses --replace-fail to force review when the upstream source changes. The removal checklist requires the pinned dependency to contain the upstream correction, followed by an unpatched output-reopen regression test and a real voice conversation before removing the override.

The earlier diagnostic suggestion still applies: preserving the underlying CPAL/ALSA error and input/output origin would distinguish this dependency failure from other Device/37 causes.

servrox avatar Sep 25 '26 15:09 servrox

Thanks a lot for digging into this and documenting the workaround.

I’m hitting the same issue on WSL2/WSLg, so I’ll try the patched alsa-plugins fix as well. Really appreciate the detailed analysis and validation.

savvy773 avatar Sep 26 '26 01:09 savvy773

Additional independent reproduction of this exact Device/37 failure on Debian 13.5 in WSL2, with Codex CLI 0.157.1, WSLg PulseAudio 17.0, and Debian libasound2-plugins 1.2.12-2+b1.

The PulseAudio defaults were the direct WSLg devices RDPSink and RDPSource. There was no null sink, remapped sink, or loopback. The Windows default microphone was WO Mic, but the isolated error came from the speaker stream. Codex showed Voice conversation started, then Voice conversation failed: voice audio session stopped unexpectedly; its local diagnostic recorded phase=Some(Device) exit_code=Some(37).

I reproduced the speaker failure outside Codex with a small CPAL 0.18.2 duplex probe using the same local stream configuration: F32, stereo, 48 kHz, fixed 2400-frame period. The output error callback reported:

BackendError: ALSA function 'snd_pcm_avail_delay' failed with error 'I/O error (5)'

An isolated trace of pa_stream_get_latency() captured -16 (-PA_ERR_NODATA) during startup. The microphone stream did not report a device error. This corroborates the sign mismatch in alsa-project/alsa-plugins#65 and the previous comment here; it is not evidence of a WO Mic driver failure.

I then built a user-local copy of the same ALSA Pulse PCM plugin with only this one-line change:

- if (err != PA_ERR_NODATA) {
+ if (err != -PA_ERR_NODATA) {

I verified the corrected .so was actually loaded via an ALSA pcm_type mapping before comparing runs. In six three-second duplex starts, the packaged plugin produced the speaker EIO in 4/6 runs; the corrected plugin produced it in 0/6. After making that corrected PCM the user's ALSA default, a further 6/6 duplex starts had no backend error. A real Codex /voice session then stayed in listening for over 30 seconds and ended only when I explicitly stopped it. The audio tests played silence and discarded microphone samples; no recording or transcript was retained.

This appears to be a dependency defect that Codex exposes through its ALSA backend, but WSLg users still get an immediate, generic voice failure. Could Codex surface a bounded device diagnostic with the input/output side and underlying CPAL/ALSA error, as suggested above, and evaluate a native PulseAudio path for WSLg so voice does not depend on this ALSA plugin behavior? The local plugin correction is a confirmed workaround for this reproduction, not a claim that every code 37 has the same cause.

AndyAlvarezDev avatar Sep 28 '26 01:09 AndyAlvarezDev

I can reproduce the same failure outside WSL2:

  • Codex CLI 0.158.0
  • Ubuntu MATE 24.04.5 x86_64
  • VMware Workstation guest using VMware HDA
  • PulseAudio 16.1; ALSA default routes through the PulseAudio plugin

The failure signature is identical:

realtime websocket connected status=101 Switching Protocols
voice helper output closed phase=Some(Device) exit_code=Some(37)
voice session operation failed stage=AudioSession kind="closed"

Local controls all work:

  • arecord -D default captures successfully
  • Speaker playback works
  • Chrome microphone access works
  • ChatGPT Web voice works in Chrome

Restarting the TUI and shared app-server daemon did not help.

I temporarily instrumented the bundled helper. It successfully loaded the ALSA PulseAudio plugin, connected to /run/user/5100/pulse/native, and completed Pulse protocol/SHM negotiation. No underlying ALSA or Rust error was emitted before exit 37.

Unlike #46630, this gets past ALSA plugin discovery and device opening, then fails in the Device service stage. This suggests the code-37 failure is not specific to WSLg.

winginitau avatar Sep 29 '26 03:09 winginitau

I diagnosed and fixed my local reproduction of this failure on Codex CLI 0.159.3 in Ubuntu 24.04.4 / WSL2 / WSLg / tmux, with CPAL 0.18.2 and libasound2-plugins 1.2.7.1-1ubuntu5.

Voice connected, but either stopped shortly after starting or after several spoken turns. Codex logged phase=Some(Device) exit_code=Some(37). Ordinary recording/playback and a separate CPAL duplex probe passed.

I followed the actual bundled Codex voice helper under GDB and caught the device-error callback:

ALSA function 'snd_pcm_avail_delay' failed with error 'I/O error (5)'

The caller was cpal::host::alsa::output_stream_worker: the failure was on the speaker/output stream.

I built a local ALSA PulseAudio PCM plugin with this change in pulse_delay:

- if (err != PA_ERR_NODATA) {
+ if (pa_context_errno(pcm->p->context) != PA_ERR_NODATA) {

I selected it in ~/.asoundrc:

pcm_type.pulse {
    lib "/absolute/path/to/patched/libasound_module_pcm_pulse.so"
}

After opening new voice streams, Codex transcribed a synthetic spoken test and replied, then successfully transcribed my physical microphone and responded. No WSL restart was required.

I subsequently found the existing upstream diagnosis: https://github.com/alsa-project/alsa-plugins/issues/65 and proposed fix https://github.com/alsa-project/alsa-plugins/pull/67. That PR's smaller correction compares against -PA_ERR_NODATA. The context-error-check variant above is what I actually tested. I did not capture the precise pa_stream_get_latency return value, so this is independent confirmation of the observed ALSA EIO and successful local workaround, not a claim that every Device/37 failure has this cause.

For Codex, please expose the stream direction, backend error kind, and underlying ALSA function/errno in safe structured diagnostics. “Voice audio session stopped unexpectedly” concealed an output failure while the symptom appeared to be a microphone that wasn't listening. A documented WSL/Linux workaround and reference to the upstream fix would also help users.

dblumenau avatar Oct 01 '26 19:10 dblumenau

Additional instrumented evidence for this report from Ubuntu 24.04 / WSL2, reproduced on Codex CLI 0.159.2 and 0.160.0. In the single instrumented 0.160.0 attempt, the ALSA EIO was captured on cpal_alsa_out before helper exit code 37. The standalone CPAL variants below, including output rebuild and a cumulative variant, did not reproduce the failure. I have not tested the plugin patches discussed above; these results do not establish the underlying cause in my environment.

Environment

  • Windows 11, WSL2 Ubuntu 24.04.
  • Codex CLI: 0.159.2 and 0.160.0.
  • CPAL: standalone tests use 0.18.2. The saved voice-host source matching 0.159.2 pins cpal = "=0.18.2". Separately, the installed 0.160.0 helper contains build-time paths including crates__cpal-0.18.2/src/host/alsa/mod.rs.
  • Audio route: ALSA default devices → PulseAudio plugin → WSLg PulseAudio 17.0.
  • PULSE_SERVER=unix:/mnt/wslg/PulseServer; default source/sink: RDPSource / RDPSink.
  • My ~/.asoundrc specifies the PulseAudio plugin, unix:/mnt/wslg/PulseServer, and handle_underrun false. A helper trace recorded opens of ~/.asoundrc and libasound_module_pcm_pulse.so. The application of handle_underrun false was not directly measured.
  • Windows microphone input uses an Android device through VirtualMic and works in other Windows applications.

Reproduction

  1. Launch Codex CLI inside Ubuntu WSL.
  2. Run /voice.
  3. On 0.160.0, the UI reports Voice conversation started, followed by voice audio session stopped unexpectedly.

Expected: the voice session remains active.

Investigation timeline

  1. 0.159.2: Initially observed voice audio devices could not open. Later instrumented runs reached audio streaming, but the helper terminated with exit code 37.
  2. 0.159.2 failure capture: A temporary ptrace breakpoint captured this CPAL error object before helper termination with exit code 37:
    ALSA function 'snd_pcm_avail_delay' failed with error 'I/O error (5)'
    
    Live helper input/output streams were observed as 48 kHz, stereo, float32. The failing direction was not established in this capture.
  3. Independent audio tests: parecord, paplay, arecord -D pulse, and aplay -D pulse completed without EIO. Approximately 15-second simultaneous input/output tests also completed without EIO through both PulseAudio directly and ALSA PulseAudio.
  4. Standalone CPAL tests: A CPAL 0.18.2 ALSA full-duplex test at 48 kHz, 2 channels, f32 completed normally. Variants exercised selected configuration and lifecycle behaviors identified in the saved 0.159.2 voice-host source: Fixed(2400), default/bounded configuration selection, output-first play() order, and output recreation while input remained active. Further variants added selected helper-like input/output callback and queue processing. Each variant completed 15 seconds × 3 runs, with exit code 0 and no stream errors. A cumulative variant combining these additions also passed all three runs. These tests did not reproduce the complete helper.
  5. After upgrading to 0.160.0: One instrumented /voice attempt captured the same ALSA error, on thread cpal_alsa_out, followed by helper termination with exit code 37.

Diagnostic limitations

  • The error text was captured from the in-memory CPAL error callback, not helper stderr. Captures used temporary ptrace breakpoints, which can affect timing; installed executable files were not modified.
  • The standalone playback producer supplied silence; playback of real voice audio was not tested in these variants.
  • Failure frequency was not systematically measured. The underlying cause has not been established.

Diagnostic request

Please investigate why the Codex voice helper encounters this ALSA EIO on the output path under WSL2.

It would also be helpful if the underlying CPAL/ALSA error were logged to stderr or included in the /voice failure message; currently the UI only reports that the audio session stopped unexpectedly.

Supporting files

  • Sanitised 0.160.0 helper capture: the output-thread EIO and exit code 37; the home-directory username is replaced with <user>.
  • Saved asoundrc.txt: ALSA defaults pointing to the WSLg PulseAudio socket.
  • Cumulative variant results: all three runs exited 0 without EIO. The logs include selected configuration, output-first start, and output rebuild while input remained active. Playback supplied silence.

asoundrc.txt

cpal-duplex-cumulative-results.json

helper-0.160.0-one-shot.sanitised.jsonl.txt

saturno3 avatar Oct 02 '26 14:10 saturno3

Reproduced on Codex CLI 0.160.0 under WSL2/WSLg.

Voice starts, then fails with:

Voice conversation failed: voice audio session stopped unexpectedly

Local diagnostics show:

voice helper output closed phase=Some(Device) exit_code=Some(37)
voice session operation failed stage=AudioSession kind="closed"

Verified setup:

  • WSLg PulseAudio default source is RDPSource, unmuted, volume 100%.
  • libasound2-plugins is installed.
  • Both ALSA default PCM and control use type pulse, with server "unix:/mnt/wslg/PulseServer".
  • The microphone works in Windows applications.
  • WSLg's PulseAudio log reports a successful RDP input connection around the failure, but does not expose an underlying stream error.

The ALSA/PulseAudio bridge did not resolve the failure. This matches the reported Device/37 signature, but does not establish the underlying cause or prove usable microphone samples reached Codex.

Could the helper report the original device error and identify whether capture or playback failed?

alvaroroco avatar Oct 05 '26 13:10 alvaroroco

Hello, I experienced the same/a similar problem. I understand that these reports are on Windows using the WSL, so for me it is a large step to assume that my bare metal Linux setup has the same problem.

After multple interactive troubleshooting sessions with GPT-6-Astra (finally high, thanks to OpenAI for the global reset an hour ago!), it identified a specific cause and applied a local fix. Voice appears to work reliably (but needs actual use, after I got sleep).

  • I only tried to make it work in general, until now. After "It works" I have not used it for actual work. /me needs sleep, after that session.
  • important: user1 runs the desktop environment with unrestricted access, and user7 runs Codex CLI and does not have access to the X11 or other services per default.
    • running Codex CLI, tests from user1 worked without problems from the start.
  • From the AI agent's description, it patched the audio library on byte level.
  • I can confirm the problem as described below, but I cannot comment on the correctness of the reasoning of the agent. That is beyond me.

The agent wrote the summary below.

Setup

  • Linux Mint 22.3 (based on Ubuntu 24.04 LTS) with an Xfce4 desktop session.
  • Codex CLI 0.160.1 running under a different Linux user from the desktop session.
  • PipeWire 1.0.5, providing PulseAudio compatibility.
  • ALSA PulseAudio plugin from alsa-plugins 1.2.7.1 and libpulse 16.1.
  • The Codex user accessed the desktop audio server through an existing loopback TCP listener, selected using PULSE_SERVER.
  • ~/.asoundrc routed the default ALSA PCM through the PulseAudio plugin.

Symptoms Initially, F8 reported that audio devices could not open. After configuring the ALSA-to-PulseAudio connection, voice remained intermittent: it sometimes worked, but usually stopped with:

“Voice conversation failed: voice audio session stopped unexpectedly”

Codex logged phase=Some(Device), exit_code=Some(37). Ordinary ALSA recording and playback worked, including simultaneous use.

Confirmed cause A debugger captured the speaker/output-stream error:

ALSA function 'snd_pcm_avail_delay' failed with error 'I/O error (5)'

Further tracing stopped inside the ALSA PulseAudio plugin’s pulse_delay() function. It captured:

pa_stream_get_latency returned: -16 PulseAudio stream state: 2 (READY) PulseAudio context error: 16 (PA_ERR_NODATA)

The plugin compared the function’s return value against positive PA_ERR_NODATA (+16). However, libpulse returned the negative error code (-16). Consequently, the plugin converted “timing information is not available yet” into a fatal -EIO instead of taking its existing path that waits for timing information.

The source-level correction is:

  • if (err != PA_ERR_NODATA) {
  • if (err != -PA_ERR_NODATA) {

This is in pulse/pcm_pulse.c, within pulse_delay(): https://github.com/alsa-project/alsa-plugins/blob/v1.2.7.1/pulse/pcm_pulse.c

Relevant libpulse implementation: https://github.com/pulseaudio/pulseaudio/blob/v16.1/src/pulse/stream.c

Negative error-return definition: https://github.com/pulseaudio/pulseaudio/blob/v16.1/src/pulse/internal.h

Local workaround and result We copied the installed libasound_module_pcm_pulse.so into a private directory under my account and applied the equivalent one-byte correction to that copy. The patch was checked against the exact binary’s SHA256 and disassembly; it is build-specific and should not be applied blindly to another version.

We then added a pcm_type.pulse definition to ~/.asoundrc pointing to the corrected private library. The system library and Codex binaries were not modified.

Normal F8 voice operation now works without the debugger and continued working after logout/login. PULSE_SERVER remains persistently exported by my shell.

This confirms the cause on my machine. It does not establish that every exit-code-37 failure, or the failure reported here, has the same cause. However, it provides a specific check for systems using the ALSA PulseAudio plugin.

It would also help troubleshooting if Codex exposed the original CPAL/ALSA error and identified whether the input or output stream failed.

SpiritInAShell avatar Oct 07 '26 04:10 SpiritInAShell

Thanks, this worked for me too. I'm on Ubuntu 26.04.1 with WSL2/WSLg, running Codex 0.160.1.

In my case, the ALSA PulseAudio plugin was missing. I installed it, rebuilt alsa-plugins from source with the one-line fix from alsa-project/alsa-plugins#67, and configured ~/.asoundrc to use the rebuilt plugin.

codex-voice-fix.en.html

F8 voice is now working correctly. I didn't need to update Codex or modify any Codex binaries.

Issue resolved on my side. Thanks!

savvy773 avatar Oct 07 '26 06:10 savvy773

Thanks, this worked for me too. I'm on Ubuntu 26.04.1 with WSL2/WSLg, running Codex 0.160.1.

In my case, the ALSA PulseAudio plugin was missing. I installed it, rebuilt alsa-plugins from source with the one-line fix from alsa-project/alsa-plugins#67, and configured ~/.asoundrc to use the rebuilt plugin.

codex-voice-fix.en.html

F8 voice is now working correctly. I didn't need to update Codex or modify any Codex binaries.

Issue resolved on my side. Thanks!

Nice to know!

Compiling Open Source libs from source sounds more straight forward and reproducable than patching the binary on disk.

SpiritInAShell avatar Oct 08 '26 16:10 SpiritInAShell

I tested this on my WSL2 setup with Codex CLI 0.162.1 (Ubuntu 22.04, WSLg PulseAudio 17.0).

The ALSA Pulse plugin I had installed contained the positive-16 comparison in pulse_delay() after pa_stream_get_latency. With that plugin, a silent playback probe using snd_pcm_avail_delay() failed with -EIO in all 3 runs. I changed the comparison to -16 in a separate copy; the same probe then passed 3/3, and playback and capture opened together when I selected that copy in .asoundrc.

My first /voice attempt after switching still failed at OpenDevices/25. I didn't change the audio configuration after that; a later session connected and recognized my speech. So the plugin change fixed the repeatable ALSA probe failure on my setup, though I can't explain that first device-open failure or say every Codex audio error has the same cause. I also reported the plugin test on alsa-project/alsa-plugins#67.

fayerman-source avatar Oct 14 '26 20:10 fayerman-source

Confirmed the same failure with Codex CLI 0.163.0 on WSL2/WSLg.

  • PulseAudio devices: RDPSource (mono, 44100 Hz) and RDPSink (stereo, 44100 Hz).
  • ALSA microphone and speaker tests pass, including simultaneous capture and playback.
  • Realtime API call succeeds (HTTP 201).
  • Realtime WebSocket connects successfully (HTTP 101).
  • Voice session starts and fails approximately 1–2 seconds later.

Relevant debug output:

voice helper output closed phase=Some(Device) exit_code=Some(37)
voice session operation failed stage=AudioSession kind="closed"

This reproduces the reported device-stream failure in 0.163.0

misudeea2009 avatar Oct 19 '26 22:10 misudeea2009

Hey folks, another data point: I reproduced this on a physical F(x)tec Pro1 X (ARM64) running Ubuntu Touch.

  • Ubuntu Touch 24.04-2.2 / Ubuntu 24.04.5 base
  • Codex CLI 0.166.0, official aarch64-unknown-linux-musl package
  • PulseAudio 16.1 and libasound2-plugins:arm64 1.2.7.1-1ubuntu5

Same behavior here: /voice connected, then stopped with phase=Some(Device), exit_code=Some(37). Ordinary ALSA recording and playback could start.

A few helper tests pointed to the playback side:

  • Real microphone + null output: stayed running.
  • Null microphone + real output: reproduced exit 37.

Pointing ALSA at a private copy of the PulseAudio plugin with the equivalent upstream fix (PA_ERR_NODATA → -PA_ERR_NODATA in the latency check) got it working. Both real audio streams then stayed running, and I was able to have a spoken conversation in Codex. The system library and Codex binaries were left unchanged.

There's also an Ubuntu backport report. I didn't capture the exact PulseAudio return value on the phone, so I can't say whether every Device/37 failure is the same bug, but the before/after result was repeatable here.

lectops avatar Oct 31 '26 14:10 lectops

same issue,

they must fix it, because claude code cli on same setup just works fine. Hold space and dictate. But codex cli inside WSL says

Failed to connect voice mode: voice audio devices could not open; check microphone and speaker setup

ilnytskyi avatar Nov 02 '26 15:11 ilnytskyi

Reproduced on Codex CLI 0.166.0; stock ALSA latency query fails 3/3

Still reproduces on the current stable CLI on 2026-11-05, with the same immediate Device/37 failure after configuring the ALSA-to-WSLg PulseAudio bridge.

Environment

  • Codex CLI 0.166.0, official npm Linux x64 package; voice helper build commit 6ff1e1ca3b30fc8b914720681fcf5fe62e95f856.
  • Ubuntu 24.04.5 LTS, x86_64; Linux 6.18.54.1-microsoft-standard-WSL2.
  • Windows Professional 26H2, build 26300.9818; WSL 3.0.3.0; WSLg 1.0.79.
  • libasound2t64 1.2.11-1ubuntu0.3, libasound2-plugins 1.2.7.1-1ubuntu5; PulseAudio client 16.1, WSLg PulseAudio server 17.0-25-gc3305.
  • WSLg defaults: microphone RDPSource, speaker RDPSink. Windows microphone and desktop-app microphone permissions are both allowed.

Configuration and reproduction

~/.asoundrc:

pcm.!default { type pulse }
ctl.!default { type pulse }

Launch, then enter /voice:

PULSE_SERVER=unix:/mnt/wslg/PulseServer \
ALSA_PLUGIN_DIR=/usr/lib/x86_64-linux-gnu/alsa-lib \
codex --no-daemon

Voice stops immediately with:

Voice conversation failed: voice audio session stopped unexpectedly

Latest reproduction's sanitized log excerpt:

2026-11-05T00:20:52.653970Z WARN codex_realtime_webrtc::client: voice helper output closed phase=Some(Device) exit_code=Some(37)
2026-11-05T00:20:52.658640Z WARN codex_realtime_webrtc::session: voice session operation failed stage=AudioSession kind="closed"

Independent audio controls

One-second ALSA tests through default at 48 kHz, float32 all passed:

Test Channels Result Recovered xruns
Silent speaker playback 2 48,000 frames 0
Microphone capture-and-discard 1 48,000 frames 0
Simultaneous playback and capture 2 output / 1 input 48,000 frames each 0

These are ordinary ALSA I/O checks, not an exact CPAL lifecycle or speaker-output-reopen reproduction.

Additional dependency evidence

Following alsa-project/alsa-plugins#65, I configured a playback PCM as FLOAT_LE, stereo, 48 kHz, with 20 ms requested latency, then immediately called snd_pcm_avail_delay(). No audio was written and no microphone was opened for this probe. The stock plugin returned -EIO (-5) in 3/3 runs.

Disassembly of the installed Ubuntu plugin also shows the positive comparison immediately after pa_stream_get_latency():

call pa_stream_get_latency@plt
test %eax,%eax
je   <success branch>
cmp  $0x10,%eax
jne  <error branch>

This matches the comparison changed in upstream commit 811c2ce.

Evidence boundary: I have not tested a patched plugin or captured the underlying native error from this Codex helper, so I cannot yet establish that the dependency defect causes this particular Codex failure. The helper's device flag is generic, and its stderr is deliberately discarded by the parent. Basic duplex success does not rule out the startup/output-reopen timing failure described earlier in this discussion.

Only sanitized diagnostic excerpts and numerical test results are included. Microphone samples were discarded; no recording, transcript, credentials, raw doctor report, private project data or personal filesystem paths are attached.

hackf5 avatar Nov 05 '26 00:11 hackf5

Confirmed: the workaround from this thread fixes /voice on Codex CLI 0.172.0, WSL2 Ubuntu 24.04 (WSLg), libasound2-plugins 1.2.7.1-1ubuntu5.

  • Before: every normal /voice start stopped about a second after "Voice conversation started" with phase=Some(Device) exit_code=Some(37) (6 of 6).
  • After rebuilding Ubuntu's pulse plugin with only err != PA_ERR_NODATA → err != -PA_ERR_NODATA in pulse_delay() and pointing pcm_type.pulse in ~/.asoundrc at it, voice works: 6 of 6 sessions stayed connected and listening until I stopped them, with no helper exit in the log.

It behaves like a heisenbug: with the stock plugin, a session slowed down by strace/gdb ran normally (speech transcribed, reply played), while unslowed runs failed within about 1.5 s every time. That fits the startup "no timing data yet" path.

Upstream fix: https://github.com/alsa-project/alsa-plugins/pull/67 (not in a release yet). Ubuntu backport request: https://bugs.launchpad.net/bugs/2172315.

Masterxilo avatar Nov 27 '26 18:11 Masterxilo