Commit Graph

4070 Commits

  • chore: use access token expiration for proactive auth refresh (#15545)
    Follow up to #15357 by making proactive ChatGPT auth refresh depend on
    the access token's JWT expiration instead of treating `last_refresh` age
    as the primary source of truth.
  • feat: communication pattern v2 (#15647)
    See internal communication
  • app-server: Add back pressure and batching to command/exec (#15547)
    * Add
    `OutgoingMessageSender::send_server_notification_to_connection_and_wait`
    which returns only once message is written to websocket (or failed to do
    so)
    * Use this mechanism to apply back pressure to stdout/stderr streams of
    processes spawned by `command/exec`, to limit them to at most one
    message in-memory at a time
    * Use back pressure signal to also batch smaller chunks into ≈64KiB ones
    
    This should make commands execution more robust over
    high-latency/low-throughput networks
  • core: Make FileWatcher reusable (#15093)
    ### Summary
    Make `FileWatcher` a reusable core component which can be built upon.
    Extract skills-related logic into a separate `SkillWatcher`.
    Introduce a composable `ThrottledWatchReceiver` to throttle filesystem
    events, coalescing affected paths among them.
    
    ### Testing
    Updated existing unit tests.
  • Increase voice space hold timeout to 1s (#15579)
    Increase the space-hold delay to 1 second before voice capture starts,
    and mirror the change in tui_app_server.
  • Pretty plugin labels, preserve plugin app provenance during MCP tool refresh (#15606)
    - Prefer plugin manifest `interface.displayName` for plugin labels.
    - Preserve plugin provenance when handling `list_mcp_tools` so connector
    `plugin_display_names` are not clobbered.
    - Add a TUI test to ensure plugin-owned app mentions are deduped
    correctly.
  • [codex] Stabilize second compaction history test (#15605)
    ## Summary
    - replace the second-compaction test fixtures with a single ordered
    `/responses` sequence
    - assert against the real recorded request order instead of aggregating
    per-mock captures
    - realign the second-summary assertion to the first post-compaction user
    turn where the summary actually appears
    
    ## Root cause
    `compact_resume_after_second_compaction_preserves_history` collected
    requests from multiple `mount_sse_once_match` recorders. Overlapping
    matchers could record the same HTTP request more than once, so the test
    indexed into a duplicated synthetic list rather than the true request
    stream. That made the summary assertion depend on matcher evaluation
    order and platform-specific behavior.
    
    ## Impact
    - makes the flaky test deterministic by removing duplicate request
    capture from the assertion path
    - keeps the change scoped to the test only
    
    ## Validation
    - `just fmt`
    - `just argument-comment-lint`
    - `env -u CODEX_SANDBOX_NETWORK_DISABLED cargo test -p codex-core
    compact_resume_after_second_compaction_preserves_history -- --nocapture`
    - repeated the same targeted test 10 times
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>
  • feat: disable notifier v2 and start turn on agent interaction (#15624)
    Make the inter-agent communication start a turn
    
    As part of this, we disable the v2 notifier to prevent some odd
    behaviour where the agent restart working while you're talking to it for
    example
  • Refresh mentions list after plugin install/uninstall (#15598)
    Refresh mentions list after plugin install/uninstall to that $mentions
    are updated without requiring exiting/launching the client.
  • [Codex TUI] - Sort /plugins TUI menu by installed status first, alpha second (#15558)
    Updates plugin ordering so installed plugins are listed first, with
    alphabetical sorting applied within the installed and uninstalled
    groups. The behavior is now consistent across both `tui` and
    `tui_app_server`, and related tests/snapshots were updated.
  • Finish moving codex exec to app-server (#15424)
    This PR completes the conversion of non-interactive `codex exec` to use
    app server rather than directly using core events and methods.
    
    ### Summary
    - move `codex-exec` off exec-owned `AuthManager` and `ThreadManager`
    state
    - route exec bootstrap, resume, and auth refresh through existing
    app-server paths
    - replace legacy `codex/event/*` decoding in exec with typed app-server
    notification handling
    - update human and JSONL exec output adapters to translate existing
    app-server notifications only
    - clean up "app server client" layer by eliminating support for legacy
    notifications; this is no longer needed
    - remove exposure of `authManager` and `threadManager` from "app server
    client" layer
    
    ### Testing
    - `exec` has pretty extensive unit and integration tests already, and
    these all pass
    - In addition, I asked Codex to put together a comprehensive manual set
    of tests to cover all of the `codex exec` functionality (including
    command-line options), and it successfully generated and ran these tests
  • Allow global network allowlist wildcard (#15549)
    ## Problem
    
    Today `codex-network-proxy` rejects a global `*` in
    `network.allowed_domains`, so there is no static way to configure a
    denylist-only posture for public hosts. Users have to enumerate broad
    allowlist patterns instead.
    
    ## Approach
    
    - Make global wildcard acceptance field-specific: `allowed_domains` can
    use `*`, while `denied_domains` still rejects a global wildcard.
    - Keep the existing evaluation order, so explicit denies still win first
    and local/private protections still apply unless separately enabled.
    - Add coverage for the denylist-only behavior and update the README to
    document it.
    
    ## Validation
    
    - `just fmt`
    - `cargo test -p codex-network-proxy` (full run had one unrelated flaky
    telemetry test:
    `network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event`;
    reran in isolation and it passed)
    - `cargo test -p codex-network-proxy
    network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event
    -- --exact --nocapture`
    - `just fix -p codex-network-proxy`
    - `just argument-comment-lint`
  • feat: list agents for sub-agent v2 (#15621)
    Add a `list_agents` for multi-agent v2, optionally path based
    
    This return the task and status of each agent in the matched path
  • Stabilize macOS CI test timeouts (#15581)
    ## Summary
    - raise the shell snapshot apply_patch helper timeout to avoid macOS CI
    startup races
    - increase the shared MCP app-server test read timeout so slow
    initialize handshakes do not fail command_exec tests spuriously
    
    ## Testing
    - cargo test -p codex-core
    shell_command_snapshot_still_intercepts_apply_patch
    - cargo test -p codex-app-server
    command_exec_tty_implies_streaming_and_reports_pty_output
    
    Co-authored-by: Codex <noreply@openai.com>
  • Remove filter from plugins/list result (#15580)
    Show all plugin marketplaces in the /plugins popup by removing the
    `openai-curated` marketplace filter, and update plugin popup
    copy/tests/snapshots to match the new behavior in both TUI codepaths.
  • Move sandbox policy transforms into codex-sandboxing (#15599)
    ## Summary
    - move the pure sandbox policy transform helpers from `codex-core` into
    `codex-sandboxing`
    - move the corresponding unit tests with the extracted implementation
    - update `core` and `app-server` callers to import the moved APIs
    directly, without re-exports or proxy methods
    
    ## Testing
    - cargo test -p codex-sandboxing
    - cargo test -p codex-core sandboxing
    - cargo test -p codex-app-server --lib
    - just fix -p codex-sandboxing
    - just fix -p codex-core
    - just fix -p codex-app-server
    - just fmt
    - just argument-comment-lint
  • move imagegen skill into system skills (#15600)
    Add imagegen skill as built-in skill. Source: github.com/openai/skills
  • [codex-cli][app-server] Update self-serve business usage limit copy in error returned (#15478)
    ## Summary
    - update the self-serve business usage-based limit message to direct
    users to their admin for additional credits
    - add a focused unit test for the self_serve_business_usage_based plan
    branch
    
    Added also: 
    
    If you are at a rate limit but you still have credits, codex cli would
    tell you to switch the model. We shouldnt do this if you have credits so
    fixed this.
    
    ## Test
    - launched the source-built CLI and verified the updated message is
    shown for the self-serve business usage-based plan
    
    ![Test
    screenshot](https://raw.githubusercontent.com/openai/codex/5cc3c013ef17ac5c66dfd9395c0d3c4837602231/docs/images/self-serve-business-usage-limit.png)
  • Move macOS sandbox builders into codex-sandboxing (#15593)
    ## Summary
    - move macOS permission merging/intersection logic and tests from
    `codex-core` into `codex-sandboxing`
    - move seatbelt policy builders, permissions logic, SBPL assets, and
    their tests into `codex-sandboxing`
    - keep `codex-core` owning only the seatbelt spawn wrapper and switch
    call sites to import the moved APIs directly
    
    ## Notes
    - no re-exports added
    - moved the seatbelt tests with the implementation so internal helpers
    could stay private
    - local verification is still finishing while this PR is open
  • Extract landlock helpers into codex-sandboxing (#15592)
    ## Summary
    - add a new `codex-sandboxing` crate for sandboxing extraction work
    - move the pure Linux sandbox argv builders and their unit tests out of
    `codex-core`
    - keep `core::landlock` as the spawn wrapper and update direct callers
    to use `codex_sandboxing::landlock`
    
    ## Testing
    - `cargo test -p codex-sandboxing`
    - `cargo test -p codex-core landlock`
    - `cargo test -p codex-cli debug_sandbox`
    - `just argument-comment-lint`
    
    ## Notes
    - this is step 1 of the move plan aimed at minimizing per-PR diffs
    - no re-exports or no-op proxy methods were added
  • Add fork snapshot modes (#15239)
    ## Summary
    - add `ForkSnapshotMode` to `ThreadManager::fork_thread` so callers can
    request either a committed snapshot or an interrupted snapshot
    - share the model-visible `<turn_aborted>` history marker between the
    live interrupt path and interrupted forks
    - update the small set of direct fork callsites to pass
    `ForkSnapshotMode::Committed`
    
    Note: this enables /btw to work similarly as Esc to interrupt (hopefully
    somewhat in distribution)
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>
  • feat: custom watcher for multi-agent v2 (#15576)
    The new wait tool just returns `Wait timed out.` or `Wait completed.`.
    The actual content is done through the notification watcher
  • feat: custom watcher for multi-agent v2 (#15570)
    Custom watcher that sends an InterAgentCommunication on end of turn
  • [codex] Add rollback context duplication snapshot (#15562)
    ## What changed
    - adds a targeted snapshot test for rollback with contextual diffs in
    `codex_tests.rs`
    - snapshots the exact model-visible request input before the rolled-back
    turn and on the follow-up request after rollback
    - shows the duplicate developer and environment context pair appearing
    again before the follow-up user message
    
    ## Why
    Rollback currently rewinds the reference context baseline without
    rewinding the live session overrides. On the next turn, the same
    contextual diff is emitted again and duplicated in the request sent to
    the model.
    
    ## Impact
    - makes the regression visible in a canonical snapshot test
    - keeps the snapshot on the shared `context_snapshot` path without
    adding new formatting helpers
    - gives a direct repro for future fixes to rollback/context
    reconstruction
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>
  • chore(core) Add approvals reviewer to UserTurn (#15426)
    ## Summary
    Adds support for approvals_reviewer to `Op::UserTurn` so we can migrate
    `[CodexMessageProcessor::turn_start]` to use Op::UserTurn
    
    ## Testing
    - [x] Adds quick test for the new field
    
    Co-authored-by: Codex <noreply@openai.com>
  • feat: use serde to differenciate inter agent communication (#15560)
    Use `serde` to encode the inter agent communication to an assistant
    message and use the decode to see if this is such a message
    
    Note: this assume serde on small pattern is fast enough
  • [hooks] add non-streaming (non-stdin style) shell-only PreToolUse support (#15211)
    - add `PreToolUse` hook for bash-like tool execution only at first
    - block shell execution before dispatch with deny-only hook behavior
    - introduces common.rs matcher framework for matching when hooks are run
    
    example run:
    
    ```
    › run three parallel echo commands, and the second one should echo "[block-pre-tool-use]" as a test
    
    
    • Running the three echo commands in parallel now and I’ll report the output directly.
    
    • Running PreToolUse hook: name for demo pre tool use hook
    
    • Running PreToolUse hook: name for demo pre tool use hook
    
    • Running PreToolUse hook: name for demo pre tool use hook
    
    PreToolUse hook (completed)
      warning: wizard-tower PreToolUse demo inspected Bash: echo "first parallel echo"
      
    PreToolUse hook (blocked)
      warning: wizard-tower PreToolUse demo blocked a Bash command on purpose.
      feedback: PreToolUse demo blocked the command. Remove [block-pre-tool-use] to continue.
    
    PreToolUse hook (completed)
      warning: wizard-tower PreToolUse demo inspected Bash: echo "third parallel echo"
    
    • Ran echo "first parallel echo"
      └ first parallel echo
    
    • Ran echo "third parallel echo"
      └ third parallel echo
    
    • Three little waves went out in parallel.
    
      1. printed first parallel echo
      2. was blocked before execution because it contained the exact test string [block-pre-tool-use]
      3. printed third parallel echo
    
      There was also an unrelated macOS defaults warning around the successful commands, but the echoes
      themselves worked fine. If you want, I can rerun the second one with a slightly modified string so
      it passes cleanly.
    ```
  • feat: new op type for sub-agents communication (#15556)
    Add `InterAgentCommunication` for v2 agent communication
  • Unify realtime stop handling in TUI (#15529)
    ## Summary
    - route /realtime, Ctrl+C, and deleted realtime meters through the same
    realtime stop path
    - keep generic transcription placeholder cleanup free of realtime
    shutdown side effects
    
    ## Testing
    - Ran 
    - Relied on CI for verification; did not run local tests
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>
  • feat: support disable skills by name. (#15378)
    Support disabling skills by name, primarily for plugin skills. We can’t
    use the path, since plugin skill paths may change across versions.
  • Thread guardian Responses API errors into denial rationale (#15516)
    ## Summary
    - capture the last guardian `EventMsg::Error` while waiting for review
    completion
    - reuse that error as the denial rationale when the review turn
    completes without an assessment payload
    - add a regression test for the `/responses` HTTP 400 path
    
    ## Testing
    - `just fmt`
    - `cargo test -p codex-core
    guardian_review_surfaces_responses_api_errors_in_rejection_reason`
    - `just argument-comment-lint -p codex-core`
    
    ## Notes
    - `cargo test -p codex-core` still fails on the pre-existing unrelated
    test
    `tools::js_repl::tests::js_repl_imported_local_files_can_access_repl_globals`
    in this environment (`mktemp ... Operation not permitted` while
    downloading `dotslash`)
    
    Co-authored-by: Codex <noreply@openai.com>
  • Plugins TUI install/uninstall (#15342)
    - Add install/uninstall actions to the TUI plugins menu
    - Wire plugin install/uninstall through both TUI and `tui_app_server`
    - Refresh config/plugin state after changes so the UI updates
    immediately
    - Add a post-install app setup flow for plugins that require additional
    app auth
    
    <img width="1567" height="300" alt="Screenshot 2026-03-20 at 4 08 44 PM"
    src="https://github.com/user-attachments/assets/366bd31b-2ffd-4e80-b4a3-3a9a9c674a5f"
    />
    <img width="445" height="240" alt="Screenshot 2026-03-20 at 4 08 54 PM"
    src="https://github.com/user-attachments/assets/613999ab-269a-4758-ab59-7c057a1742dc"
    />
    <img width="797" height="219" alt="Screenshot 2026-03-20 at 4 09 07 PM"
    src="https://github.com/user-attachments/assets/b9679e60-40f5-49bb-ade0-2e40449c3fbf"
    />
    <img width="499" height="235" alt="Screenshot 2026-03-20 at 4 09 24 PM"
    src="https://github.com/user-attachments/assets/261ce2fe-f356-4e99-8ac9-f29ed850bc75"
    />
    
    
    
    
    Note/known issue: The /plugin install flow fails in `tui_app_server`
    because after a successful install it tries to trigger a
    ReloadUserConfig operation, but `tui_app_server` has not yet implemented
    transport for that operation, so it falls through to the generic “Not
    available in app-server TUI yet” stub.
  • Fix: proactive auth refresh to reload guarded disk state first (#15357)
    ## Summary
    
    Fix a managed ChatGPT auth bug where a stale Codex process could
    proactively refresh using an old in-memory refresh token even after
    another process had already rotated auth on disk.
    
    This changes the proactive `AuthManager::auth()` path to reuse the
    existing guarded `refresh_token()` flow instead of calling the refresh
    endpoint directly from cached auth state.
    
    ## Original Issue
    
    Users reported repeated `codexd` log lines like:
    
    ```text
    ERROR codex_core::auth: Failed to refresh token: error sending request for url (https://auth.openai.com/oauth/token)
    ```
    
    In practice this showed up most often when multiple `codexd` processes
    were left running. Killing the extra processes stopped the noise, which
    suggested the issue was caused by stale auth state across processes
    rather than invalid user credentials.
    
    ## Diagnosis
    
    The bug was in the proactive refresh path used by `AuthManager::auth()`:
    
    - Process A could refresh successfully, rotate refresh token `R0` to
    `R1`, and persist the updated auth state plus `last_refresh` to disk.
    - Process B could keep an older auth snapshot cached in memory, still
    holding `R0` and the old `last_refresh`.
    - Later, when Process B called `auth()`, it checked staleness from its
    cached in-memory auth instead of first reloading from disk.
    - Because that cached `last_refresh` was stale, Process B would
    proactively call `/oauth/token` with stale refresh token `R0`.
    - On failure, `auth()` logged the refresh error but kept returning the
    same stale cached auth, so repeated `auth()` calls could keep retrying
    with dead state.
    
    This differed from the existing unauthorized-recovery flow, which
    already did the safer thing: guarded reload from disk first, then
    refresh only if the on-disk auth was unchanged.
    
    ## What Changed
    
    - Switched proactive refresh in `AuthManager::auth()` to:
      - do a pure staleness check on cached auth
      - call `refresh_token()` when stale
    - return the original cached auth on genuine refresh failure, preserving
    existing outward behavior
    - Removed the direct proactive refresh-from-cached-state path
    - Added regression tests covering:
      - stale cached auth with newer same-account auth already on disk
    - the same scenario even when the refresh endpoint would fail if called
    
    ## Why This Fix
    
    `refresh_token()` already contains the right cross-process safety
    behavior:
    
    - guarded reload from disk
    - same-account verification
    - skip-refresh when another process already changed auth
    
    Reusing that path makes proactive refresh consistent with unauthorized
    recovery and prevents stale processes from trying to refresh
    already-rotated tokens.
    
    ## Testing
    
    Test shape:
    
    - create a fresh temp `CODEX_HOME` from `~/.codex/auth.json`
    - force `last_refresh` to an old timestamp so proactive refresh is
    required
    - start two long-lived helper processes against the same auth file
    - start `B` first so it caches stale auth and sleeps
    - start `A` second so it refreshes first
    - point both at a local mock `/oauth/token` server
    - inspect whether `B` makes a second refresh request with the stale
    in-memory token, or reloads the rotated token from disk
    
    ### Before the fix
    
    The repro showed the bug clearly: the mock server saw two refreshes with
    the same stale token, `A` rotated to a new token, and `B` still returned
    the stale token instead of reloading from disk.
    
    ```text
    POST /oauth/token refresh_token=rt_j6s0...
    POST /oauth/token refresh_token=rt_j6s0...
    
    B:cached_before=rt_j6s0...
    B:cached_after=rt_j6s0...
    B:returned=rt_j6s0...
    
    A:cached_before=rt_j6s0...
    A:cached_after=rotated-refresh-token-logged-run-v2
    A:returned=rotated-refresh-token-logged-run-v2
    ```
    
    ### After the fix
    
    After the fix, the mock server saw only one refresh request. `A`
    refreshed once, and `B` started with the stale token but reloaded and
    returned the rotated token.
    
    ```text
    POST /oauth/token refresh_token=rt_j6s0...
    
    B:cached_before=rt_j6s0...
    B:cached_after=rotated-refresh-token-fix-branch
    B:returned=rotated-refresh-token-fix-branch
    
    A:cached_before=rt_j6s0...
    A:cached_after=rotated-refresh-token-fix-branch
    A:returned=rotated-refresh-token-fix-branch
    ```
    
    This shows the new behavior: `A` refreshes once, then `B` reuses the
    updated auth from disk instead of making a second refresh request with
    the stale token.
  • feat: structured multi-agent output (#15515)
    Send input now sends messages as assistant message and with this format:
    
    ```
    author: /root/worker_a
    recipient: /root/worker_a/tester
    other_recipients: []
    Content: bla bla bla. Actual content. Only text for now
    ```
  • tui: queue follow-ups during manual /compact (#15259)
    ## Summary
    - queue input after the user submits `/compact` until that manual
    compact turn ends
    - mirror the same behavior in the app-server TUI
    - add regressions for input queued before compact starts and while it is
    running
    
    Co-authored-by: Codex <noreply@openai.com>
  • Label plugins as plugins, and hide skills/apps for given plugin (#15279)
    - Duplicate app mentions are now suppressed when they’re plugin-backed
    with the same display name.
    - Remaining connector mentions now label category as [Plugin] when
    plugin metadata is present, otherwise [App].
    - Mention result lists are now capped to 8 rows after filtering.
    - Updates both tui and tui_app_server with the same changes.
  • fix: fall back to vendored bubblewrap when system bwrap lacks --argv0 (#15338)
    ## Why
    
    Fixes [#15283](https://github.com/openai/codex/issues/15283), where
    sandboxed tool calls fail on older distro `bubblewrap` builds because
    `/usr/bin/bwrap` does not understand `--argv0`. The upstream [bubblewrap
    v0.9.0 release
    notes](https://github.com/containers/bubblewrap/releases/tag/v0.9.0)
    explicitly call out `Add --argv0`. Flipping `use_legacy_landlock`
    globally works around that compatibility bug, but it also weakens the
    default Linux sandbox and breaks proxy-routed and split-policy cases
    called out in review.
    
    The follow-up Linux CI failure was in the new launcher test rather than
    the launcher logic: the fake `bwrap` helper stayed open for writing, so
    Linux would not exec it. This update also closes the user-visibility gap
    from review by surfacing the same startup warning when `/usr/bin/bwrap`
    is present but too old for `--argv0`, not only when it is missing.
    
    ## What Changed
    
    - keep `use_legacy_landlock` default-disabled
    - teach `codex-rs/linux-sandbox/src/launcher.rs` to fall back to the
    vendored bubblewrap build when `/usr/bin/bwrap` does not advertise
    `--argv0` support
    - add launcher tests for supported, unsupported, and missing system
    `bwrap`
    - write the fake `bwrap` test helper to a closed temp path so the
    supported-path launcher test works on Linux too
    - extend the startup warning path so Codex warns when `/usr/bin/bwrap`
    is missing or too old to support `--argv0`
    - mirror the warning/fallback wording across
    `codex-rs/linux-sandbox/README.md` and `codex-rs/core/README.md`,
    including that the fallback is the vendored bubblewrap compiled into the
    binary
    - cite the upstream `bubblewrap` release that introduced `--argv0`
    
    ## Verification
    
    - `bazel test --config=remote --platforms=//:rbe
    //codex-rs/linux-sandbox:linux-sandbox-unit-tests
    --test_filter=launcher::tests::prefers_system_bwrap_when_help_lists_argv0
    --test_output=errors`
    - `cargo test -p codex-core system_bwrap_warning`
    - `cargo check -p codex-exec -p codex-tui -p codex-tui-app-server -p
    codex-app-server`
    - `just argument-comment-lint`
  • Use Shift+Left to edit queued messages in tmux (#15480)
    ## Summary
    - use Shift+Left to edit the most recent queued message when running
    under tmux
    - mirror the same binding change in the app-server TUI
    - add tmux-specific tests and snapshot coverage for the rendered
    queued-message hint
    
    ## Testing
    - just fmt
    - cargo test -p codex-tui
    - cargo test -p codex-tui-app-server
    - just argument-comment-lint -p codex-tui -p codex-tui-app-server
    
    Co-authored-by: Codex <noreply@openai.com>
  • core: snapshot fork startup context injection (#15443)
    ## Summary
    - add a snapshot-style core test for fork startup context injection
    followed by first-turn diff injection
    - capture the current duplicated startup-plus-turn context behavior
    without changing runtime logic
    
    ## Testing
    - not run locally; relying on CI
    - just fmt
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>