Commit Graph
6806 Commits
Author SHA1 Message Date
jif 258cae0778 Default eligible OpenAI sessions to automatic approval review (#65236)
## What changed

When `approvals_reviewer` is unset, default to `auto_review` for sessions using the OpenAI model provider with `guardian_approval` enabled, effective workspace-write permissions, and an effective approval policy of `on-request` or `granular`. Otherwise default to `user`. Explicit reviewer settings still take precedence over the default, subject to configuration requirements.

When the TUI starts a replacement session on a remote app server, use the server's configured reviewer if the client has no explicit reviewer setting. Update the configuration and app-server schemas to document the new default.

## Testing

Cover reviewer eligibility and managed requirements in configuration tests, manual overrides and empty workspace roots in app-server thread-start tests, and remote reviewer precedence in the TUI replacement-session test.

GitOrigin-RevId: fd05687accddb8a3ab99df0486b93f3f595fef65
2026-12-02 11:38:20 +00:00
jif 6b36f44a93 Describe exec-only tools in mixed Code Mode (#65223)
## Why

Mixed Code Mode can call MCP tools excluded from both direct and deferred
exposure, but the `exec` description omitted their signatures and server
instructions.

## What changed

Include exec-only tool declarations, shared MCP types, and namespace
instructions in the mixed-mode `exec` description. Cap this material at
64,000 bytes and point to `ALL_TOOLS` for declarations that do not fit.
Tools exposed directly continue to carry their own declarations.

## Testing

Extend integration coverage to verify that both Code Mode variants can
call MCP tools excluded from direct and deferred exposure. The mixed-mode
case checks that an oversized namespace is omitted from the description,
its tools remain callable through `ALL_TOOLS`, and a smaller namespace
still shows signatures and server instructions.

GitOrigin-RevId: 6ad4e68d85f6b2dfdafb8ccd55755d80651c0b6c
2026-12-02 10:51:12 +00:00
Adam Perry @ OpenAI 065513215b Support model-facing IDs in environment context (#65218)
## Why

When an environment detaches after a session resumes, the context update
needs to mark it unavailable under the same ID the model saw earlier.

## What changed

Render environment entries with session-scoped aliases such as `env731`
when a mapping is supplied. Save the aliases and naming mode in snapshots
so removal updates can use the recorded names and the naming mode survives
when the last environment detaches. Keep registered IDs as snapshot keys
for compatibility with existing rollouts. The session still renders
registered names.

## Testing

Add regression tests for removing the last aliased environment after resume
and refreshing the context when a saved snapshot has inconsistent IDs.

GitOrigin-RevId: 730fe3d366a9e0bc3e5eb9c6139051901c4f5f96
2026-12-02 10:20:41 +00:00
Charlie Weems 1805912776 Add a configurable maximum width for TUI conversations (#65216)
## Why

On wide terminals, the transcript and prompt box can span more columns than
users want for comfortable reading and editing.

## What changed

Set `tui.max_conversation_width` in `config.toml` to cap the transcript and
prompt box in fullscreen and inline modes, including the startup composer.

```toml
[tui]
max_conversation_width = 80
```

The setting accepts values from 20 to 65,535 terminal columns. When unset,
the conversation uses the available width. Raw inline scrollback keeps native
terminal wrapping, and wrapped links in formatted history and command previews
retain their full destinations.

## Testing

Add regression coverage for config validation, startup and live layouts,
inline history reflow after a config reload, and links that wrap across rows.

GitOrigin-RevId: 91e1856776986fee3b540247c3fbfe5f083b297f
2026-12-02 10:19:11 +00:00
alexsong-oai 986dc881be Expose gateway spend in app-server account rate limits (#65193)
## Why

Clients need to show the spend and cap for the account behind a thread's
model provider. The existing ChatGPT usage read cannot provide those
figures for a gateway account.

## What changed

- Route `account/rateLimits/read` through the provider's configured
  `usage_url` using the provider's credentials. An optional `threadId`
  selects a loaded thread's provider for the account-wide read. Omitting it
  selects the default provider.
- Return `usageUnavailable` for a thread whose provider has neither a
  usage endpoint nor first-party authentication. Surface gateway errors
  without falling back to ChatGPT usage.
- Report monthly gateway spend in `individualLimit` as exact USD decimal
  strings, with `limit: "unlimited"` for uncapped accounts. Use
  `spendControlReached` for the gateway's cap status. Spend snapshots
  identify their unit as `usd` or `credit`, with omitted units defaulting
  to `credit` for compatibility.

## Testing

Add integration coverage for thread-specific provider selection, gateway
usage taking precedence over ChatGPT without fallback, and reuse of an
existing gateway OAuth session without interactive login.

GitOrigin-RevId: e6ec9d83eecc3084fcc98e72e2c031bd3e53a2cd
2026-12-02 07:59:18 +00:00
Abhinav d8ccc0f051 Enable Responses Lite for Amazon Bedrock Runtime profiles (#65185)
## What changed

Set `use_responses_lite` for all `global.` and `us.` model profiles in the Bedrock Runtime catalog.

## Testing

Update the catalog test to require Responses Lite for every Runtime profile. Update the request test to check that the selected model ID is preserved, the Responses Lite header is sent, and `additional_tools` declares `functions.exec` while omitting `web_search`.

GitOrigin-RevId: 7bd3d793f6365d4bffdf51528eeb3dac0d441aba
2026-12-02 06:56:44 +00:00
Abhinav 1759ac249a Inherit bundled tool capabilities on Amazon Bedrock (#65184)
## Why

The Bedrock catalog cleared the bundled tool mode, so models configured
for Code Mode did not get that default on Bedrock. Runtime inference
profiles also discarded the base model's tool search capability.

## What changed

- Inherit the bundled tool mode on standard Bedrock endpoints. Leave
  the mode unset for GPT-5.5 and GovCloud Mantle so Code Mode settings
  determine tool exposure there.
- Inherit model-level tool search support in global and US cross-region
  Runtime inference profiles.
- Keep full Responses requests so Mantle can expose cached web search
  alongside Code Mode.

## Testing

Add coverage for Runtime profile capability inheritance and GovCloud
Mantle defaults. Verify that GPT-5.6 Sol on Mantle sends both
`functions.exec` and the text-only cached web search tool.

GitOrigin-RevId: dca35b5ca08321b5a906b442dbcbdec648ffdcea
2026-12-02 06:56:08 +00:00
tejsudha-openai f20d485ea2 Send the installation ID header on authenticated Responses requests (#65183)
## What changed

Add `x-codex-installation-id` to Responses API HTTP requests and WebSocket
handshakes when an authorization header is attached and the destination is
a trusted OpenAI endpoint. Use the persisted installation ID already sent in
`client_metadata` and mark the header value as sensitive.

## Testing

Cover header delivery over WebSocket and HTTP, retention across a trusted
redirect, and omission for unauthenticated requests and third-party endpoints.

GitOrigin-RevId: 3fa83816cc91584944d6023680ba0dd05fbca138
2026-12-02 06:54:40 +00:00
alexsong-oai badc482b81 Add monthly spend reads for custom model providers (#65168)
## What changed

Add an optional `usage_url` to model provider configuration and carry it
through remote thread configuration. Expose `read_provider_usage` to
fetch the current user's monthly USD spend, optional cap and percentage
used, and reset time.

Use the provider's own credentials for the request. Reject redirects,
disable interactive gateway login, and enforce same-origin validation
for gateway OAuth configurations that require it.

## Testing

Cover capped and uncapped spend, percentage rounding, and malformed
responses. Verify usage URL validation and remote configuration
round-tripping.

GitOrigin-RevId: ed805a756aab6e55c24751f0285bfe73b9091f07
2026-12-02 04:59:30 +00:00
ningyi-oai abb3701f4c Refresh workspace Git status before sending WebSocket turn frames (#65158)
## Why

A background Git scan can finish during WebSocket connection setup.
The generation frame previously used the earlier metadata snapshot,
so it could omit Git status that was already available when it was sent.

## What changed

Pick up same-turn Git results before building the generation frame,
without waiting for the scan. Handshake headers and prewarm frames use
the initial snapshot. Keep the earlier workspace snapshot if the refresh
would exceed the metadata size limit where the earlier one fit, or
displace a Git remote URL that would otherwise fit.

## Testing

Add regression coverage for Git status arriving during the handshake,
which request kinds can refresh, and remote URL retention at the
metadata size boundary.

GitOrigin-RevId: 942eeb8d5ee16756803ce3a5021d186a47fb9f0c
2026-12-02 03:47:42 +00:00
Charlie Marsh 028590df7d Preserve deferred tool declarations in prediction forks (#65146)
## Why

A prediction fork that disables MCP inherits the parent's tool declarations,
but recomputing the deferred tool list can append a conflicting declaration
to the request.

## What changed

Skip the deferred tool list update when the fork preserves the parent's tool
declarations. The fork still reports MCP tool unavailability separately.

## Testing

Extend `prediction_fork_keeps_inherited_tools` to cover both inline and
deferred MCP tools and assert that the fork carries exactly the parent's
`<tools>` messages.

GitOrigin-RevId: 04b4a542e0d587a20706935e8b028b7f1fdb9209
2026-12-02 02:40:50 +00:00
Adam Perry @ OpenAI e1e967cd46 Add session-scoped aliases for registered environment IDs (#65140)
## What changed

Pair each registered executor ID with a model-facing alias assigned on
first use by the session's model ID store. Turn environment snapshots
can resolve these pairs in selection order, including for executors
that are still starting or have failed. Environment context snapshots
and rendering continue to use registered IDs.

## Testing

Cover alias assignment in selection order, stability across readiness
updates, and reuse of the same ID pair after reopening the SQLite store.

GitOrigin-RevId: e5fa6e5549ebb12fcf651e5bf7413402fb4db1b3
2026-12-02 01:59:55 +00:00
Dylan Hurd b1387dd6cc Preserve active input context order during compaction (#65128)
## Why

Restoring active context after compaction selects retained messages can
move it across user turns. For example, instructions for a context-only
heartbeat can end up before an earlier, already answered user question.

## What changed

Retain active context in source order when building compacted history
and resetting the context window. Use the full items from live history
so active tool outputs and messages survive prompt shortening.

## Testing

Add regression coverage for a heartbeat that compacts mid-turn, and
verify ordering around repeated user message IDs and pending agent
messages in local and remote compaction.

GitOrigin-RevId: b670f3c4e87331a61986b4c163f892e43bd0261d
2026-12-02 01:08:37 +00:00
aakash-oai 6adca62116 Measure model catalog lookups and HTTP GET attempts (#65123)
## Why

A model catalog lookup can use a cached snapshot or bundled fallback without sending a request. A lookup that reaches the endpoint can send multiple requests through retries. Measuring both lets readers of the metrics distinguish cache behavior from endpoint traffic.

## What changed

- Record one `codex.remote_models.lookup.outcome` observation per completed catalog lookup with its purpose, result, and the source of the snapshot actually selected. Record observations without taking the exporter lock on the lookup path.
- Count dispatched requests in `codex.remote_models.http_get_attempt`, including retries. Tag them by purpose and whether they match the configured endpoint when that context is available. Keep endpoint URLs out of metric labels.
- Mark background refreshes as maintenance and apply metrics enablement changes to cached global handles when the process reloads telemetry settings.

## Testing

Add coverage for cache and fallback attribution, retry counts, auth failures before dispatch, and metrics collection across exporter disablement and replacement.

GitOrigin-RevId: b970207a69432030b4511c7e84acb6696b6f824b
2026-12-02 00:44:37 +00:00
Won Park cd9a09e7f6 Record why MCP runtimes refresh (#65120)
## Why

Several invalidations can be handled by a single MCP runtime refresh. Recording the reasons together shows which changes prompted that refresh.

## What changed

When `mcp_refresh_reason_telemetry` is enabled, successful MCP runtime refreshes report a `codex_mcp_runtime_refresh_event` with distinct reason labels, a timestamp, and thread and session attribution. The flag is off by default.

Multiple installed-plugin metadata changes collapse to one `installed_plugin_metadata` label. The event omits configuration contents and plugin change IDs. Analytics buffers refresh events that arrive before their thread context is available.

## Testing

Add an integration test that queues multiple invalidations and verifies that one event with deduplicated reasons and the correct thread and session IDs is sent after thread start is recorded.

GitOrigin-RevId: 639326d0cb993b8b3a0fcbf0618049cb2ff065fd
2026-12-02 00:41:52 +00:00
Will Emmanuel 7131f15461 Include the host subagent roster in initial environment context (#65118)
## Why

When a turn has no execution environments or other environment context
to report, Codex can skip the environment update before reading the host
roster. The model then misses any active subagents in that roster.

## What changed

Keep the initial environment update until Codex has had a chance to
attach the host roster. Emit `<environment_context>` when the roster is
its only content, and drop the update if it is still empty.

## Testing

Add integration coverage for roster-only context and empty context in
both the default and per-environment formats.

GitOrigin-RevId: 6ceffd9aa13fefa31387c4d598a81a4281554c1c
2026-12-02 00:28:07 +00:00
Owen Lin a1deffb5b2 Pass the last inherited turn ID when creating a fork (#65111)
## Why

A thread store that resolves the last inherited turn during fork preparation
can reuse that ID when creating the child instead of resolving it again.

## What changed

Forward the optional `last_inherited_turn_id` from `PreparedFork` to
`CreateThreadParams` alongside the inherited history position. Omit the
field from serialized creation parameters when no ID is available.

## Testing

Add a regression test that checks the in-memory thread store receives the
turn ID supplied by the prepared fork when it creates the child.

GitOrigin-RevId: 709c8cc4a744b2f893af6233e825026a27732873
2026-12-01 23:56:56 +00:00
iceweasel-oai 80d0a67185 Share runtime registration across app-server startup clients (#65106)
## Why

Statsig starts before the model catalog. When runtime agent instances are
enabled, separate auth managers can cause Statsig and model discovery to
register the same app-server runtime twice.

## What changed

Pass a shared runtime auth slot to Statsig and model discovery in both
standalone and in-process app-server startup so they use the same runtime
registration.

## Testing

Extend the CLI startup integration test to require exactly one runtime
registration and verify that both Statsig evaluations and model discovery
send `AgentAssertion` authorization headers.

GitOrigin-RevId: 132521b685c5c7c617e7067c648de65b9a4287b2
2026-12-01 23:12:29 +00:00
Tom 47e1cf4fe4 Link startup prewarm to the first turn's OpenTelemetry trace (#65105)
## Why

Startup prewarm runs in the session startup trace, while the first turn
can run in a separate trace. The first-turn trace needs a way to show
which prewarm task it resolved, including when the wait times out.

## What changed

Record `startup_prewarm.resolve` at info level under the first-turn span.
Capture the startup prewarm span context when scheduling the task and
attach it as an OpenTelemetry span link during resolution. If the prewarm
span is filtered out, omit the link.

## Testing

Check exported spans for first-turn parentage, link behavior with the
prewarm span enabled or filtered out, and no second resolution on a
later turn. Add a regression test for retaining the link on timeout.

GitOrigin-RevId: ef4a19be64ecf145b17527081960e50adca3b92e
2026-12-01 23:11:46 +00:00
Ben Romano 1aeab9e3d5 Overlap remote MCP config reads with capability discovery (#65101)
## Why

MCP runtime refreshes waited for capability discovery and host MCP
configuration to finish before requesting HTTP MCP servers from the selected
remote environment. That serialized two reads that can be in flight together.

## What changed

Start the remote environment config read alongside host MCP configuration,
including executor capability discovery. Start the read's 10-second timeout
after host configuration is ready so a serial executor can queue the read
behind discovery without consuming its timeout. Merge the results with host
server precedence and requirements still enforced.

## Testing

Add V1 and V2 integration cases that hold both executor replies until both
requests arrive, then verify host precedence and requirements. Add a
paused-clock test that covers a queued read and confirms a stalled read
times out 10 seconds after discovery completes.

GitOrigin-RevId: d974f0f575559bfe6b756de11aa460399fdabf25
2026-12-01 22:57:35 +00:00
Aismit 624fdeecee Run patch hooks for intercepted apply_patch commands (#65077)
## Why

Codex can intercept an `apply_patch` heredoc passed to `exec_command`
and apply the patch directly. That path ran shell hooks but bypassed
`apply_patch` hooks, so patch-specific rules could miss the same edit
when it was submitted through the shell tool.

## What changed

- Run `apply_patch` `PreToolUse` after shell hooks and before file
  verification. Hooks can block or rewrite the patch, and the final
  patch is checked against the selected environment's permissions.
- Report the executed patch through `apply_patch` `PostToolUse`. Link
  the patch hook events to the outer shell call with
  `parent_tool_use_id` and provide working-directory and filesystem
  metadata for hooks that inspect patch targets.
- Apply the same block and rewrite rules in recorded Guardian reviews.
  Mark those hook requests with `review_only` and review the resulting
  patch without executing it or publishing hook-provided context.

## Testing

Add coverage for hook blocks and rewrites, effective working directories,
environment permissions, and cancellation before and after a patch write.
Cover recorded reviews of rewritten patches and reviews stopped by a hook.

GitOrigin-RevId: 2115f26261a20d4a512669bc9e277a764b8f42f4
2026-12-01 20:18:13 +00:00
jif b9cbe0d977 Require V3 workers to report results with send_message (#65076)
## Why

A V3 worker can resume its conversation after stopping. Reporting results
explicitly lets the worker decide when to send a result to its parent,
independently of when a turn ends.

## What changed

Stop forwarding V3 workers' final answers as automatic success results.
Continue forwarding failures and preserve automatic results for V2. Update
V3 prompts and tool descriptions to tell workers to send their result and
call `stop_agent` to release their slot.

Keep `send_message` available in the V3 native tool set even when
`disable_direct_message` is set. When native tools are enabled, require both
`send_message` and `stop_agent` to survive tool policy filtering for V3
workers, including on resume.

Track accepted worker-to-parent reports until they are written to the
parent's rollout. Preserve unread reports for the next turn if a turn
triggered by a report is interrupted.

## Testing

Extend the idle eviction scenario to verify that a resumed V3 worker's
explicit report reaches the parent's rollout exactly once after turn
admission is deferred and the subsequent wake is interrupted.

GitOrigin-RevId: 9bf95a4358bca9778797c7064f9eaf20c8679a81
2026-12-01 20:16:42 +00:00
Tom 848d7ffbe3 Trace per-step preparation for each tool contributor (#65067)
Add an info-level `tool_contributor.prepare_for_step` span so traces
show how long each contributor spends preparing before tools are built.
Label the span with the contributor's `trace_name()`, which defaults to
its concrete Rust type name, and skip recording the preparation inputs.

GitOrigin-RevId: cc644deb2d7c1a00e8eea68698516ad1c2e102da
2026-12-01 19:34:56 +00:00
jif 9f02599a9a Add stop_agent for multi-agent V3 (#65061)
## Why

When a worker's current turn is no longer needed, the caller needs to
know when that turn has released its execution slot. Previously,
`interrupt_agent` returned without waiting for the slot to be released.

## What changed

Replace `interrupt_agent` with `stop_agent` in V3. When stopping a loaded
worker, the tool waits for the interrupted turn to release its slot.
A message can resume the worker, and queued input can reclaim the slot
immediately.

Workers can target their own path to stop after the current tool batch
if no new input is waiting and no send failed.

## Testing

Extend the V3 mailbox test to cover self-stop freeing the only worker
slot, a message waking another worker, and the parent stopping that
worker and observing its interrupted status.

GitOrigin-RevId: b066d10e4221fabe49b07ed126752e2e88e9517b
2026-12-01 19:16:25 +00:00
Tom 278dd6cafd Trace each MCP tool-list page and its retries (#65060)
## Why

A tool-list page can take multiple attempts. Tracing the whole page
keeps retry warnings tied to the page that triggered them.

## What changed

Wrap each `tools/list` page request in an `mcp.tools.list_page` span
that covers the retry loop. Record whether the request has a cursor
via `mcp.has_cursor`.

## Testing

Extend the trace propagation test in both MCP protocol modes. Return
HTTP 503 on the first request for the second page and verify that the
requests carry the page span context, the cursor flag reflects the
request, and the retry warning appears on the page span.

GitOrigin-RevId: e4b695731d037f71c15660a826c9f2e59d02e55f
2026-12-01 19:13:34 +00:00
Krish Chainani 71f99fca5d Overlap Noise handshakes with remote environment provisioning (#65057)
## Why

Deferred remote environments previously waited for provisioning to succeed
before looking up the executor and starting the Noise handshake. Starting
that work while provisioning is pending can shorten the wait for a usable
exec-server session.

## What changed

When a deferred Noise environment is selected, start executor lookup and
the handshake with a bounded retry window. After provisioning succeeds,
refresh the connection bundle and reuse the early connection if it is
still live and matches the current environment, executor registration,
and public key. Otherwise, establish a fresh connection. Exec-server
session initialization still waits for provisioning success, and a
provisioning failure cancels the early connection.

## Testing

Cover early connection reuse, fallback when the executor changes or the
socket closes, and cancellation on provisioning failure. Verify that
malformed handshake replies surface as protocol errors and that connection
resets remain retryable.

GitOrigin-RevId: 658135338672f0c02c33d9203299b05ba15d1fc2
2026-12-01 18:56:52 +00:00
jif 3da5a55b5b Abort pending terminal writes when their turn is cancelled (#65036)
## Why

A `write_stdin` call can resume after its turn is cancelled if approval was still pending. It can then send stale input to a running terminal or consume the final output of a remote process that has already exited.

## What changed

After approval, check both tool-call and turn cancellation before a non-empty `write_stdin` request can send input or drain output. Report cancelled writes as aborted and surface the abort as an error to Code Mode cells that are still running. Empty polls can still collect buffered output.

## Testing

Regression tests cover cancellation during stdin approval for direct and Code Mode calls, reuse of the same terminal on the next turn, and retrieval of final remote output after a cancelled write.

GitOrigin-RevId: 735bdd7ed0e892467647039ba72eb9a4d177a560
2026-12-01 16:54:12 +00:00
Benjamin Carlsson 5c865592f4 Remember the TUI's Cloud environment choice per project (#65033)
## Why

Selecting a saved Cloud environment for a draft did not set a default
for future conversations in the same project.

## What changed

- Save the environment selected for a Cloud draft in the local user
  configuration under `tui.default_cloud_environments`, keyed by project
  and local user identity. Selecting Default clears the preference.
- Reuse the preference at startup, when creating a new Cloud conversation,
  and when switching to Cloud. Use the normal Cloud environment selection
  when the saved environment is absent from the catalog or the catalog
  cannot be loaded.
- Use the v2 environment catalog, filter for eligible saved environments,
  and deduplicate entries across personal and workspace results.

## Testing

Cover preference persistence and clearing, project scoping, reuse after a
config reload, fallback when the catalog is unavailable, and catalog
pagination, filtering, and deduplication.

GitOrigin-RevId: bc4f66842c5c83dc75c5b10840fd596feedd44df
2026-12-01 16:51:26 +00:00
felixxia-oai 8ea32990bc Add message-count batching to the Guardian v3 housekeeper (#65028)
## What changed

Set `batch_limit = { mode = "messages", limit = 9 }` in the housekeeper
configuration to route up to nine new evidence records per batch. Each tool
call and each tool result counts separately. In this mode, batches can exceed
the default 100,000 estimated tokens while still fitting within the routing
model's input limit.

## Testing

Add a housekeeping test that routes nine large records in the first batch
and defers the tenth to the next batch.

GitOrigin-RevId: 99fdfc71f432007958c793a46b251f2e32a3e8ba
2026-12-01 16:39:54 +00:00
felixxia-oai 1b3eee5af3 Make Guardian V3 housekeeper batch size configurable (#65027)
## Why

The housekeeper used the model's tool-output truncation limit to size
routing batches, tying how much evidence it could route at once to a
setting intended for tool output.

## What changed

Add `guardianv3.housekeeper.batch_limit` to cap the estimated tokens in
the serialized channel catalog and new evidence. It defaults to 100,000
estimated tokens. The housekeeper packs whole evidence records into each
batch and splits batches further as needed to fit the model's context
window.

```toml
[guardianv3.housekeeper]
batch_limit = { mode = "tokens", limit = 50000 }
```

## Testing

Cover parsing a positive limit and rejecting zero. The routing tests
check that the default groups eight 44 KiB evidence records into one
batch and routes the ninth in a separate batch.

GitOrigin-RevId: 2480afb8b64ed042fa41d75513aea8186e2a578e
2026-12-01 16:38:27 +00:00
jif 18cf9ef6e7 Let V3 workers stop after their tool calls finish (#65025)
## Why

A worker can send a message and ask to stop in the same response. It
needs to see any send failure before going idle so it can respond to
the error.

## What changed

When a V3 worker targets itself with `interrupt_agent`, finish the
current tool batch and skip the automatic model follow-up if no
`send_message` call in that batch failed. Pending input can still
trigger another model request. Scope the stop to the sampling attempt
so it cannot carry over to a retry.

## Testing

Extend the mailbox integration test to cover a truncated response, a
send failure alongside a self-stop, and a subsequent self-stop that
runs the `SubagentStop` hook and frees the worker slot.

GitOrigin-RevId: 62e377026d32ffc59d1ea5b88030ce9148d414b4
2026-12-01 16:23:27 +00:00
jif aadf113445 Wait for V3 workers to release their slots when stopped (#65008)
## Why

With only one worker slot, starting a replacement can fail while the
interrupted worker is still cleaning up its turn.

## What changed

Add `CodexThread::stop_worker` for V3 workers. Enable interruption at
sampled item boundaries for V3 and make the stop call wait until the
interrupted turn releases its execution slot. The stopped thread can
still accept later messages.

## Testing

Add an integration test that holds a worker during sampling and abort
cleanup, checks that the stop call remains pending at both points, and
starts a replacement worker in the only worker slot after stop returns.

GitOrigin-RevId: da78de02d8c32a0f6e62b0487b49cf4908c01de5
2026-12-01 15:16:03 +00:00
jif 33aab1f2c6 Always track retained command sessions in world state (#64993)
## What changed

Track retained command sessions on every turn and mark
`command_sessions_world_state` as a removed compatibility flag. When
`write_stdin` is unavailable, keep reporting retained sessions and indicate
that they cannot be polled.

Omit the command session section when there are no sessions and no prior
section. Still emit an empty update when needed to clear stale handles.

## Testing

Update the Code Mode scenario to exercise retained command session tracking
without enabling the flag. Its snapshot omits the empty section before any
commands are retained.

GitOrigin-RevId: fd953750b06f0098ae6382ce3d3115a1263fd305
2026-12-01 13:42:02 +00:00
jif 51957a2da5 Handle Stop after multiple command approval declines (#64960)
## Why

The desktop client declines all open command approval prompts before
sending Stop. If the first decline is still being recorded in history,
a second queued decline can keep Stop from reaching the active turn.

## What changed

Queue consecutive declines for the same active turn and record them in
submission order. If Stop follows, interrupt the turn while the declines
are still being recorded, then finish recording them before publishing
the turn-aborted event.

## Testing

Extend the interruption regression test to cover two declined prompts
followed by Stop. It checks that the running sibling command stops while
history is blocked, both commands are recorded as declined before the
turn-aborted event, and completed sibling output is preserved.

GitOrigin-RevId: 00ac946378cc5fcf6c77e4a657aaa64508d60421
2026-12-01 09:44:12 +00:00
Alex Daley a54018ff36 Expose TypeScript signatures in Code Mode's ALL_TOOLS (#64939)
## Why

Code Mode embeds TypeScript declarations in tool descriptions, so scripts
that want to inspect a tool's argument and return types have to extract
the declaration from the description.

## What changed

Enable `features.code_mode_all_tools_schema` to expose callable names,
descriptions, and TypeScript signatures as separate fields in `ALL_TOOLS`.
Update the `exec` guidance to match the selected format, including when
resuming a session. The flag is off by default.

Carry signatures over gRPC and stdio. Reject execution requests with
signatures when the host does not advertise support for them.

## Testing

Add coverage for both catalog formats, `exec` guidance on resume, and
signature preservation over gRPC and stdio.

GitOrigin-RevId: dedaeec4a2563c23d432c324187ef20f6a0e5ea3
2026-12-01 06:54:13 +00:00
akak-oai 936ac6dbe6 Add critical-path snapshots for turn milestones (#64935)
## Why

The completed turn profile describes the whole turn. A host measuring latency
to an intermediate event needs the elapsed time and critical path at that event.

## What changed

Expose `turn_milestones` through `codex-core-api` and bind host-provided watches
when a regular turn starts. Add helpers to match published assistant text to
the sampled response and capture a one-shot observation with its source,
elapsed time, and critical path at the cutoff.

## Testing

Add tests that verify a cutoff during a second sampling round includes earlier
sampling and joined tool work, stale or cancelled candidates leave the watch
available, and elapsed time is recorded even when critical-path capture is
disabled.

GitOrigin-RevId: 507b7aaf8819b5cedf608ea66807c632bcb59c82
2026-12-01 06:25:16 +00:00
pakrym-oai 2c2a945de2 Record why Responses WebSockets fall back to HTTP (#64923)
## Why

The fallback counter identifies the original transport but gives no indication
of what triggered the switch to HTTP.

## What changed

Include the triggering Codex error kind and HTTP status, when available, in
the fallback warning and the `codex.transport.fallback_to_http` counter.
The counter uses `none` when the error has no HTTP status.

## Testing

Integration tests assert a single counter increment with the expected tags for
HTTP 426 during connection setup, HTTP 403 after retries, server overload, and
oversized WebSocket messages.

GitOrigin-RevId: 6f8b9d5049da1563e035fff62473c85693f0ad1b
2026-12-01 04:47:08 +00:00
Tom c1eee51321 Trace capability discovery and cloud catalog refresh (#64917)
## What changed

Add tracing spans for per-step plugin selection, host skill discovery,
and V2 capability-root snapshots. The snapshot span records whether
skill discovery was requested.

Trace cloud catalog refresh and discovery, and time the step's wait
for the catalog lock separately from preparation under the lock.

GitOrigin-RevId: 12eeb6333a8d2b335e92112dc7dccae6e7ed266d
2026-12-01 04:09:45 +00:00
Anthony Tafoya 976c0fbbfc Stabilize span assertions in spawn publication tests (#64915)
## Why

SQLite workers can retain spans after acknowledging a write, so reading
the exporter immediately can miss spans. A paginated history reader can
also keep the fork span open after history preparation returns.

## What changed

Collect exported spans until the tracer is released, with a bounded
timeout. Cover failed spawn publication cleanup with both paginated and
in-memory history against the SQLite graph store. Check that fork
preparation starts before or at the graph upsert in the paginated case,
and that its span ends before or at the upsert's start in the in-memory
case.

GitOrigin-RevId: 2438ed49bc6c6d6c74c2695c9397a39dacc1dee2
2026-12-01 04:08:34 +00:00
Won Park 092fc09d9a Use the current MCP runtime context for skill dependency OAuth (#64899)
## Why

OAuth discovery for newly installed skill dependencies needs an HTTP
client for each added server. Building the full runtime MCP configuration
does extra work because the installer already has those server configs.

## What changed

Use `current_mcp_runtime_context` to resolve the HTTP clients for the
added servers.

GitOrigin-RevId: 4970954dd5f1ed21a02dfe7f6c3a9f1df4fe7026
2026-12-01 03:06:11 +00:00
Won Park bbfa676153 Enable unified exec process tests on non-Unix platforms (#64894)
GitOrigin-RevId: 86243d7100f9bf269924c81cdaf9593db03166dc
2026-12-01 02:57:20 +00:00
Owen Lin 8c04e2529c Support prepared creation of persisted threads (#64839)
## Why

Thread stores can do work before Core starts, but the ordinary creation
API has no way to pass that state back to the store when it creates the
thread.

## What changed

Pass optional, single-use `ThreadStoreCreatePreparation` from
`StartThreadOptions` to `ThreadStore::create_thread_with_preparation`
when creating a persisted thread, including a fork. Reject creation
preparation for ephemeral or resumed threads. Stores that do not implement
the prepared creation method return an unsupported-operation error.

## Testing

Add a regression test that supplies creation preparation to a prepared
fork and checks that it reaches the prepared creation method by asserting
the default unsupported-operation error.

GitOrigin-RevId: bc4d3e9e5d89dd7503aed75423bc9c9d42c7f7fc
2026-12-01 00:40:48 +00:00
goodman-oai 83545f3514 Allow model catalogs to omit writable-root sentences (#64837)
## Why

The environment context already lists writable paths. An empty catalog
template previously fell back to the bundled writable-root sentence,
so a model catalog had no way to omit that repeated list.

## What changed

Treat an empty `writable_root` or `writable_roots` template as a request
to omit the corresponding sentence. Missing, null, invalid nonempty,
and oversized templates still use the bundled wording.

Suppressed roots leave the full path budget available for denied-read
paths and globs and never trigger an omitted-path warning on their own.

## Testing

Cover empty singular and plural templates and verify that suppressed
roots leave room for denied-read entries. A model-switch scenario checks
that Codex appends the updated permissions message once and preserves
the earlier conversation, filesystem permissions, and approval settings.

GitOrigin-RevId: 105819fb07ff829be8f111b3676656373aeb7892
2026-12-01 00:29:20 +00:00
jif 51bcfc3768 Fix cleanup when unified exec startup is canceled (#64833)
## Why

Canceling a remote command during the early-exit grace period could
drop the process before handoff and run ordinary termination. That
bypasses the exec server's startup cleanup, which also disables
recovery for the abandoned session.

## What changed

Track whether each process has been handed off or abandoned. Dropping
a live process before handoff abandons startup once. Processes handed
off to the process store or to a one-shot caller retain normal
termination on drop.

## Testing

Add regression tests for cancellation during the early-exit grace
period, dropping an explicitly abandoned process, and normal cleanup
after registration or one-shot handoff.

GitOrigin-RevId: 2276ba15e50a2345da21e7841ab9015b572786ac
2026-12-01 00:26:27 +00:00
jif 6dab58d9f7 Preserve read-only permissions across repeated thread resumes (#64829)
## Why

A cold resume can save a read-only profile with concrete read paths
derived from the current configuration. On the next cold resume, those
paths make the saved profile ineligible for direct reuse, so the thread
can fall back to a writable default.

## What changed

When restoring a saved read-only profile with restricted network access
that cannot be reused directly, rebuild its read grants from the current
configuration while keeping writes disabled and network access
restricted. Preserve read denials from both the saved profile and the
current configuration. For deny globs, use the larger scan depth when
both contributing policies are bounded and keep the scan unbounded if
either contributing policy is unbounded.

## Testing

Cover two consecutive cold resumes under a scoped writable default, and
test that restoration respects the current read allowlist, preserves
saved path and glob denials, merges glob scan depths, and drops the
configured network proxy.

GitOrigin-RevId: 04c91804e83d396402e1c8a985e4c3ff006f7e91
2026-11-30 23:48:15 +00:00
Charlie Marsh b0b5cfcab8 Connect plugin MCP servers over launcher-provided Unix sockets (#64828)
## Why

A launcher that already hosts an MCP server needs a way for Codex to
use it without starting a separate subprocess for the plugin.

## What changed

The stdio app server accepts socket bindings from its immediate parent
on Unix. A binding applies to a local plugin's stdio MCP server only
when the plugin ID, server name, and binding ID match a single entry.
Codex uses the stdio wire protocol over the socket and retains the
original declaration for policy checks.

Before sending MCP traffic, Codex requires a user-owned socket
directory with mode `0700` and verifies the listener's PID and UID.

## Testing

Add tests for binding scope and ambiguous matches, and for rejecting
unexpected listener PIDs, insecure directory permissions, symlinked
socket directories, and relative socket paths.

GitOrigin-RevId: 3d669dd59a0812b04727e4a1e458774007f054ba
2026-11-30 23:34:32 +00:00
Brent Traut 515cfeceba Skip host skill discovery in the remote command approval test (#64827)
## Why

An empty extension registry falls back to legacy host skill discovery
even when `SkipHostSkillDiscovery` is enabled. The remote command
approval test only needs to check plugin attribution when script reads
are denied.

## What changed

Enable `SkipHostSkillDiscovery` and register the skills extension with
no providers in both variants of
`remote_command_approval_skips_attribution_for_a_read_denied_script`.

GitOrigin-RevId: 1abcf6a762ac359825fe1c4db97160b9bfde0f87
2026-11-30 23:33:54 +00:00
ioanbudea-OAI 6b599f7a8e Use then_some for Notes metadata in the multi-environment MCP test (#64823)
GitOrigin-RevId: 8fab548c5c06ec5b0f005872f0b98d6c2d93fcbd
2026-11-30 22:53:09 +00:00
Joe Savona 1843a4df93 Expand the bundled MCP statusline authoring guide (#64814)
## Why

An unsupported UI tag or property invalidates the entire statusline
response, so providers need a fallback for clients whose rendering
capabilities are unknown.

## What changed

- Document the available UI elements with examples for wrapping rows,
  spacing fields, preserving whitespace, and displaying status badges.
- Explain how to use `app.cli_version` to check support for features such
  as `spacer` and `maxLines`, and return a plain string for the entire
  footer when support is unknown or absent. Carry the `spacer` guidance
  into the generated TypeScript reference.
- Clarify how to diagnose provider discovery failures with F2 and check
  `tools/list` metadata when a provider is missing from the picker.

## Testing

Update the scenario snapshot that verifies an explicit statusline skill
mention loads the bundled guide.

GitOrigin-RevId: 9c6ea1d356146c2d666359732d6a065ed41d9fee
2026-11-30 21:44:01 +00:00
felixxia-oai 02a15f1244 Cancel Guardian V3 shadow reviews on interruption (#64813)
## Why

A Guardian V3 shadow review could keep running after its live review or
owning turn was interrupted, leaving the reviewer slot occupied.

## What changed

- Cancel the shadow when a pending live review is cancelled or dropped,
  and let the live review finish its cleanup on cancellation.
- Cancel in-flight shadows when their owning turn is aborted, even if
  the live verdict is already available, and prevent new shadows for
  that turn. On normal turn completion, shadows can finish independently.

## Testing

Cover tool cancellation during live-review cleanup and turn interruption
both during review and after approval. The app-server test also checks
that a later turn can start a shadow and complete while it is still
running.

GitOrigin-RevId: 45df0575853d5f8ca7ef7282fcd0fa1f22fed6c5
2026-11-30 21:35:13 +00:00