Skip to content

codex app-server hardcodes SessionSource::VSCode; no --session-source flag on the umbrella subcommand #23442

Open

Description

@Bohan-J

Summary

The codex app-server subcommand (in the umbrella codex binary) hardcodes the session source to SessionSource::VSCode. There is no CLI flag to override this, even though clientInfo.name is honored for the originator field. As a result, any third‑party host that embeds Codex via codex app-server --listen stdio:// produces sessions that:

  • carry a faithful originator (e.g. multica-agent-sdk), but
  • are also tagged source=vscode, which the default threadList allowlist treats as a normal interactive VSCode session.

These third‑party sessions then show up in Codex Desktop's recent/project history and, at high session rates, push real user chats out of the visible window.

The standalone codex-app-server binary already exposes --session-source (default vscode) and parses arbitrary values into SessionSource::Custom(...). The fix is to forward the same flag from the umbrella codex app-server subcommand.

Repro

  1. Start Codex via the umbrella binary the way embedders do today:
    codex app-server --listen stdio://
    
    Pass clientInfo = { name: "my-agent-sdk", version: "..." } over the JSON-RPC handshake.
  2. Inspect the resulting ~/.codex/sessions/.../rollout-*.jsonl session_meta line:
    { "originator": "my-agent-sdk", "source": "vscode", ... }
  3. Open Codex Desktop. The third‑party session appears in the recent threads/project list, even though it was never a VSCode‑extension chat.

Root cause (confirmed against current main)

  • The umbrella codex app-server subcommand calls run_main_with_transport_options(..., SessionSource::VSCode, ...) directly — the value is hardcoded, not read from a flag:
    • codex-rs/cli/src/main.rs (AppServerCommand invocation, ~L986)
  • AppServerCommand does not declare a --session-source field:
    • codex-rs/cli/src/main.rs (AppServerCommand struct, ~L435–477) — fields are subcommand, strict_config, listen, remote_control, analytics_default_enabled, auth. No session source.
  • The standalone codex-app-server binary already has the flag and parser:
    • codex-rs/app-server/src/main.rs (~L31–37): clap long = "session-source", default = "vscode", parsed via SessionSource::from_startup_arg.
  • SessionSource::from_startup_arg accepts any string and folds unknown values into SessionSource::Custom(normalized):
    • codex-rs/protocol/src/protocol.rs (from_startup_arg).
  • arg0‑style dispatch in codex does not alias to app-server, so calling codex under a different basename is not a workaround:
    • codex-rs/arg0/src/lib.rs.

Why hardcoding to vscode is load-bearing for the bug

The default threadList allowlist in rollout includes SessionSource::VSCode, which is why these sessions surface in Desktop in the first place:

  • Default allowlist: INTERACTIVE_SESSION_SOURCES = [Cli, VSCode, Custom("atlas"), Custom("chatgpt")]
    • codex-rs/rollout/src/lib.rs (~L24–31)
  • Default filter when client doesn't pass source_kinds:
    • codex-rs/app-server/src/filters.rs (~L9–15)
  • Sessions whose source is not in the allowlist are dropped from threadList results:
    • codex-rs/rollout/src/list.rs (~L748–754)

So if an embedder could pass --session-source my-agent-sdk, the resulting SessionSource::Custom("my-agent-sdk") would naturally fall outside the default allowlist and Desktop would correctly hide it — same convention the codebase already uses for non‑interactive sources.

Proposed fix

Mirror the standalone binary's flag on the umbrella subcommand:

  1. Add --session-source to AppServerCommand (codex-rs/cli/src/main.rs), default = "vscode" so existing VSCode‑extension behavior is unchanged.
  2. Parse it with SessionSource::from_startup_arg (same as codex-rs/app-server/src/main.rs).
  3. Pass the parsed SessionSource into run_main_with_transport_options(...) instead of the hardcoded SessionSource::VSCode.

This is additive, opt-in, and matches the existing convention used by the standalone codex-app-server binary. No allowlist or Desktop‑side change is required: Custom(...) sources are already filtered out of the default interactive list.

Workarounds today

  • Build/install the standalone codex-app-server binary and pass --session-source <name> directly. Not viable for end users who only have the official @openai/codex distribution (which ships only codex), and Desktop's bundled codex-app-server isn't on PATH.

Context

Activity

  1. added
    bug
    CLI
    app-server
    on May 19, 2026
  2. github-actions commented on May 19, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. truffle-dev commented on May 19, 2026

    @truffle-dev

    Not a duplicate of #23437. Same surface symptom (source=vscode), different root causes.

    This issue is the app-server subcommand at codex-rs/cli/src/main.rs:986 constructing the session with codex_protocol::protocol::SessionSource::VSCode hardcoded. The app-server's own session is misclassified at construction time. Fix is plumbing a source through AppServerCommand (a --session-source flag, or detecting CLI invocation vs Desktop launch).

    #23437 is a separately-launched TUI session in a project directory getting written with source=vscode, originator=Codex Desktop, and cwd=$HOME after codex app-server has run. The TUI session never enters the :986 codepath; its metadata is being polluted through shared state outside that file (env var, session-store, lockfile, or originator detection reading state set by the app-server). Patching :986 leaves that codepath untouched.

    Worth keeping both open. The fixes are independent.

  4. truffle-dev commented on May 19, 2026

    @truffle-dev

    Sharing the fix outline per docs/contributing.md. Happy to PR it if a Codex maintainer wants it.

    The umbrella app-server subcommand already mirrors the standalone codex-app-server binary in every other respect (--listen, --remote-control, --analytics-default-enabled, strict config). Adding the same --session-source flag with the same defaults closes the gap. The change is 42 lines in codex-rs/cli/src/main.rs (1 import, 1 struct field, 1 destructure, 1 hardcoded-replacement, 3 unit tests), compiles clean on top of b3ae3de40, cargo test -p codex-cli passes locally.

    // codex-rs/cli/src/main.rs
    
    use codex_protocol::protocol::SessionSource;        // <-- add
    
    // AppServerCommand: place after the existing `analytics_default_enabled` flag
    /// Session source used to derive product restrictions and metadata.
    ///
    /// Mirrors the `--session-source` flag on the standalone `codex-app-server`
    /// binary so third-party embedders launching `codex app-server --listen ...`
    /// can classify their sessions (e.g. `multica-agent-sdk`) instead of being
    /// hardcoded as `vscode`. Defaults to `vscode` to preserve the first-party
    /// VSCode IDE extension flow.
    #[arg(
        long = "session-source",
        value_name = "SOURCE",
        default_value = "vscode",
        value_parser = SessionSource::from_startup_arg
    )]
    session_source: SessionSource,
    
    // in cli_main, the AppServerCommand destructure:
    //   analytics_default_enabled,
    //   session_source,                                // <-- add
    //   auth,
    
    // at the run_main_with_transport_options call (line ~986):
    //   transport,
    // - codex_protocol::protocol::SessionSource::VSCode,
    // + session_source,
    //   auth,

    The default stays vscode so first-party VSCode launches keep their current classification with no change. SessionSource::from_startup_arg is the same parser the standalone binary uses (codex-rs/protocol/src/protocol.rs:2613), which already accepts cli/vscode/exec/mcp/app-server aliases and wraps anything else as SessionSource::Custom(_), so downstream embedders get their identifier through without needing a new enum variant.

    Three unit tests in the existing #[cfg(test)] mod tests block cover default, custom, and alias normalization:

    #[test]
    fn app_server_session_source_defaults_to_vscode() {
        let app_server = app_server_from_args(["codex", "app-server"].as_ref());
        assert_eq!(app_server.session_source, SessionSource::VSCode);
    }
    
    #[test]
    fn app_server_session_source_accepts_custom_value() {
        let app_server = app_server_from_args(
            ["codex", "app-server", "--session-source", "multica-agent-sdk"].as_ref(),
        );
        assert_eq!(
            app_server.session_source,
            SessionSource::Custom("multica-agent-sdk".to_string())
        );
    }
    
    #[test]
    fn app_server_session_source_normalizes_known_values() {
        let app_server =
            app_server_from_args(["codex", "app-server", "--session-source", "cli"].as_ref());
        assert_eq!(app_server.session_source, SessionSource::Cli);
    }

    This is upstream-only and leaves the separate TUI-classification-via-shared-state question on #23437 untouched.

  5. innoiso commented on Jun 19, 2026

    @innoiso

    Still reproducible in current Codex builds.

    I verified rust-v0.141.0 still hardcodes SessionSource::VSCode in the umbrella codex app-server path:

    • codex-rs/cli/src/main.rs:1146
    • codex-rs/app-server/src/lib.rs:398

    The standalone codex-app-server binary has --session-source, but the distributed codex app-server command does not expose it, so custom clients using codex app-server --listen stdio:// still create threads with source: "vscode".

  6. azat-badretdin commented on Oct 12, 2026

    @azat-badretdin

    Additional Windows Desktop evidence, observed October 12, 2026: I use Codex Desktop on Windows and do not use VS Code at all, but a local rollout's session_meta record contains:

    {"source":"vscode","originator":"Codex Desktop","cli_version":"0.162.0-alpha.2"}

    The version above is the recorded Codex runtime version, not the desktop app version. The fields were read directly from the local rollout header.

    This also affects downstream session viewers: Codex Sessions Live displays that raw source as “interactive vscode” or “non-interactive vscode”, incorrectly suggesting VS Code usage. For the temporary display workaround, I am using the explicit originator value to label these sessions “Codex Desktop”, while preserving the underlying session records.

    Could you please ensure Windows Desktop sessions have an unambiguous desktop identity, or document the supported field consumers should use to distinguish Desktop from the VS Code extension? This observation establishes the metadata discrepancy; I have not independently traced the exact assignment path in this build.

    Related in-app feedback ID: 01a13053-ab6c-7991-b5c6-dacf5b51c0db.

  7. niieani commented on Oct 16, 2026

    @niieani

    Still present in rust-v0.163.0 (codex-rs/cli/src/main.rs:1288) and on main as of 6ae8b8a.

    Another use case for the flag: keeping an embedder's threads out of the Codex desktop app. I run a personal assistant service that drives codex app-server over stdio, using the same CODEX_HOME as the desktop app so it shares auth and config. Every thread it creates is stamped vscode, so dozens of automated threads end up in the desktop sidebar.

    The source is the only per-thread signal the desktop app filters on. Its thread/list calls send an empty sourceKinds, which the server treats as interactive sources only. A thread stamped exec never shows in the sidebar, search, or archived view. It stays resumable by ID, and codex://threads/<id> links still open it. I confirmed this on 0.163.0, and the exec stamp survives thread/resume from a vscode app-server.

    The workaround today is to stop using the npm package and download the standalone codex-app-server from GitHub releases, which has --session-source. That binary isn't shipped in @openai/codex, so npm-based embedders can't reach the flag without pinning and checksumming a separate release asset. Exposing --session-source on the umbrella app-server subcommand, as outlined above, would remove that need.

  8. diodeme commented on Nov 19, 2026

    @diodeme

    Still present on main as of b9559ff (2026-11-19): codex-rs/cli/src/main.rs:1379 still passes SessionSource::VSCode. Also verified on 0.153.4 (Windows).

    Adding a few data points from a desktop app that drives the user's installed codex app-server --stdio with the user's normal CODEX_HOME:

    1. Visibility also leads to a resume conflict. Our users see these threads in the Codex desktop sidebar and open them. After that, our app can no longer resume the thread. Presumably the desktop app's app-server now holds the per-thread writer lock ($CODEX_HOME/thread-writer-locks). Keeping embedder threads out of the default list would remove the most common way users run into this.

    2. The source only needs to be set when the thread is created. On resume, a thread keeps the source recorded in its rollout (get_resumed_session_sources / StartThreadOptions::effective_sources). Tested on 0.153.4:

    • Created a thread with the standalone codex-app-server --session-source app-server: session_meta.source is "mcp", and the thread is absent from the default thread/list.
    • Resumed it and ran a turn with the stock codex app-server: source stays "mcp" and the thread stays hidden.

    So the flag alone is sufficient, even when hosts mix binaries or versions.

    3. Caveat about custom names. --session-source my-agent-sdk becomes SessionSource::Custom("my-agent-sdk"), and restriction_product() maps unknown custom names to None (Product::from_session_source_name only knows chatgpt/codex/atlas). Skills or plugins that declare a product restriction would then be filtered out for those threads. app-server (→ Mcp) and exec keep Product::Codex and are already outside INTERACTIVE_SESSION_SOURCES, so one of those may be the safer value to document for embedders. If custom names are the intended convention, they could map to Product::Codex.

    What we checked that doesn't work with the stock codex binary: clientInfo.name and thread/start.threadSource don't affect source; thread/fork stamps the server's source; archived threads can't be resumed without unarchiving first; sqlite_home doesn't move rollouts or writer locks.

  9. xxchan commented on Nov 19, 2026

    @xxchan

    Another embedder affected. OAR, an open-source agent runtime library, starts one codex app-server --listen stdio:// per session from the @openai/codex npm package. Hosts built on it (for example Raft) run several long-lived agents on the user's own machine and CODEX_HOME, so every agent thread is stamped vscode and lands in the Codex desktop sidebar next to the user's own chats.

    Still hardcoded on main at ab00c6d (codex-rs/cli/src/main.rs:1379).

    We would pass --session-source app-server (keeps Product::Codex, stays outside INTERACTIVE_SESSION_SOURCES, survives resume as noted above) as soon as the umbrella subcommand accepts it. Shipping the standalone codex-app-server binary in the npm package would also work for us, but forwarding the flag is the smaller change.


    Agent Cindy wrote this for @xxchan through Stamp (grant cgr_33b7192d4ffb06ab8373a0083bd5e2ac)

  10. brycedbjork commented on Nov 24, 2026

    @brycedbjork

    +1 from another embedder, with a second consequence worth noting.

    We run codex app-server (stdio) to drive Codex sessions for agents our desktop app starts on the person's behalf. Because the subcommand hardcodes SessionSource::VSCode, every one of those threads lands in INTERACTIVE_SESSION_SOURCES, so:

    1. They fill the person's own Codex app thread list (thread/list with no sourceKinds defaults to interactive sources).
    2. They feed Codex memories, which also filter on interactive sources.

    Workarounds we tried on 0.172.0: ephemeral: true hides them but makes them unresumable ("no rollout found for thread id"); thread/archive on a loaded thread unloads it, so the next turn/start fails "thread not found". We've settled on archiving only after thread/unsubscribe and unarchiving before thread/resume, which works but still shows the thread while it runs.

    Plumbing the standalone binary's --session-source through the codex app-server subcommand (as outlined above, defaulting to vscode) would let us pass --session-source <name> and drop the workaround entirely.

  11. litefeel commented on Nov 27, 2026

    @litefeel

    Our Windows IM bridge uses codex app-server --listen stdio:// with CLI 0.172.0. Its persistent threads show up in Desktop’s Activity → Priority alongside chats I started manually. I’d like to exclude IM threads from Priority, including after new replies, while keeping them resumable by ID after the bridge restarts.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIapp-serverbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions