Codex WSL Terminal Flashes and Closes? Switch the Agent Host

Codex WSL Terminal Flashes and Closes? Switch the Agent Host

Aident AI

A magenta terminal path fragments while a parallel cyan terminal path remains open in a dark technical workspace.

Codex WSL Terminal Flashes and Closes? Switch the Agent Host

If the integrated terminal in Codex Desktop flashes open and immediately closes only when Agent environment is set to WSL, switch the agent host to Windows native, restart Codex, and then choose WSL as the integrated terminal shell if you still want a Linux prompt.

That combination is the important workaround:

Agent environment: Windows native
Integrated terminal: WSL

An August 5 reproduction on Codex Desktop 26.730.8199.0 found that both PowerShell and WSL terminal profiles worked under the Windows-native agent host. Both profiles failed under the WSL agent host, even though WSL itself worked outside Codex. The upstream bug is still open, so treat this as a bounded workaround rather than an official fix.

Confirm the WSL Agent-Host Failure

Prerequisites

  • Codex Desktop is running on Windows.

  • WSL2 and at least one Linux distribution are installed.

  • You can save any active terminal work before restarting Codex.

  • You know your current Agent environment and integrated terminal selections.

First, verify WSL independently from PowerShell:

wsl --status
wsl --list --verbose

Expected result: your intended distribution appears in the list with VERSION set to 2. Note its exact name, such as Ubuntu, then run a harmless command inside it:

wsl -d Ubuntu -- sh -lc 'printf "terminal-ok\n"; pwd'

Expected result:

terminal-ok
/your/current/wsl/path

Replace Ubuntu with the distribution name from wsl --list --verbose. If this command fails, the problem is not limited to Codex's integrated terminal. Skip to When WSL itself does not start.

Now test the two independent Codex settings:

  1. Record the current Agent environment under Codex settings.

  2. Record the selected integrated terminal shell.

  3. With the Agent environment set to WSL, restart Codex.

  4. Open a task and press Ctrl+J, use the terminal button, or select View > Open Terminal.

  5. Repeat once with PowerShell selected as the terminal shell and once with WSL selected.

The reported failure matrix was:

Agent environment

Terminal shell

Result

Windows native

PowerShell

Works

Windows native

WSL

Works

WSL

PowerShell

Panel flashes and closes

WSL

WSL

Panel flashes and closes

This matrix matters more than the shell label alone. If changing only the terminal shell does not help, but changing the Agent environment does, you have isolated the failure to the agent-host boundary.

Switch the Agent Host to Windows Native

  1. Open Codex Desktop settings.

  2. Find Agent environment.

  3. Select Windows native.

  4. Leave your integrated terminal set to WSL if that is the shell you want.

  5. Fully restart Codex. OpenAI's Windows documentation says an Agent environment change does not take effect until restart.

  6. Reopen the same project and open the terminal.

  7. Run a read-only shell check:

printf 'terminal-ok\n'
pwd
git status --short

Expected result: the bottom panel remains visible, terminal-ok prints once, pwd shows the expected project location, and git status --short reports the repository state without changing it.

The Codex agent now executes through the Windows-native host, but the integrated terminal can still be WSL. OpenAI documents these as separate settings. You do not need to abandon your Linux shell merely to route the agent through the host that keeps the panel open.

Why This Workaround Works

The controlled comparison narrows the failure to the agent host, not to the selected terminal shell:

Agent host starts Codex runtime
  -> integrated terminal request is routed
  -> selected PowerShell or WSL shell starts
  -> bottom panel stays mounted

In the reported build, changing the shell did not alter the result while the Agent environment remained WSL. Switching the Agent environment to Windows native restored both shell options immediately. The same report confirmed that the WSL application server initialized and that the distribution accepted commands outside Codex.

That makes the host boundary the smallest supported target for a workaround. It does not prove the underlying product root cause. One reporter observed a missing bundled bwrap resource and an earlier child exit code of 127, while a second same-day issue described a failure before terminal process startup. OpenAI has not confirmed that either observation causes the panel to close.

Avoid Destructive Look-Alike Fixes

Do not unregister or reinstall your distribution

wsl --unregister deletes the selected distribution and its data. A healthy wsl -d <distribution> -- ... result already shows that reinstalling the distribution targets the wrong layer.

Do not keep changing only the terminal shell

The terminal shell and Agent environment are separate. In the reported reproduction, PowerShell and WSL both failed under the WSL agent host and both worked under the Windows-native host.

Do not assume Windows sandbox setup caused this symptom

One reporter completed elevated Windows sandbox setup successfully and still reproduced the terminal failure. Treat a sandbox-setup error as a separate problem unless your own A/B test links it to the panel.

Do not treat generic panel advice as a verified fix

OpenAI's troubleshooting guide recommends closing and reopening a stuck terminal panel. That is reasonable for a panel that remains visible but stops responding. A panel that flashes and immediately disappears under one Agent environment has a more specific boundary.

When WSL Itself Does Not Start

If the independent PowerShell check fails, use Microsoft's WSL diagnostics before changing Codex:

wsl --status
wsl --list --verbose

Close work running in every distribution before using:

wsl --shutdown

That command stops all running WSL distributions. Start the intended distribution again and repeat the harmless terminal-ok command. If WSL remains unhealthy, resolve that platform issue first. Switching Codex to Windows native can keep the agent usable, but it does not repair WSL.

If Windows Native Does Not Restore the Terminal

Fully quit Codex, reopen it, and confirm the Agent environment still reads Windows native. Then try the official terminal troubleshooting sequence: close the panel, reopen it, and run pwd or git status.

If the panel still closes, report the issue from Codex with /feedback. Include:

  • Codex Desktop package version.

  • Windows version and build.

  • wsl --list --verbose output with private distribution names redacted if needed.

  • The four-row Agent environment and terminal shell matrix.

  • Whether the same WSL command succeeds from PowerShell.

  • Whether restarting after the setting change altered the result.

Do not attach unredacted logs until you have checked them for usernames, paths, repository names, prompts, and environment values.

Keep Structured Actions Available

The integrated terminal is useful for local repository commands. Connected Actions are a separate route for structured services such as analytics, search, issue trackers, and publishing systems. Aident Loadout lets the same agent inspect an Action contract and estimate its cost before execution.

From the restored terminal, check the installed public CLI:

aident account auth status
aident vault vault --action status

aident capabilities search \
  --targetEnv staging \
  --types '["action"]' \
  --queries '["one read-only Action for my current task"]'

Use the exact Action name returned by search with aident capabilities get, then call aident capabilities preflight before execution. Expected result: authentication and Vault status are visible, and the Action contract can be reviewed without copying provider credentials into the terminal.

Follow https://aident.ai/SETUP.md to set up Aident Loadout, then preflight one read-only Action.

Sources

Review this article when either upstream issue closes, OpenAI changes the Windows Agent environment controls, or a Codex Desktop release documents a permanent terminal fix.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

The one tool

for every tool

your agent needs.

Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.