Commit Graph

7686 Commits

  • [codex] configure rollout budget reminder thresholds (#29423)
    ## Summary
    
    Instead of:
    
        reminder_interval_tokens = 65_536
    
    allow users to configure explicit remaining-token reminder thresholds:
    
    reminder_at_remaining_tokens = [65_536, 32_768, 16_384, 8_192, 4_096,
    2_048, 1_024, 512]
    
    ## Validation
    
    - CARGO_INCREMENTAL=0 just test -p codex-core rollout_budget: 9 passed
    - just fix -p codex-core
    - just fmt
  • Allow ChatGPT accounts without email (#28991)
    # Summary
    
    Codex required every ChatGPT account to have an email address. A
    service-account personal access token can return valid account metadata
    without one, so PAT login failed while decoding the metadata response.
    
    This change makes email optional in the account metadata type that owns
    it and preserves that absence through authentication, provider account
    state, the app-server API, generated clients, and TUI bootstrap.
    Existing accounts with email addresses keep the same behavior.
    
    ## Behavior-changing call sites
    
    | Call site | Behavior after this change |
    | --- | --- |
    | `login/src/auth/personal_access_token.rs` | PAT metadata accepts a
    missing or null email and retains `None`. |
    | `agent-identity/src/lib.rs` | Agent Identity JWT claims accept an
    omitted email. |
    | `login/src/auth/storage.rs` and `login/src/auth/agent_identity.rs` |
    Stored and managed Agent Identity records carry `Option<String>`.
    Deserialization maps the legacy empty-string sentinel to `None`. |
    | `login/src/auth/manager.rs` | `get_account_email` returns the stored
    option, and managed identity bootstrap no longer converts `None` to an
    empty string. |
    | `model-provider/src/provider.rs` and `protocol/src/account.rs` | A
    ChatGPT provider account requires a plan type but may carry no email. |
    | `app-server-protocol/src/protocol/v2/account.rs` | `account/read`
    keeps the `email` field on the wire and returns `null` when the account
    has no email. Generated TypeScript and JSON schemas describe a required,
    nullable field. |
    | `sdk/python/src/openai_codex/generated/v2_all.py` | The generated
    Python `ChatgptAccount` model accepts `None` for email. |
    | `tui/src/app_server_session.rs` | Email-less ChatGPT accounts
    bootstrap normally, keep external feedback routing, omit account-email
    telemetry, and display the plan in account status. |
    
    ## Design decisions
    
    - Missing email remains `None` at every layer. The code never uses an
    empty string as a substitute.
    - The app-server response includes `"email": null` instead of omitting
    the field. Clients retain a stable response shape.
    - Plan type remains required for provider account state. This change
    relaxes only the email assumption.
    
    ## Testing
    
    Tests: affected test targets compile, scoped Clippy and formatting pass,
    a focused TUI snapshot covers plan-only account status, real
    before/after PAT login smoke covers metadata without email, app-server
    smoke covers `account/read` with `email: null`, and a regression smoke
    covers an existing email-bearing PAT. Unit tests run in CI.
    
    ## Evidence
    
    Visual smoke evidence will be attached here.
  • PAC 2 - Add shared auth system proxy contract (#26707)
    ## Summary
    
    Stacked on #26706.
    
    Adds the shared auth/system-proxy contract that later platform resolver
    PRs plug into. This PR moves Codex-owned auth and startup HTTP clients
    through a common route-aware boundary, but does not yet add Windows or
    macOS system proxy resolution.
    
    The default path remains unchanged when `respect_system_proxy` is absent
    or disabled.
    
    ## Implementation
    
    - Adds `codex-client/src/outbound_proxy.rs` with the shared
    route-selection model:
      - `OutboundProxyConfig`;
      - `ClientRouteClass`;
      - `RouteFailureClass`;
      - `build_reqwest_client_for_route`.
    - Preserves the existing reqwest/default-client behavior when no route
    config is supplied.
    - Uses the fixed MVP routing policy when route config is supplied:
    platform system/PAC/WPAD discovery, then explicit env proxy variables,
    then direct connection.
    - Keeps platform-specific system discovery behind the shared client
    boundary. This PR provides the contract and fallback behavior; later
    resolver PRs plug in Windows and macOS discovery.
    - Adds `login::AuthRouteConfig` so auth call sites depend on a small
    policy type instead of platform resolver details.
    - Maps the resolved `Config.respect_system_proxy` boolean into
    `AuthRouteConfig` for auth-owned clients.
    - Wires the route config through browser login, device-code login,
    access-token login, login status, logout/revoke, token refresh, API-key
    exchange, app-server account login, TUI/app startup, cloud-config
    bootstrap, cloud tasks, plugin auth, and exec startup config loading.
    
    ## End-user behavior
    
    - No behavior changes by default.
    - When `respect_system_proxy = true`, auth-owned clients opt into the
    shared route-aware client path.
    - On platforms without a resolver implementation in this PR, system
    discovery is unavailable and the route-aware path falls back to explicit
    env proxy handling, then direct connection.
    - Custom CA handling remains separate from proxy route selection and
    still runs through the shared client builder.
    - No proxy URLs, PAC contents, or resolved platform details are exposed
    through the public config surface introduced here.
    
    ## Tests
    
    Adds or updates coverage for:
    
    - preserving default auth-client fallback behavior when no route config
    is provided;
    - injected environment-proxy fallback without mutating process
    environment;
    - existing login-server E2E flows using explicit `auth_route_config:
    None` to guard unchanged default behavior;
    - updated auth manager, login, logout, cloud-config, startup, and
    plugin-auth call sites passing route config explicitly.
  • core: remove unused permissions cwd plumbing (#29468)
    ## Why
    
    `compile_scoped_filesystem_pattern()` accepted a `_policy_cwd` parameter
    even though scoped glob compilation no longer uses the policy working
    directory. Keeping that unused argument forced the surrounding
    permissions compilation path to keep forwarding `policy_cwd` through
    call sites that did not need it, making the API look more dependent on
    cwd resolution than it is.
    
    ## What changed
    
    Removed the unused cwd parameter from
    `compile_scoped_filesystem_pattern()` and the callers that only
    forwarded it: `compile_filesystem_permission()`,
    `compile_permission_profile()`, and
    `compile_permission_profile_selection()`. Workspace root resolution
    still keeps `policy_cwd`, because that path still resolves relative
    roots against the active policy cwd.
    
    Relevant code:
    [`codex-rs/core/src/config/permissions.rs`](https://github.com/openai/codex/blob/b8b9816102e064dae4488ec130cf560f63c1ab78/codex-rs/core/src/config/permissions.rs#L346).
    
    ## Verification
    
    - `just test -p codex-core config::permissions`
    - `just test -p codex-core` was also run after building
    `test_stdio_server`; it passed the touched permissions coverage but
    still reported unrelated existing failures in `cli_stream` and shell
    snapshot tests.
  • [codex] Start the guardian child session when parent session is started (#27982)
    ## Why
    
    The first auto-review currently creates its Guardian child session on
    demand, adding avoidable latency before the review can begin. Creating
    the ordinary Guardian child during parent-session initialization lets
    that child use the existing session startup WebSocket prewarm before the
    first escalation. This does not introduce a Guardian-specific prewarm
    mechanism.
    
    ## What changed
    
    - initialize the existing Guardian review-session manager owned by
    `Session` when a thread starts with auto-review enabled and an approval
    policy that routes to Guardian
    - use the standard Guardian child-session construction and the existing
    session startup WebSocket prewarm
    - preserve the existing reuse-key invalidation and lazy creation
    fallback when startup initialization fails or the effective review
    configuration changes
    - add an integration test that verifies normal root-session startup
    emits a Guardian `generate=false` prewarm request
    
    ## Benchmark
    
    I compared release builds against main. Each prompt first ran a
    non-escalated `sleep 3`, then requested an escalated marker command.
    
    | binary | count | avg Guardian duration | median Guardian duration |
    avg Guardian TTFT |
    |---|---:|---:|---:|---:|
    | origin-main | 10 | 4008.7 ms | 3949.5 ms | 3746.5 ms |
    | session-fix | 10 | 2865.0 ms | 2594.0 ms | 2492.7 ms |
    
    Guardian duration fell by 28.5% and Guardian TTFT fell by 33.5%. These
    measurements cover Guardian review latency; they do not measure parent
    thread-start latency.
  • [codex] Fix usage-limit reset copy and state (#28793)
    ## Why
    
    The reset flow introduced in #28154 still describes earned reset credits
    as "rate-limit resets" and uses generic reset-scope copy. It can also
    retain a stale available-credit count after redemption or an account
    change, leaving the reset action enabled after the last credit is used.
    
    This follow-up updates terminology only within that reset feature.
    Existing rate-limit wording elsewhere in the CLI and TUI is unchanged.
    
    ## What changed
    
    - Rename reset-specific `/usage` menu items, startup hints, and reset
    dialogs to "usage limit reset."
    - Describe monthly resets for Free, Go, and accounts that report a
    monthly usage window; otherwise describe the current 5-hour and weekly
    limits.
    - Recheck a cached zero balance when `/usage` is reopened, and refresh
    the balance after redemption so the final reset immediately disables the
    action.
    - Correlate async refresh results before updating snapshots and clear
    account-derived reset state, warnings, prompts, and status surfaces when
    the account changes.
    
    ## Validation
    
    - `just test -p codex-tui chatwidget::tests::usage` — 29 passed.
    - `just test -p codex-tui chatwidget::tests::status_command_tests` — 7
    passed.
    - Account-boundary prompt and plan-mode prompt regression tests passed.
    - `cargo insta pending-snapshots` from `codex-rs/tui` — no pending
    snapshots.\
    
    <img width="814" height="318" alt="image"
    src="https://github.com/user-attachments/assets/2a460e96-458b-4805-8d9f-c759382d21a4"
    />
    view for monthly
    <img width="905" height="243" alt="image"
    src="https://github.com/user-attachments/assets/179f88e3-08fb-4af5-8dc6-ce6a944ed681"
    />
  • [sdk/python] Stop advertising HTTP image URLs (#29464)
    ## Summary
    
    - use generated image data URLs in the Python SDK examples and notebook
    - document HTTP and HTTPS image URLs as deprecated and recommend
    `LocalImageInput`
    - replace the remote-URL integration test with data-URL coverage
    
    `ImageInput` remains available for data URLs. The SDK does not duplicate
    app-server URL validation.
    
    ## Testing
    
    - `uv run --frozen --no-sync ruff check --output-format=full .`
    - `uv run --frozen --no-sync ruff format --check .`
    - full Python SDK test suite with an isolated writable
    `CODEX_SQLITE_HOME` (119 passed, 38 skipped)
  • core: rename metadata -> internal_chat_message_metadata_passthrough (#28968)
    ## Description
    This PR cuts Codex over from generic `ResponseItem.metadata` (introduced
    here: https://github.com/openai/codex/pull/28355) to
    `ResponseItem.internal_chat_message_metadata_passthrough`, which is the
    blessed path and has strongly-typed keys.
    
    For now we have to drop this MAv2 usage of `metadata`:
    https://github.com/openai/codex/pull/28561 until we figure out where
    that should live.
  • Report remote sandbox denials semantically (#29424)
    ## Why
    
    #29113 moved remote sandbox setup and enforcement to the exec server.
    That gives the executor ownership of the platform-specific work: a Linux
    executor chooses and runs a Linux sandbox even when the Codex
    orchestrator is running on macOS or Windows.
    
    It also means the orchestrator no longer knows which concrete sandbox
    the executor selected. When that sandbox blocks a remote command, the
    orchestrator currently sees only a failed process and can treat the
    denial as an ordinary command failure. The existing sandbox approval and
    retry path is then skipped.
    
    This PR lets the executor report one portable fact:
    
    > This command probably failed because the executor sandbox blocked it.
    
    The executor keeps its concrete sandbox type private. The protocol sends
    only the semantic result.
    
    ## Example
    
    Suppose a local macOS Codex session asks a Linux devbox to write outside
    the allowed workspace.
    
    Before this PR:
    
    ```text
    Linux sandbox blocks the write
        -> remote process exits with "Permission denied"
        -> local orchestrator sees an ordinary command failure
        -> the normal sandbox approval and retry path can be skipped
    ```
    
    With this PR:
    
    ```text
    Linux sandbox blocks the write
        -> executor reports sandboxDenied: true
        -> unified exec returns UnifiedExecError::SandboxDenied
        -> the existing approval prompt is shown
        -> an approved retry runs through the existing unsandboxed retry path
    ```
    
    ## What changes
    
    ### The executor remembers its selected sandbox
    
    The prepared remote process now retains the executor-selected
    `SandboxType`. This value never crosses the executor boundary.
    
    Commands started without a sandbox retain `SandboxType::None` and are
    never reported as sandbox denials.
    
    ### The executor uses the existing denial heuristic
    
    The existing local denial heuristic moves from `codex-core` into the
    shared `codex-sandboxing` crate.
    
    When a sandboxed remote process exits, the executor:
    
    1. waits the same short output grace period used by local unified exec;
    2. reads the output currently available in the existing retained output
    buffer;
    3. runs the existing heuristic using the exit code and common denial
    messages;
    4. stores the yes/no result before publishing the process exit.
    
    This deliberately matches the old local unified-exec behavior. It does
    not add a new streaming classifier, another output buffer, or stronger
    output-retention guarantees.
    
    ### The protocol reports a portable boolean
    
    `process/read` gains `sandboxDenied`:
    
    ```json
    {
      "exited": true,
      "exitCode": 1,
      "closed": false,
      "sandboxDenied": true
    }
    ```
    
    The field defaults to `false` when an older executor omits it. The
    response does not expose the executor sandbox implementation or
    executor-native paths.
    
    ### Unified exec uses the existing error path
    
    The exec-server client carries `sandboxDenied` into the unified process
    state. If it is true, unified exec returns the existing `SandboxDenied`
    error instead of trying to classify remote output using an
    orchestrator-side sandbox type.
    
    Remote process exit remains visible as soon as the process exits. This
    PR does not wait for stdout or stderr to close and does not change the
    existing process lifecycle.
    
    ## Scope
    
    This PR is intentionally limited to matching the existing local
    unified-exec behavior for the initial command execution path.
    
    It does not add:
    
    - incremental denial tracking across the full output stream;
    - new denial handling for commands completed later through
    `write_stdin`;
    - new guarantees for preserving the semantic flag during the narrow
    reconnect-recovery race.
    
    Those can be considered separately if the same behavior is added for
    local execution.
    
    ## Test coverage
    
    One remote end-to-end integration test covers the complete intended
    flow:
    
    ```text
    remote read-only sandbox
        -> denied write
        -> executor reports the denial
        -> Codex requests approval
        -> user approves
        -> retry succeeds on the remote executor
    ```
    
    Existing lifecycle coverage continues to verify that remote process exit
    is reported before late output streams close.
  • TUI Plugin Sharing 3 - render remote plugin catalog sections (#26703)
    ## Summary
    
    [#26701](https://github.com/openai/codex/pull/26701) added remote plugin
    identity support, [#26702](https://github.com/openai/codex/pull/26702)
    added remote-section fetching and state, and
    [#28768](https://github.com/openai/codex/pull/28768) extracted the
    catalog rendering module. This PR builds the product-facing `/plugins`
    catalog on that foundation so remote records appear as OpenAI Curated,
    Workspace, and Shared with me sections rather than backend marketplace
    implementation details.
    
    Plugin details remain read-only for sharing metadata. This PR does not
    add share-authoring actions or change the app-server protocol.
    
    ## Changes
    
    - Renders OpenAI Curated, Workspace, and Shared with me sections with
    loading, empty, and error states.
    - Preserves section selection and stable tab ordering as remote sections
    transition between fallback and populated states.
    - Shows OpenAI Curated loading only when the explicit vertical fallback
    request was issued.
    - Centralizes remote marketplace identity matching around the existing
    marketplace constants.
    - Uses product labels for remote marketplaces and identifies the
    personal marketplace as Local by its path.
    - Shows read-only source, authentication, version, and sharing metadata
    in plugin detail views.
    - Applies narrow display deduplication for local and remote records
    sharing a remote plugin ID:
      - installed records take precedence;
    - local mapped sources are preferred for details only when their
    installed state matches the selected record.
    - Returns from detail and confirmation views through the current plugin
    cache so newly loaded remote sections are not overwritten by an older
    captured response.
    - Keeps admin-disabled plugins view-only and labels default-installed
    plugins as Available by default.
    
    ## Tests
    
    New tests:
    
    - `plugins_popup_admin_disabled_available_plugin_has_view_only_hint`
    - `plugins_popup_remote_section_fallback_states_snapshot`
    -
    `plugins_popup_installed_remote_row_keeps_remote_detail_when_local_share_is_uninstalled`
    
    Updated existing plugin catalog tests and snapshots for product labels,
    detail metadata, personal-marketplace labeling, and stable tab ordering.
    
    Verification:
    
    - `cargo clippy -p codex-tui --all-targets -- -D warnings`
    
    ## Follow-ups
    
    - Local/remote duplicate normalization should eventually move into
    app-server. This PR intentionally keeps the compatibility behavior
    narrow and display-only.
    - PR5 will sanitize sensitive components before displaying Git source
    URLs.
  • [codex] Centralize Plugin Analytics Metadata (#27102)
    This PR moves construction of `PluginTelemetryMetadata` from loader and
    model helpers into `PluginsManager`, which already owns installed plugin
    state and will eventually perform remote identity enrichment. The
    metadata type remains in `codex-plugin`, and serialized analytics events
    remain unchanged.
    
    ## Before
    
    ```mermaid
    flowchart LR
        subgraph Events["Analytics event paths"]
            direction TB
            Lifecycle["Local install / uninstall"]
            Config["Enable / disable"]
            Remote["Remote install"]
            Used["Plugin used"]
        end
    
        subgraph Construction["Metadata construction"]
            direction TB
            Loader["Loader telemetry helpers"]
            Summary["PluginCapabilitySummary::telemetry_metadata"]
            Override["Caller adds remote_plugin_id"]
        end
    
        Metadata["PluginTelemetryMetadata"]
    
        Lifecycle --> Loader
        Config --> Loader
        Remote --> Loader
        Loader -->|"local events"| Metadata
        Loader -->|"remote install"| Override
        Override --> Metadata
        Used --> Summary
        Summary --> Metadata
    ```
    
    Telemetry metadata was constructed through loader helpers, a
    capability-summary method, and a remote-install call-site override.
    
    ## After
    
    ```mermaid
    flowchart LR
        subgraph Events["Analytics event paths"]
            direction TB
            Lifecycle["Local install / uninstall"]
            Config["Enable / disable"]
            Remote["Remote install"]
            Used["Plugin used"]
        end
    
        Manager["PluginsManager — single construction owner"]
        Metadata["PluginTelemetryMetadata"]
    
        Lifecycle --> Manager
        Config --> Manager
        Remote -->|"authoritative remote ID"| Manager
        Used -->|"capability summary"| Manager
        Manager --> Metadata
    ```
    
    Every analytics path delegates metadata construction to
    `PluginsManager`. Remote install still supplies its authoritative
    backend ID explicitly.
    
    ## What Changes
    
    - Make loader code return a focused plugin capability summary instead of
    constructing analytics metadata.
    - Centralize immutable plugin telemetry metadata construction in
    `PluginsManager`.
    - Route local install/uninstall, remote install, enable/disable, and
    plugin-used emitters through the manager.
    - Preserve the current serialized analytics contract exactly.
    
    Normal metadata still has no remote override. Remote install continues
    to provide its authoritative backend ID explicitly, so the existing
    serializer continues reporting that ID through `plugin_id`.
    Snapshot-based enrichment is intentionally deferred to the final PR.
    
    ## Testing
    
    - `just test -p codex-core-plugins` (238 tests passed)
    - `just test -p codex-plugin` (3 tests passed)
    - Scoped Clippy/compile checks passed for `codex-plugin`,
    `codex-core-plugins`, `codex-app-server`, and `codex-core`.
    
    ## Split Overview
    
    ```text
    main
    ├── #27093  Debug analytics capture                 (merged)
    ├── #27099  Non-mutating plugin smoke               (merged)
    ├── #27100  Remote install/uninstall smoke          (merged)
    └── #27102  Plugin telemetry metadata refactor      ← you are here
        └── #27669  Persist remote plugin identity
    
    After #27102 and #27669 merge:
    └── Final PR: add explicit local and remote IDs to plugin analytics
    ```
    
    Review order and dependencies:
    
    1. [#27093 Add debug-only analytics event
    capture](https://github.com/openai/codex/pull/27093) (merged)
    2. [#27099 Add a plugin analytics smoke
    workflow](https://github.com/openai/codex/pull/27099) (merged)
    3. [#27100 Add a remote plugin analytics mutation smoke
    workflow](https://github.com/openai/codex/pull/27100) (merged)
    4. This metadata refactor, independent and based on `main`
    5. [#27669 Persist remote plugin
    identity](https://github.com/openai/codex/pull/27669), stacked on this
    PR
    6. Final remote-ID behavior PR, created after the prerequisites merge
    
    The original [#26281](https://github.com/openai/codex/pull/26281)
    remains open as the aggregate reference until the final replacement PR
    is published.
  • ci: restore custom Windows runner with hermetic LLVM 0.7.9 (#29143)
    The custom Windows argument-comment-lint job was temporarily moved to
    `windows-2022` in #28940 after hermetic LLVM source extraction failed on
    the newer runner. This takes the upstream extraction fix so the job can
    return to the intended custom runner.
    
    This upgrades `llvm` to `0.7.9` and `rules_cc` to `0.2.18`, refreshes
    the module lock, rebases the remaining Windows and custom libc++
    patches, drops the obsolete symlink-extraction workaround, and restores
    the `windows-x64` runner configuration.
    
    Validation:
    
    - Verified all LLVM patches apply cleanly against the `0.7.9` source.
    - Built `@llvm-project//compiler-rt:clang_rt.builtins.static`.
  • remove flag for image preparation (#29429)
    ## What
    
    - make Fjord's centralized response-item image preparation unconditional
    for new and resumed history
    - have local user images and `view_image` outputs always defer decoding
    and resizing to that path
    - retain `resize_all_images` as an ignored, removed compatibility key
    for released clients
    - delete the flag-off producer paths and obsolete policy-specific tests
    
    ## Why
    
    Centralized preparation is now the intended image path. Keeping the
    runtime feature checks also kept two image-processing implementations
    alive and allowed client config to select the legacy behavior.
    
    This is a clean replacement for #28975, rebuilt from the latest `main`.
    
    ## How
    
    `prepare_response_items` now runs whenever items enter history and
    whenever persisted history is reconstructed. Producers emit deferred
    image data, so malformed images become the existing model-visible
    placeholder instead of failing the session at the producer.
    
    ## Test plan
    
    - `just fmt`
    - `just fix -p codex-core -p codex-features`
    - `just test -p codex-features` — 52 passed
    - focused affected `codex-core` set — 20 passed
    - `just test -p codex-core handle_accepts_explicit_high_detail` — 1
    passed
    - full `just test -p codex-core` attempt — 2,723 passed; 88 unrelated
    environment failures from read-only `~/.codex` SQLite state and
    unavailable integration helper binaries
  • Filter noisy targets from persistent logs (#29457)
    ## Why
    
    The local SQLite log sink currently enables TRACE for every target. This
    persists high-volume dependency logs bridged through `target=log` and
    duplicates OpenTelemetry mirror events in `codex_otel.log_only` and
    `codex_otel.trace_safe`.
    
    These records rapidly consume the per-partition log budget and cause
    unnecessary SQLite insert-and-prune churn.
    
    ## What changed
    
    - Keep TRACE persistence for other targets.
    - Exclude bridged `target=log` events from the SQLite sink.
    - Exclude the two `codex_otel` mirror targets from the SQLite sink.
    - Share the same filter between app-server and TUI.
    
    Remote OpenTelemetry export and metrics are unchanged.
  • fix(core): restore thread_source in x-codex-turn-metadata (#29455)
    ## Description
    
    Restore `thread_source` in `x-codex-turn-metadata`.
    
    Inadvertently removed `thread_source` from `x-codex-turn-metadata` in
    https://github.com/openai/codex/pull/27122 - didn't realize it was a
    top-level thread app-server API field, not passed in
    `responsesapi_client_metadata`.
    
    This also reserves the key so `responsesapi_client_metadata` cannot
    override it.
  • core: refresh environment context before sampling (#29073)
    ## Why
    
    Nonblocking environment snapshots allow a turn to reach the model while
    a remote environment is still starting. The initial context can describe
    that environment as still loading, but nothing currently refreshes the
    model-visible environment context when startup finishes during the same
    turn.
    
    This adds the first request-scoped reconciliation slice on top of
    #28683. It is gated by `DeferredExecutor` and intentionally updates only
    model-visible environment context; tools and other environment-derived
    state will migrate separately.
    
    ## What
    
    - Add a minimal `StepContext` containing the environment snapshot
    captured before each sampling request.
    - Render attached environments with their resolved shell and starting
    environments with `still loading`.
    - Track the latest environment state recorded in model history and
    append a bounded update only when it changes.
    - Seed that baseline from full initial context so ready-at-start
    environments are not duplicated.
    - Clear the in-memory baseline when history is rewritten so replacement
    history can be refreshed safely.
    
    ## Testing
    
    - `just test -p codex-core deferred_executor`
    - `just test -p codex-core
    environment_context_baseline_deduplicates_until_history_is_replaced`
    
    The integration coverage verifies that a pending environment reaches the
    first request, the ready state reaches the next request, later requests
    do not duplicate it, and ready-at-start environments remain
    single-injected.
    
    <details>
    <summary>Live verification</summary>
    
    - Connected to a real remote executor with startup deliberately delayed
    and forced three sampling requests in one turn.
    - Inspected the raw model inputs: request 1 showed the remote
    environment as `still loading`, request 2 appended its ready shell and
    cwd, and request 3 contained no duplicate ready update.
    - With the feature disabled, startup waited for the delayed executor and
    the first request contained only the ready environment.
    - With a synchronously ready environment and the feature enabled, the
    first request contained one environment context with no duplicate.
    - Executed `pwd` and read a marker file through the remote process
    runner; the command exited successfully and returned the remote cwd and
    marker contents.
    
    </details>
  • Stop logging every Responses WebSocket event (#29432)
    ## Why
    
    Every successful Responses WebSocket event currently produces three
    local log records: the full payload at TRACE, an OpenTelemetry log
    event, and an OpenTelemetry trace event.
    
    On busy threads these records fill the 1,000-row log partition in
    seconds and cause continuous SQLite insert-and-prune churn.
    
    Related to
    https://openai.slack.com/archives/C095U48JNL9/p1782128972644209
    
    ## What changed
    
    - Stop logging each successful Responses WebSocket payload at TRACE.
    - Stop emitting `codex.websocket_event` as OpenTelemetry log and trace
    events.
    - Keep WebSocket event counters, duration metrics, response timing
    metrics, parsing, and error handling.
  • Add workspace messages app-server API (#29001)
    ## Summary
    
    - Add backend-client types and fetch support for active workspace
    messages.
    - Add the app-server v2 `account/workspaceMessages/read` method,
    generated schemas, and README documentation.
    - Delegate workspace-message eligibility to the Codex backend feature
    gate; map a backend 404 to `featureEnabled: false`.
    
    ## Testing
    
    - `just write-app-server-schema`
    - `just test -p codex-backend-client`
    - `just test -p codex-app-server-protocol`
    - `just test -p codex-app-server workspace_messages`
    - `just fix -p codex-backend-client -p codex-app-server-protocol -p
    codex-app-server`
    - `just fmt`
    
    ## Stack
    
    - Base PR for #28232, which adds the TUI status-line integration.
  • Apply sandbox intent inside remote exec servers (#29113)
    ## Why
    
    PR #29108 lets the orchestrator send sandbox intent with `process/start`
    without wrapping the command for its own operating system.
    
    This PR completes that boundary by making the executor interpret and
    enforce the intent using its own filesystem paths and sandbox
    implementation.
    
    For example, a macOS TUI targeting a Linux devbox sends `/bin/bash -lc
    pwd`. The Linux executor turns that into its own `codex-linux-sandbox
    ... /bin/bash -lc pwd` launch.
    
    ## What changes
    
    - Keep `process/start` unchanged when no sandbox intent is present.
    - Convert sandbox `PathUri` values into native paths on the executor.
    - Bind symbolic `:workspace_roots` permissions to the executor's native
    sandbox cwd.
    - Select the sandbox implementation on the executor and wrap the
    original command immediately before spawning it.
    - Reject sandbox-required execution before spawning when the executor
    cannot enforce the intent.
    - Pass exec-server runtime paths into process creation so Linux can
    locate `codex-linux-sandbox`.
    
    The boundary is therefore:
    
    ```text
    orchestrator                         executor
    original argv + sandbox intent  ->  select and enforce local sandbox
    ```
    
    This PR intentionally treats a denied remote command as an ordinary
    command failure. Draft follow-up #29424 carries a semantic
    `sandboxDenied` result back to unified exec for the existing approval
    and retry flow.
    
    ## Platform scope
    
    Linux and macOS use their existing direct-spawn sandbox transforms.
    
    Windows sandboxed remote process launch is intentionally unsupported in
    this PR. The current Windows direct-spawn wrapper does not correctly
    preserve arbitrary argv, TTY behavior, or pass the full child
    environment out of band. The executor rejects the request instead of
    running it incorrectly or unsandboxed.
    
    ## Known follow-ups
    
    - The transported permission profile can still contain
    orchestrator-materialized helper or explicit paths. A `TODO(jif)` marks
    where the executor boundary should receive pre-host-materialization
    permission intent.
    - The sandbox wrapper currently replaces a requested custom inner
    `arg0`. A `TODO(jif)` marks where this must be preserved or rejected
    explicitly.
    - Draft PR #29424 contains the deferred sandbox-denial classification
    and approval/retry behavior.
    
    ## Rollout assumption
    
    This executor-sandbox stack is unreleased and its client and executor
    are expected to move together. This PR does not add mixed-version
    negotiation with older exec servers.
  • Simplify multi-agent mode controls (#29324)
    ## Why
    
    Multi-agent delegation policy was split across `multiAgentMode`,
    `features.multi_agent_mode`, and `usage_hint_enabled`. These controls
    could disagree: a requested mode could be downgraded by the feature
    flag, and disabling usage hints also disabled mode instructions.
    
    Some clients also need multi-agent tools without adding
    delegation-policy text to model context. The previous two-mode API could
    not express that directly.
    
    ## What changed
    
    `multiAgentMode` is now the only live delegation-policy control:
    
    | Mode | Behavior |
    | --- | --- |
    | `none` | Keep multi-agent tools available without adding mode
    instructions. |
    | `explicitRequestOnly` | Only delegate after an explicit user request.
    |
    | `proactive` | Delegate when parallel work materially improves speed or
    quality. |
    
    - new threads default to `explicitRequestOnly`; omitting the mode on
    later turns keeps the current value
    - thread start, resume, fork, and settings responses always report the
    concrete current mode instead of `null`
    - mode selection remains sticky across turns and resume
    - usage-hint text no longer controls whether mode instructions apply
    - `features.multi_agent_mode` and `usage_hint_enabled` remain accepted
    as ignored compatibility settings so existing configs continue to load
    - app-server documentation and generated schemas describe the three-mode
    API
    
    ## Tests
    
    - `just test -p codex-core multi_agent_mode`
    - `just test -p codex-core multi_agent_v2_config_from_feature_table`
    - `just test -p codex-core spawn_agent_description`
    - `just test -p codex-features`
    - `just test -p codex-app-server-protocol`
    - `just test -p codex-app-server multi_agent_mode`
  • Persist session IDs across thread resume (#29327)
    ## Summary
    
    A cold-resumed subagent kept its durable thread ID but could receive a
    new session ID, splitting one agent tree across multiple sessions after
    a restart.
    
    Persist the root session ID in every rollout `SessionMeta`, carry it
    through thread creation, and restore it before initializing the resumed
    `Session` and `AgentControl`.
    
    ## Behavior
    
    For a nested agent tree:
    
    ```text
    root session R
      parent thread P
        child thread C
    ```
    
    The child rollout stores:
    
    ```text
    session_id:       R
    parent_thread_id: P
    id:               C
    ```
    
    After a cold resume, the child still belongs to root session `R` while
    its immediate parent remains `P`. The integration coverage uses distinct
    values for all three IDs so it catches restoring the session from
    `parent_thread_id`.
    
    ## Legacy rollouts
    
    Previous rollouts have `id` but no `session_id`. `SessionMetaLine`
    deserialization treats a missing `session_id` as `id`, keeping those
    files readable, listable, and resumable. When a legacy subagent is
    resumed through its root, that synthesized child ID no longer overrides
    the inherited root-scoped `AgentControl`. New rollouts always persist
    the explicit root session ID.
  • chore: fix merge race (auto-compaction feature access) (#29393)
    ## Summary
    
    - read the `AutoCompaction` feature flag through `TurnContext::config`
    - fix both the mid-turn and pre-sampling compaction checks
    
    ## Why
    
    #28260 was validated against an older base where `TurnContext` exposed a
    direct `features` field. It was then merged after that field had moved
    under `config`, leaving the merge result unable to compile with `E0609`
    on `turn_context.features`.
    
    This restores compilation for Bazel, SDK, and argument-comment-lint jobs
    that build `codex-core`. Behavior is unchanged: disabling
    `auto_compaction` still skips automatic compaction.
    
    ## Validation
    
    - `just fmt`
    - `CODEX_HOME=/private/tmp/codex-fix-auto-compaction-test-home just test
    -p codex-core auto_compaction_feature_disabled` — 4 passed
    - `just test -p codex-core` — `codex-core` compiled; 2,722 passed and 89
    unrelated local-environment failures remained because the sandbox could
    not write the default Codex SQLite/proxy paths and some first-party test
    binaries were unavailable
  • Propagate safety buffering events to app-server clients (#29371)
    Responses API safety buffering metadata currently stops at the transport
    boundary, so app-server clients cannot render the in-progress safety
    review state.
    
    This change:
    - decodes and deduplicates `safety_buffering` metadata from Responses
    API SSE and WebSocket events without suppressing the original response
    event
    - emits a typed core event containing the requested model plus backend
    use cases and reasons
    - forwards that event as `turn/safetyBuffering/updated` through
    app-server v2 and updates generated protocol schemas
    - keeps the side-channel event out of persisted rollouts and turn timing
    
    This supports the Codex Apps buffering UX and depends on the Responses
    API backend work in https://github.com/openai/openai/pull/1044569 and
    https://github.com/openai/openai/pull/1044571.
    
    Validation:
    - focused `codex-core` safety-buffering integration test passes
    - `cargo check -p codex-core -p codex-app-server -p
    codex-app-server-protocol`
    - `just fix -p codex-api -p codex-protocol -p codex-core -p
    codex-app-server-protocol -p codex-app-server -p codex-rollout -p
    codex-rollout-trace -p codex-otel`
    - `just fmt`
    - broad package test run: 4,430/4,492 passed; 62 unrelated
    local-environment/concurrency failures involved unavailable test
    binaries, MCP subprocess setup, and app-server timeouts
  • [codex] Add internal auto-compaction opt-out (#28260)
    ## Summary
    
    - add a default-on `auto_compaction` feature flag as an internal escape
    hatch
    - skip pre-turn, model-switch/hash, and mid-turn automatic compaction
    when the flag is disabled
    - preserve manual `/compact` behavior and surface the existing
    context-window error when the provider runs out of room
    - add integration coverage for disabled pre-turn and mid-turn compaction
    
    ## Motivation
    
    Long-running SPO optimization rollouts need the option to preserve their
    full context and fail on context exhaustion instead of entering another
    compaction window. This deliberately uses the existing feature-flag
    mechanism rather than adding a dedicated public config or app-server
    API.
    
    Disable it with:
    
    ```sh
    codex --disable auto_compaction
    ```
    
    ## Testing
    
    - `just test -p codex-features` — 51 passed
    - `just test -p codex-core auto_compaction_feature_disabled` — 2 passed
    - `just fix -p codex-core -p codex-features`
    - `just write-config-schema`
    - `just test -p codex-core` — the new compaction tests passed; the
    overall local run had 54 unrelated environment failures, primarily
    missing first-party test binaries and shell-snapshot timeouts
  • code-mode: preserve initial yield at completion (#29289)
    ## Summary
    
    - Retain the first pre-observation `yield_control()` boundary when a
    cell completes before observation.
    - Deliver the preserved yield before the buffered completion.
    - Keep later unattached yields as no-ops.
    
    ## Why
    
    Create followed by the initial wait must preserve the former execute
    response boundary even when the script runs to completion first.
    
    ## Impact
    
    The first wait observes the same initial yield boundary as before create
    and observe were decoupled.
    
    ## Validation
    
    - Focused initial-yield signature regression passed.
    - Stack-tip validation: `just test -p codex-code-mode -p
    codex-code-mode-protocol` (70 passed).
    - Parent branch:
    `cconger/code-mode-runtime-compact-03e2-observation-delivery`.
  • code-mode: preserve dropped observation output (#29288)
    ## Summary
    
    - Restore yielded output when an observation receiver disappears before
    delivery.
    - Preserve pending-frontier output and tool IDs across failed delivery.
    - Add dropped-observer coverage for yield and pending observations.
    
    ## Why
    
    Canceling a wait must not consume output or a pending frontier that the
    caller never received.
    
    ## Impact
    
    A later observation can recover undelivered incremental output without
    duplication.
    
    ## Validation
    
    - Stack-tip validation: `just test -p codex-code-mode -p
    codex-code-mode-protocol` (70 passed).
    - Parent branch:
    `cconger/code-mode-runtime-compact-03e-shutdown-hierarchy`.
  • [prompting] updated plan mode prompt (#29301)
    Update plan mode prompt to render the implementation plan to the user on
    relevant follow-ups, such that the user can exit out of plan mode to
    implement rather than manually switch of plan mode.
  • code-mode: make session shutdown authoritative (#29287)
    ## Summary
    
    - Give each session and cell a hierarchical cancellation token.
    - Track cell tasks so shutdown waits for admitted actors without polling
    the registry.
    - Make shutdown authoritative across concurrent admission and
    non-cooperative callbacks.
    
    ## Why
    
    A best-effort registry scan can miss cells admitted concurrently or
    blocked behind the registry lock.
    
    ## Impact
    
    Session shutdown reliably stops every admitted cell and rejects new work
    once shutdown begins.
    
    ## Validation
    
    - Stack-tip validation: `just test -p codex-code-mode -p
    codex-code-mode-protocol` (70 passed).
    - Parent branch: `cconger/code-mode-runtime-compact-03c-terminal-state`.
  • code-mode: linearize cell terminal state (#29286)
    ## Summary
    
    - Introduce a single cell terminal-state machine for completion and
    termination.
    - Make stored-value commits atomic with the winning terminal outcome.
    - Buffer terminal results for later observation and cover
    termination-before-commit behavior.
    
    ## Why
    
    Completion, termination, observation, and stored-value updates must
    agree on one linearized outcome under cancellation races.
    
    ## Impact
    
    Terminal delivery becomes deterministic and terminated cells cannot
    commit state after termination wins.
    
    ## Validation
    
    - Focused terminal-state regression passed.
    - Stack-tip validation: `just test -p codex-code-mode -p
    codex-code-mode-protocol` (70 passed).
    - Parent branch:
    `cconger/code-mode-runtime-compact-03b-session-runtime`.
  • code-mode: move session ownership into runtime (#29285)
    ## Summary
    
    - Move code-mode cell ownership and shared stored values from
    `CodeModeService` into `SessionRuntime`.
    - Keep the protocol-facing execute/wait behavior behind the existing
    service adapter.
    - Add runtime-level ownership and isolation coverage.
    
    ## Why
    
    This establishes a transport-neutral session boundary before later
    lifecycle and create/observe changes.
    
    ## Impact
    
    No intended model-facing behavior change. This is an ownership and
    layering refactor.
    
    ## Validation
    
    - Stack-tip validation: `just test -p codex-code-mode -p
    codex-code-mode-protocol` (70 passed).
    - Parent branch: `cconger/code-mode-runtime-compact-03a-runtime-types`.
  • code-mode: define transport-neutral runtime types (#29170)
    ## Summary
    
    - introduce a private `session_runtime` boundary for cell creation
    requests, observation modes, lifecycle events, output items, and tool
    metadata
    - update the cell actor and in-process service to use those
    transport-neutral types
    - keep cell ID allocation on the owning session side
    
    ## Motivation
    
    Cell lifecycle vocabulary currently lives inside the cell actor
    implementation. That makes the service adapter and future session
    runtime depend on actor-specific types, increasing the size and
    complexity of the runtime ownership change.
    
    This is the first reviewable slice of the session-runtime stack. It
    separates the transport-neutral data model without moving lifecycle
    ownership or changing behavior.
    
    Later slices will move session state behind this boundary, harden
    terminal and shutdown behavior, and split cell creation from
    observation.
    
    ## Behavior
    
    There are no public API or user-visible behavior changes in this PR.
    
    In particular:
    
    - `CodeModeSession::execute` and `wait` are unchanged
    - cell IDs remain allocated by the owning session
    - cell admission, observation, termination, and shutdown behavior are
    unchanged
  • Use controlled time for remote initialization timeout test (#29329)
    ## Summary
    
    The remote-control initialization timeout test used a 50 ms wall-clock
    deadline around a 10 ms transport timeout. A busy CI runner could miss
    that outer deadline even when the rollback behavior was correct.
    
    Pause Tokio time and advance it explicitly through the transport timeout
    instead. The test still verifies that initialization fails and emits the
    matching connection-closed event, without depending on scheduler speed.
  • Parallelize skill metadata stats (#29326)
    ## Summary
    
    This switches skill discovery to the simpler same-connection scalar
    request shape.
    
    After reading a skills directory, discovery now starts the existing
    `fs/getMetadata` calls for all visible entries in that directory before
    awaiting the results. There is no JSON-RPC batch frame and no new
    filesystem API; remote filesystems use the existing request-id
    multiplexing on the same exec-server connection.
    
    This is the scoped alternative to the batch-frame approach in #29074 /
    #29075.
    
    ## What changed
    
    - Collect visible directory entries before processing them.
    - Run their existing `fs.get_metadata(...)` calls with `join_all`.
    - Process the results in the original directory order, so skill
    discovery behavior stays the same.
    
    ## Benchmarks
    
    Fresh local benchmark against generated skill trees over a real
    exec-server remote filesystem. The benchmark calls the actual
    `load_skills_from_roots` path, so this includes directory reads,
    metadata stats, `SKILL.md` reads, and parsing.
    
    Times are p50 milliseconds from 5 samples after 1 warmup, using warmed
    runs.
    
    | Scenario | Legacy `main` | Batch frame stack (#29074 / #29075) |
    Same-connection scalar stack |
    | --- | ---: | ---: | ---: |
    | 100 flat skills | 377.4 | 389.0 | 378.6 |
    | 500 flat skills | 1983.2 | 1856.6 | 1757.5 |
    
    Takeaway: for the actual skill discovery path, same-connection scalar is
    tied with legacy at 100 skills and best at 500 skills. The batch-frame
    stack does not show enough win here to justify the extra protocol/API
    surface.
    
    Benchmark command:
    
    - `just test -p codex-exec-server benchmark_remote_skill_discovery
    --run-ignored ignored-only --no-capture`
    
    Checked locally with:
    
    - `just test -p codex-core-skills`
    - `just bazel-lock-update`
    - `just bazel-lock-check`
  • Test pipelined scalar exec-server requests (#29325)
    ## Summary
    
    This adds focused coverage for the simpler same-connection scalar
    request path.
    
    The exec-server connection already supports multiple in-flight JSON-RPC
    scalar requests on one connection. This test locks in that behavior by
    sending two normal requests before reading either response, without
    adding a batch frame or any new API surface.
    
    ## What changed
    
    - Added a processor-level test that initializes an exec-server
    connection.
    - Sends two scalar `environment/info` requests back-to-back on the same
    connection.
    - Verifies both responses come back on the same connection by request
    id.
    
    Checked locally with:
    
    - `just test -p codex-exec-server
    connection_accepts_pipelined_scalar_requests`
  • Carry sandbox intent to remote exec servers (#29108)
    ## What changed
    
    PR #29099 stopped sending the orchestrator's concrete sandbox wrapper to
    a remote exec-server. Remote commands now arrive as plain native argv.
    
    This PR adds the next piece: Codex also sends portable sandbox intent
    next to that plain argv.
    
    For a remote unified-exec command, the request can now include:
    
    - the canonical permission profile before local workspace-root
    materialization
    - the sandbox cwd and workspace roots as `PathUri` values
    - Windows sandbox settings
    - the legacy Landlock setting
    - whether managed networking must be enforced
    
    The important part is that symbolic entries such as `:workspace_roots`
    stay symbolic while crossing the boundary. The executor can then bind
    them to its own workspace-root paths instead of receiving
    orchestrator-local absolute paths.
    
    The data travels through `ExecRequest` into `ExecParams`. Older
    exec-servers can still deserialize requests because the new fields have
    defaults.
    
    ## Why
    
    The orchestrator should not decide how another machine implements
    sandboxing.
    
    For example:
    
    - a local macOS Codex would normally build a Seatbelt command
    - a remote Linux executor needs a Linux sandbox command instead
    
    The orchestrator now sends the plain command plus the policy it intended
    to enforce. A later PR can let the exec-server choose and build the
    correct sandbox for its own operating system.
    
    ## Important detail
    
    This keeps the portable intent separate from the local `SandboxType`.
    
    `SandboxType::None` is ambiguous:
    
    - it can mean the command was explicitly approved to run without a
    sandbox
    - it can also mean the orchestrator host has no concrete sandbox
    implementation available
    
    Those cases are different for remote execution. This PR adds
    `sandbox_requested` so an executor can still receive sandbox intent when
    the orchestrator cannot build a local wrapper. Explicit unsandboxed
    retries still send no sandbox context.
    
    ## Behavior today
    
    This PR only transports the intent. The exec-server accepts the new
    fields but does not apply them yet.
    
    Remote commands therefore remain unsandboxed after this PR, just as they
    are after PR #29099.
    
    ## Follow-up
    
    The next PR will make exec-server read this portable intent, bind
    symbolic workspace permissions to executor-native roots, choose the
    sandbox for its own operating system, build the wrapper locally, and
    then spawn the command.
  • [codex] simplify token budget context (#29295)
    ## Why
    
    The token-budget feature currently adds remaining-token messages
    whenever usage crosses the 25%, 50%, and 75% thresholds. Those periodic
    inserts create prompt churn without requiring action, while the
    near-compaction reminder and explicit `get_context_remaining` tool
    already cover actionable and on-demand budget information.
    
    The context-window lineage block is also easier to scan as plain labeled
    text than as a `<token_budget>`-wrapped fragment.
    
    ## What changed
    
    - Stop recording automatic remaining-token messages at percentage
    thresholds.
    - Render context-window lineage in `First`, `Current`, `Previous` order
    with colon-separated labels.
    - Omit the `Previous` line for the first context window.
    - Remove `<token_budget>` wrappers from newly rendered lineage,
    near-compaction reminders, and `get_context_remaining` output.
    - Keep recognizing legacy wrapped fragments so existing rollouts remain
    compatible.
    - Remove the post-sampling token snapshot that was only needed by the
    periodic threshold path.
    
    ## Testing
    
    - `just test -p codex-core token_budget` (11 tests passed)
  • [codex] add configurable token budget compaction reminder (#29255)
    ## Why
    
    The token-budget feature reports coarse remaining-context milestones,
    but it does not give the model a configurable wrap-up prompt before
    automatic compaction. A strict threshold-crossing check can also miss
    resumed or reconfigured windows that are already inside the threshold.
    
    ## What changed
    
    - Add structured `[features.token_budget]` configuration for an absolute
    `reminder_threshold_tokens` and bounded `reminder_message_template`;
    `{n_remaining}` is expanded when the reminder is delivered.
    - Compute remaining tokens against the next effective auto-compaction
    boundary, including scoped `body_after_prefix` accounting and the full
    context-window limit.
    - Make reminder delivery level-triggered before and after sampling, with
    one-shot state owned by `AutoCompactWindow` and re-armed on compaction,
    `new_context`, restore, or history replacement.
    - Leave the existing initial full-window token-budget context, 25/50/75%
    notices, and token-budget tools unchanged.
    - Persist the resolved feature configuration in the session config lock
    and regenerate the config schema.
    
    ## Validation
    
    - `just test -p codex-core token_budget`
    - `just test -p codex-core
    token_budget_reminder_emits_after_crossing_compaction_threshold`
    - `just test -p codex-core auto_compact_window`
    - `just test -p codex-core
    lock_contains_prompts_and_materializes_features`
    - `just test -p codex-features`
    - `just test -p codex-config`
  • [codex] prototype mcp_history thread hint injection (#29259)
    ## Why
    
    Prototype whether the harness can invoke the `mcp_history` MCP while
    constructing full initial context and expose its thread hint to the
    model without requiring a model-issued tool call.
    
    The prototype builds on the context-window lineage added by #29256 and
    is now based directly on `main`.
    
    ## What changed
    
    - Call `mcp_history/thread_hint` with no arguments while building the
    full `<token_budget>` context.
    - Pass the current `threadId` through MCP request metadata, matching the
    normal MCP tool-call path.
    - Serialize only the unstructured `content` result and append it inside
    `<token_budget>` when the call succeeds.
    - Omit the additional context when the MCP call or content serialization
    fails.
    
    ## Prototype limitations
    
    - The direct call bypasses the normal model-initiated MCP approval,
    lifecycle-event, telemetry, and result-sanitization path.
    - The call has no prototype-specific timeout, result-size cap, or
    per-window cache.
    - MCP latency is added to full-context construction, including
    applicable compaction paths.
    
    ## Validation
    
    - `just test -p codex-core token_budget`
  • core: add context window lineage IDs (#29256)
    ## Why
    
    The rendered `<token_budget>` fragment identifies the thread and current
    context window, but it does not expose enough lineage to identify the
    first window in the thread or the immediately preceding window. Those
    IDs also need to remain stable across compaction, resume, and rollback.
    
    ## What changed
    
    - Track first, previous, and current UUIDv7 context-window IDs in
    auto-compaction state.
    - Render `thread_id`, `first_window_id`, `previous_window_id`, and the
    current window ID in the full `<token_budget>` fragment.
    - Persist the first and previous window IDs in compacted rollout
    checkpoints and restore them during rollout reconstruction.
    - Preserve compatibility with older compacted records that do not
    contain the new optional fields.
    - Update focused state, rendering, reconstruction, rollback, and
    serialization coverage.
    
    ## Validation
    
    - `just test -p codex-core token_budget`
    - `just test -p codex-protocol compacted_item::tests`
    - `just test -p codex-core tracks_prefill_and_window_boundaries`
    - `just test -p codex-core
    reconstruct_history_uses_replacement_history_verbatim`
    - `just test -p codex-core
    thread_rollback_restores_cleared_reference_context_item_after_compaction`
  • Allow resume and settings commands during tasks and MCP startup (#29154)
    ## Why
    
    The TUI treats both an active turn and MCP startup as a running task.
    That currently blocks `/resume` and several settings commands even
    though they do not compete with turn execution, which is especially
    frustrating when MCP startup is slow.
    
    Model, permissions, personality, and service-tier selections already
    update thread settings independently of the running turn. Other clients
    can send those updates mid-turn, while the current turn continues with
    its captured settings. Allowing the same updates from local slash
    commands makes the TUI consistent with that existing behavior.
    
    ## What changed
    
    - Allow `/resume` while a task is running.
    - Allow `/model`, `/permissions`, `/personality`, and service-tier
    commands such as `/fast` while a task is running.
    - Keep the existing behavior where the active turn uses its captured
    settings and updates apply to subsequent turns.
    - Exercise the commands under the busy state in the existing TUI tests
    and retain coverage for commands that should remain blocked.
    
    ## Behavior note
    
    Turn settings such as model selection and reasoning effort are captured
    when a turn starts. Changing them during an active turn affects the next
    turn, not the turn already in progress. The status bar updates
    immediately, so it may temporarily display the newly selected setting
    before that setting is actually in effect.
    
    ## Verification
    
    - Focused `codex-tui` tests for resume dispatch, settings popups,
    `/fast`, and disabled-command behavior.
    
    ## Related issues
    
    Closes #19015.
    
    Addresses the next-turn-safe model/reasoning switching portion of
    #14356; dedicated shortcuts and the proposed depth meter remain out of
    scope.
  • [codex] Preserve skill descriptions outside model context (#29006)
    ## Why
    
    Skill descriptions are used in model-visible lists: the default
    available-skills catalog that supports implicit selection, and the
    on-demand `skills.list` tool response used to discover orchestrator
    skills. A single overlong description should not consume a
    disproportionate share of either list.
    
    Enforcing the 1024-character limit while loading or migrating skills is
    the wrong boundary: it rejects otherwise-valid skills and discards
    metadata that non-model consumers and full skill reads may need. Skill
    metadata and `SKILL.md` content should remain intact; the cap belongs at
    model-visible list rendering boundaries.
    
    ## What changed
    
    - Preserve full `description` and `metadata.short-description` values
    when loading skills.
    - Preserve full external-agent command descriptions during
    `source-command-*` migration instead of skipping commands solely because
    their descriptions exceed 1024 characters.
    - Preserve full normalized orchestrator descriptions in the underlying
    skills catalog.
    - Cap each description at 1024 Unicode characters when rendering the
    default available-skills context in `codex-core-skills` and
    `codex-skills-extension`.
    - Apply the same cap when serializing descriptions in the model-visible
    `skills.list` response.
    - Render truncated descriptions as 1021 original characters plus `...`.
    - Leave explicit `$skill` injection, `skills.read`, underlying metadata,
    and on-disk `SKILL.md` files unchanged and full-fidelity.
    
    ## Implicit skill selection
    
    Codex injects a bounded catalog containing each implicitly allowed
    skill's name, description, and source locator, together with
    instructions to use a skill when the task clearly matches its
    description. The model makes that semantic choice; after selecting a
    skill, it reads the full `SKILL.md` from its filesystem or provider
    resource. Explicit `$skill` mentions remain a separate path that injects
    the full skill instructions. For orchestrator skills, `skills.list`
    provides bounded discovery metadata before `skills.read` returns the
    full selected resource.
    
    ## Test plan
    
    - `just test -p codex-core-skills`
    - `just test -p codex-skills-extension`
    - `just test -p codex-external-agent-migration`
    
    The focused regressions verify that overlong metadata is preserved at
    load and migration boundaries while default available-skills rendering
    and `skills.list` output produce the 1021-character prefix plus `...`.
  • chore(deps): advance tokio-tungstenite (#29132)
    ## Why
    
    Responses websocket connections use `tokio-tungstenite`. When DNS
    returns an unusable native IPv6 address before a working IPv4 address,
    sequential dialing can consume Codex's outer websocket timeout before
    reaching IPv4. The merged fork change adds Happy Eyeballs-style
    alternate-family racing so websocket dialing matches the recovery
    behavior already present in the HTTP path.
    
    ## What Changed
    
    Advance the workspace `tokio-tungstenite` patch from `132f5b39` to
    merged commit `e5e64b86`, and update the matching lockfile source. The
    new revision comes from
    [openai-oss-forks/tokio-tungstenite#1](https://github.com/openai-oss-forks/tokio-tungstenite/pull/1).
  • Use cached and live web access terminology (#29095)
    ## Summary
    
    - Rename the string-valued external web access enum variants from
    `Offline` / `Online` to `Cached` / `Live`.
    - Align the transport names with the existing `web_search = "cached"` /
    `"live"` configuration vocabulary.
    
    Existing behavior is unchanged: `WebSearchMode::Cached` and
    `WebSearchMode::Live` continue to send the backward-compatible boolean
    values `false` and `true`; `Indexed` remains the only mode currently
    sent as a string.
    
    ## Validation
    
    - `just fmt`
    - `just test -p codex-api` (127 passed)
  • Keep remote exec commands native to the executor (#29099)
    ## Summary
    
    - Remote unified-exec now sends the original command argv to exec-server
    instead of materializing the orchestrator's sandbox wrapper first.
    - Local unified-exec keeps the existing sandbox path unchanged.
    - Add a focused regression test for a macOS-selected sandbox producing
    plain remote argv.
    
    Before:
    
        macOS orchestrator -> /usr/bin/sandbox-exec ... -> Linux exec-server
    
    After:
    
        macOS orchestrator -> /bin/bash -lc pwd -> Linux exec-server
    
    This is intentionally only the first cleanup step. Remote unified-exec
    commands are sent without a process sandbox until the targeted
    follow-ups below land. For the macOS-to-Linux path this is not a
    practical regression: the old sandboxed attempt failed before process
    launch because the Linux executor could not spawn macOS sandbox paths.
    
    ## Targeted follow-ups
    
    1. Carry sandbox intent separately from argv.
       - Add an optional sandbox field to exec-server process params.
    - Reuse FileSystemSandboxContext rather than introducing a new sandbox
    model.
       - Carry managed-network enforcement as one explicit bit.
       - Keep argv plain.
    
    2. Apply that intent inside exec-server.
       - Add a small process-start adapter before LocalProcess::exec.
    - Reuse the existing codex-sandboxing SandboxManager and exec-server
    runtime paths.
    - Follow the same shape already used by exec-server filesystem
    sandboxing.
       - Do not duplicate or move the sandbox implementations.
    
    3. Report the sandbox actually used.
       - Return the executor-selected sandbox type from process/start.
    - Use that value in core for sandbox-denial detection and retry
    behavior.
    
    ## End state
    
    The orchestrator sends plain commands plus portable sandbox intent. The
    executor chooses and applies its own native sandbox: Linux executors use
    Linux sandboxing, macOS executors use Seatbelt, and Windows executors
    use Windows sandboxing. Concrete wrapper argv, helper paths, and sandbox
    env markers never cross the executor boundary.
  • Add config toggles for orchestrator skills and MCP (#28942)
    ## Why
    
    Orchestrator-provided skills and Codex Apps MCP tools add model-visible
    instructions, resources, and tools beyond the local workspace. Hosts
    need config-level switches to disable those orchestrator-owned surfaces
    independently, without disabling regular skills or regular MCP servers.
    
    ## What changed
    
    - Adds `[orchestrator.skills].enabled` and `[orchestrator.mcp].enabled`
    config entries, both defaulting to `true`.
    - Includes the new settings in `config.schema.json` and in the config
    lock so resolved thread configuration preserves the same orchestrator
    exposure decisions.
    - Threads `orchestrator.skills.enabled` through the app-server skills
    extension so disabled orchestrator skills do not expose the `skills`
    namespace or inject orchestrator skill context.
    - Gates Codex Apps MCP exposure, app instructions, and app auth
    eligibility on `orchestrator.mcp.enabled` while leaving non-Codex-Apps
    MCP tools available.
    - Updates the thread-manager sample config to disable both
    orchestrator-owned surfaces.
    
    ## Verification
    
    - Added config parsing, loading, defaulting, and schema coverage for the
    new settings.
    - Added MCP exposure coverage that `orchestrator.mcp.enabled = false`
    removes Codex Apps tools while preserving regular MCP tools.
    - Added app-server coverage that `orchestrator.skills.enabled = false`
    prevents orchestrator skill tools, prompts, and resource reads from
    reaching the model turn.
  • Add indexed web search mode (#28489)
    ## Summary
    
    - Add `web_search = "indexed"` alongside `disabled`, `cached`, and
    `live`.
    - Use that same resolved mode for both hosted and standalone web search.
    - For hosted search, send `index_gated_web_access: true` with external
    web access enabled only when `indexed` is selected.
    - For standalone search, preserve the existing boolean wire values for
    existing modes (`cached` maps to `false` and `live` to `true`) and send
    `"indexed"` only for `indexed`; `disabled` keeps the tool unavailable.
    - Carry the mode through managed configuration requirements and
    generated schemas.
    
    ## Why
    
    Indexed search provides a middle ground between cached-only search and
    unrestricted live page fetching. Search queries can remain live while
    direct page fetches are limited to URLs admitted by the server.
    
    The existing `web_search` setting remains the single source of truth, so
    hosted and standalone executors cannot drift into different access
    modes. Without an explicit `indexed` selection, the existing
    model-visible tool and request shapes are unchanged.
    
    ```toml
    web_search = "indexed"
    
    [features]
    standalone_web_search = true
    ```
    
    ## Validation
    
    - `just fmt`
    - `just test -p codex-api` (`126 passed`)
    - `just test -p codex-web-search-extension` (`7 passed`)
    - `just test -p codex-core
    code_mode_can_call_indexed_standalone_web_search` (`1 passed`)
    - Focused configuration, hosted request, standalone request, and
    managed-requirement coverage is included in the PR; remaining suites run
    in CI.
    
    The full workspace test suite was not run locally.
  • Document raw response item compatibility (#29086)
    Adds a short AGENTS.md note asking reviewers to treat raw response item
    events as compatibility-sensitive, even while they are experimental.
    
    This keeps future app-server changes from accidentally breaking Codex
    Cloud consumers of raw response item events.
  • Scope network approvals by environment (#28899)
    Stacked on #28766.
    
    ## Why
    
    Network approvals are environment-scoped: allowing a host in one
    execution environment should not allow the same host in another
    environment.
    
    #28766 adds the inert IDs and constructor plumbing. This PR applies the
    behavior on top.
    
    ## What changed
    
    - Route managed network traffic through per-environment HTTP and SOCKS
    proxy listeners.
    - Stamp HTTP, HTTPS CONNECT, SOCKS TCP, and SOCKS UDP policy requests
    with the source environment at the proxy boundary.
    - Carry the selected execution environment through shell, unified exec,
    zsh-fork, and sandbox transform paths.
    - Include the environment in pending, approved-for-session, and
    denied-for-session network approval cache keys.
    - Include the environment in approval IDs and approval prompts.
    - Preserve legacy fallback for unattributed requests, but deny when
    active-call attribution is ambiguous.
    - Fail closed if an environment-specific proxy endpoint cannot be
    prepared.
    
    ## Validation
    
    - just fmt
    - CI will run tests and clippy
  • [codex] abort turns when rollout budgets expire (token budget 3/3) (#28707)
    ## Stack
    
    Depends on #28494.
    
    ## Description
    
    This PR propagates shared rollout-budget exhaustion through the existing
    `CodexErr::TurnAborted` task result.
    
    Each thread records its model usage against the same ledger. Once the
    ledger is exhausted, that usage update and all later usage updates
    return `TurnAborted`. The task wrapper emits the normal aborted-turn
    event and lifecycle instead of completing the turn.
    
    This is intentionally a soft boundary: there is no cross-thread
    `Op::Interrupt` fanout. An in-flight thread can finish its current
    response before it observes the exhausted ledger, but every thread
    aborts at its next usage-accounting boundary.
    
    ## Tests
    
    The integration coverage verifies that:
    
    - the response that exhausts the budget aborts its turn;
    - a later response also aborts because the shared ledger remains
    exhausted; and
    - sub-agent usage draws from the same shared ledger; and
    - local and remote-v2 compaction abort without retrying or emitting a
    generic error.
    
    Local checks:
    
    - `just test -p codex-core
    exhausted_budget_aborts_current_and_later_turns`
    - `just test -p codex-core subagent_usage_draws_from_the_shared_budget`
    - `just test -p codex-core
    abort_regular_task_emits_marker_before_turn_aborted`
    - `just test -p codex-core
    compaction_budget_exhaustion_aborts_without_error_or_retry`
    - `just fix -p codex-core`
    - `just fmt`
    - `git diff --check`
    
    The full workspace test suite was not run locally.