Skip to content

[Bug]: Only the first Codex session is registered in the sidebar when Codex 0.157 shared app-server daemon is enabled #23517

Closed as duplicate

Description

@EngineerEricXie

Title

[Bug]: Codex 0.157 shared managed app-server keeps Orca agent attribution bound to the first session

Operating system

Windows 11 + WSL2 (Ubuntu 22.04)

Orca version

1.4.215

Details

Codex sessions launched from an Orca-managed WSL workspace are not consistently registered in the Orca sidebar / agent-status store when Codex 0.157.1 uses the shared managed app-server daemon.

The first Codex session after a clean daemon start is registered correctly. A second fresh Codex session, opened without restarting the daemon, gets its own ORCA_PANE_KEY, ORCA_TAB_ID, and ORCA_AGENT_LAUNCH_TOKEN, but the shared managed daemon continues to hold the metadata from the first session.

As a result, Orca keeps tracking only the first Codex session. The second session exists and works normally in the terminal, but no new agentType: "codex" entry is created for it.

Environment

  • Orca: 1.4.215
  • OS: Windows 11
  • WSL: Ubuntu 22.04
  • Codex CLI: 0.157.1
  • Agent runtime: WSL / Ubuntu-22.04
  • Workspace: \\wsl.localhost\Ubuntu-22.04\home\tsungyeh\CROWN
  • Codex home: /home/tsungyeh/.codex

Reproduction

  1. Close all Orca Codex sessions.
  2. Stop the Codex managed app-server daemon and its helper processes.
  3. Confirm that only unrelated Codex processes, such as the VS Code extension app-server, remain.
  4. Open a fresh Codex session in Orca. Call this Session A.
  5. Send a prompt such as:
say hello
  1. After the turn completes, run:
& "$env:LOCALAPPDATA\Programs\orca\resources\bin\orca.exe" worktree ps --json
  1. Session A is registered correctly. agents[] contains an entry similar to:
{
  "state": "done",
  "agentType": "codex",
  "prompt": "say hello",
  "lastAssistantMessage": "Hello!"
}
  1. Do not restart or kill the Codex managed daemon.
  2. Open another completely fresh Codex session in the same workspace. Call this Session B.
  3. Send another prompt.
  4. Run worktree ps --json again.

Actual behavior

After Session B is opened:

  • liveTerminalCount increases, confirming that the new terminal/session exists.
  • Session B runs normally.
  • Session B has its own Orca pane/tab/launch metadata.
  • However, agents[] still contains only Session A's Codex entry.
  • No second agentType: "codex" entry is created for Session B.

For example, after Session A:

{
  "liveTerminalCount": 2,
  "agents": [
    {
      "paneKey": "1a0a2d7f-b818-4750-9e01-1bb71f226cdc:cb691c6a-a9aa-4f4d-9b95-f30ebcdc55eb",
      "state": "done",
      "agentType": "codex",
      "prompt": "say hello"
    }
  ]
}

After opening Session B:

{
  "liveTerminalCount": 3,
  "agents": [
    {
      "paneKey": "1a0a2d7f-b818-4750-9e01-1bb71f226cdc:cb691c6a-a9aa-4f4d-9b95-f30ebcdc55eb",
      "state": "done",
      "agentType": "codex",
      "prompt": "say hello"
    }
  ]
}

The second Codex session does not appear in agents[].

Process / environment evidence

Session A has its own Orca metadata:

ORCA_PANE_KEY=1a0a2d7f-b818-4750-9e01-1bb71f226cdc:cb691c6a-a9aa-4f4d-9b95-f30ebcdc55eb
ORCA_TAB_ID=1a0a2d7f-b818-4750-9e01-1bb71f226cdc
ORCA_AGENT_LAUNCH_TOKEN=45e3327a-4c1c-4c42-b592-29958140cec3

Session B has different metadata:

ORCA_PANE_KEY=34242fbd-9fa6-48fc-8a40-deadd06c4d62:73acf142-cfb8-48b2-a057-00e1a3f0683d
ORCA_TAB_ID=34242fbd-9fa6-48fc-8a40-deadd06c4d62
ORCA_AGENT_LAUNCH_TOKEN=362ea32e-9db3-4294-867b-b5869c0917b6

However, the shared Codex daemon:

codex app-server --listen unix:// --managed-daemon

still contains Session A's Orca metadata:

ORCA_PANE_KEY=1a0a2d7f-b818-4750-9e01-1bb71f226cdc:cb691c6a-a9aa-4f4d-9b95-f30ebcdc55eb
ORCA_TAB_ID=1a0a2d7f-b818-4750-9e01-1bb71f226cdc
ORCA_AGENT_LAUNCH_TOKEN=45e3327a-4c1c-4c42-b592-29958140cec3

This suggests that the shared managed app-server inherits the Orca attribution metadata from the first session and keeps it for subsequent Codex sessions.

Hook debugging

The Orca Codex hook installation is present and working.

~/.codex/hooks.json is installed, and the Orca hook script is executed.

For a fresh session, the following events are emitted:

SessionStart
UserPromptSubmit
Stop

The Codex process also receives the expected Orca variables:

ORCA_PANE_KEY
ORCA_TAB_ID
ORCA_WORKTREE_ID
ORCA_AGENT_LAUNCH_TOKEN
ORCA_AGENT_HOOK_ENDPOINT
ORCA_AGENT_HOOK_PORT

The Orca hook endpoint is reachable from WSL.

A manually constructed POST to:

/hook/codex

using the Orca token and metadata returns:

HTTP 204

The first session is therefore able to register correctly.

Additional observation

Resuming an existing Codex conversation can show the same symptom, but the issue is not limited to resume.

A second completely fresh Codex session also fails to receive its own agent entry while the shared managed daemon from Session A is still running.

Restarting the managed daemon restores correct behavior for the first newly opened session, after which the problem can recur for subsequent sessions.

Expected behavior

Each Codex session should be attributed to its own Orca pane/tab.

If multiple Codex sessions share one managed app-server daemon, the daemon or hook handling should not cause Orca attribution to remain bound to the first session's:

ORCA_PANE_KEY
ORCA_TAB_ID
ORCA_AGENT_LAUNCH_TOKEN

Opening Session B should create a second Codex entry in agents[] with Session B's own paneKey.

Actual behavior

The shared Codex managed app-server remains associated with the first Orca session's environment.

Subsequent fresh Codex sessions have their own Orca environment variables at the TUI process level, but they are not separately registered in the Orca agent-status store.

This causes only the first Codex session after a clean daemon start to appear correctly in the sidebar / agents[].

Suspected cause

Codex 0.157.1 uses a shared process:

codex app-server --listen unix:// --managed-daemon

The daemon appears to inherit and retain the Orca environment from the first Codex session that started it.

Subsequent Codex sessions reuse the same daemon, but the daemon's Orca attribution metadata is not updated or scoped per session.

Possible fix

Orca could avoid relying on process-global Orca attribution inherited by the shared Codex managed daemon.

Possible approaches include:

  1. Associate Codex lifecycle events with the pane/session metadata from the current TUI/session instead of the daemon's inherited environment.
  2. Pass pane/tab/launch attribution explicitly per Codex session or hook event.
  3. Detect a lifecycle event for a new ORCA_PANE_KEY and create/rebind the Codex agent entry accordingly.
  4. Avoid treating the shared daemon's environment as authoritative for agent attribution when multiple Codex sessions are attached to the same daemon.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. changed the title [-][Bug]: Resumed Codex sessions are not restored in the sidebar because SessionStart is not emitted on resume[/-] [+][Bug]: Only the first Codex session is registered in the sidebar when Codex 0.157 shared app-server daemon is enabled[/+] on Sep 28, 2026
  3. AmethystLiang commented on Sep 28, 2026

    @AmethystLiang
    Contributor

    looking into it

  4. nwparker commented on Oct 26, 2026

    @nwparker
    Contributor

    Thanks @EngineerEricXie for the clear repro. This has the same cause as #23643: the shared Codex app-server daemon keeps the first session's pane key, so later sessions never get their own entry. Closing as a duplicate so the work stays in one place; please follow #23643.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugos:Windows

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions