Commit Graph
6780 Commits
Author SHA1 Message Date
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
ioanbudea-OAI 7d60863a4a Include direct MCP screenshots in synchronous Guardian reviews (#64811)
## Why

Synchronous Guardian reviews could receive screenshots from Code Mode calls,
but missed screenshots returned by direct calls to the same REPL connectors.

## What changed

Capture screenshots from accepted direct `node_repl` and `cua_repl` MCP
results when multimodal review evidence is enabled. Include them alongside
Code Mode evidence in call order, with separate retention budgets.

When the synchronous review prompt exceeds its fixed image budget, retry with
only the last image in prompt order and keep it if the prompt fits.

## Testing

Add coverage for screenshot delivery to synchronous permission reviews,
including text-only mode and image budget overflow. Verify that direct
screenshots preserve call order and do not consume the Code Mode retention
budget.

GitOrigin-RevId: e74ee6c5578225efb284c1ca38494377a1d0762e
2026-11-30 21:34:02 +00:00
Aismit 1108cbcbef Require fresh Guardian review after tool input rewrites (#64810)
## Why

A `PreToolUse` hook can change a tool's arguments while keeping its call
ID. An asynchronous risk score for that ID still describes the original
action, even if the score arrives after the rewrite.

## What changed

Require synchronous Guardian review when a hook changes the tool payload
and discard the original assessment. Preserve normal review behavior
when the hook returns an identical payload. Also require synchronous
review for MCP elicitations without an associated tool approval context.

## Testing

Add regression coverage for unchanged hook output, rewritten patches
whose original scores arrive before the rewrite or during review, and
MCP elicitations with missing approval context or rewritten inputs.

GitOrigin-RevId: 994519d61d52c69edcdec9517766a8e3051587d5
2026-11-30 21:32:28 +00:00
sayan-oai 829ddd4442 Honor the skill installation named in an explicit mention (#64805)
## Why

When a catalog entry groups multiple installations of a skill, a link to
a specific installation can load instructions from the primary
installation, such as the Cloud copy.

## What changed

Carry the matched installation through to the instruction read and
resource metadata. A path that uniquely identifies an enabled
installation takes precedence over name-only and ambiguous mentions of
the same skill, regardless of mention order. Default mentions still
use the primary installation, and distinct executor environments can
each be selected in the same turn.

## Testing

Extend the merged catalog test to cover a path shared by Cloud and
executor copies and a package link that selects the executor copy.
Update the installation recovery scenario to show that an explicit link
loads the selected environment's instructions into the initial request.

GitOrigin-RevId: f4495c5442b9f4c14d5cdcc4c717717e2119b088
2026-11-30 20:49:39 +00:00
Steve Coffey b26c32c843 Record model attribution in persisted token usage (#64804)
## Why

A model can change between steps of the same turn. Persisted token usage
records need the model for each response to distinguish usage before and
after the switch.

## What changed

Add an optional `model` field to `TokenUsageRecord`. Record the model
selected for the sampling step on both completed and incomplete responses.
Attribute compaction usage to the model selected at the start of the turn.
Existing records without the field still deserialize.

## Testing

Extend coverage to check persisted model attribution and cumulative token
totals after a mid-turn switch, including when the response hits the output
token limit. Verify that compaction keeps the turn-start model attribution
and continues restored usage totals.

GitOrigin-RevId: 3615724c1cbe6ed46c9367d6c3c1a29ebaba73d8
2026-11-30 20:29:59 +00:00
bkotsopoulos 89bc4351be Trace MCP runtime refresh contention (#64800)
## Why

MCP refresh traces show how long an operation waits for the refresh gate, but they lack the timing and operation labels needed to identify which refresh held it.

## What changed

- Tag refresh wait and hold spans with a shared gate ID and the operation name so overlapping spans show which operation held the gate while another waited.
- Carry the scheduling trace context into background MCP prewarm and add a span for the Apps catalog refresh.

## Testing

- Add a test that checks the exported wait and hold spans share a gate ID and overlap while a second operation waits for the permit.
- Make the worktree TUI test wait for the `Ready` run state before submitting input, since a directory change can appear while the composer is still busy.

GitOrigin-RevId: be2b6d2a82e4a5b553fb3f335850865f04a181ee
2026-11-30 20:09:18 +00:00
bkotsopoulos 9b64b43207 Record pre-sampling overhead in turn telemetry (#64799)
## What changed

Record `codex.turn.pre_sampling.duration_ms` when a sampling phase starts. Use the `is_first_sampling_request` label to distinguish overhead before the first request from overhead accumulated since the preceding request. The timing excludes tool blocking and compaction.

## Testing

Extend turn timing tests to verify the first-request duration, per-request overhead across subsequent requests, and the exclusion of tool blocking and compaction.

GitOrigin-RevId: 068be5cb4d1345dc064fa8f1df2469dfa0f3071f
2026-11-30 19:56:54 +00:00
jif 069804e021 Reject mid-turn service tier overrides for hosted children (#64796)
## Why

Hosted children using a shared service tier already reject overrides
when a turn starts, but turn settings updates could still request a
different tier during an active turn.

## What changed

Apply the same rejection and error message to turn starts and active
turn settings updates for hosted children using a shared service tier.

## Testing

Extend the WebSocket regression test to verify that a mid-turn tier
override is rejected and the child still uses the root's updated tier
on its next step.

GitOrigin-RevId: 4fad6d02b56d81aba162f3e87b6dcaae2386d171
2026-11-30 19:23:46 +00:00
fahad-OAI dac56a1ca2 Remove special-case instructions from the web search tool (#64788)
## What changed

Remove the `web.run` instructions to check local code first and limit
browsing to official OpenAI sites for OpenAI product questions, to rely
only on primary sources for technical questions, and to explicitly flag
inferences from sources.

Update the thread sampling and web search scenario snapshots to reflect
the revised tool description.

GitOrigin-RevId: d35dcaaeb69940af5d7f9df19aba337fd0ab6426
2026-11-30 18:51:22 +00:00
jif 89a5bb31f4 Keep hosted agent corrections behind pending follow-up tasks (#64785)
## Why

An injected `send_message` correction could reach a hosted worker before
the `followup_task` it refers to because turn-local input drains before
the mailbox. An interrupt during a history checkpoint could also drop
corrections from a batch that had already left the queue.

## What changed

Queue plain-text agent messages behind pending follow-up tasks and
deliver them in mailbox order, even across turn boundaries. Record
accepted follow-ups and corrections before waiting on their checkpoint,
and save deferred injections to session history on shutdown.

## Testing

Add regression coverage for native and hosted delivery order, hosted
corrections sent between turns, interruption during a checkpoint, and
correction persistence across shutdown and resume.

GitOrigin-RevId: 3acffd175d3bb2d7e1a9f704fe6c6d6ce38e798d
2026-11-30 18:37:59 +00:00
felixxia-oai 10a8d4ff15 Retire Guardian V3 shadow boards when intake stops (#64784)
## Why

An intake failure blocked new shadow reviews but let in-flight reviews
continue after the board stopped receiving thread history. Loaded child
threads could also retain references to the stopped board.

## What changed

Cancel in-flight shadow reviews and release board resources in the
background when intake stops. Keep completed verdicts in the comparison
with Guardian V2 and count eligible reviews skipped because intake
stopped across the root and its child threads. Allow a fresh board when
shadow enrollment is turned off and back on.

## Testing

Cover cancellation while a shadow response is still pending, board
cleanup while child threads remain loaded, and retirement waiting for
a finishing review to release its slot.

GitOrigin-RevId: a95bf5527ef3251d37207d07d76430f6557cd420
2026-11-30 18:29:43 +00:00
felixxia-oai 6984bcc0c2 Measure Guardian v3 shadow review outcomes and latency (#64783)
## Why

Comparing the live v2 reviewer with the v3 shadow reviewer requires
measuring both on the same action. A live retry can pick up new context,
which can affect how a verdict disagreement is interpreted.

## What changed

Record outcomes for each reviewer and emit paired outcomes and timings
when both return validated verdicts. Measure from a shared start to each
verdict's validation and tag the pair when the live review's context
changed.

Track shadow skips when the reviewer is busy or intake has stopped, and
exclude shadow denial retries from live reconsideration metrics.

## Testing

Add a metrics test that checks exactly-once reporting for completed,
failed, and cancelled samples and verifies pair emission for two
validated verdicts.

GitOrigin-RevId: 1a0f8e4e38099ea172e6511d4fa2fe8735b82ea4
2026-11-30 18:28:15 +00:00
felixxia-oai 457ea27b0b Shadow fresh Guardian V2 approvals with Guardian V3 (#64782)
## Why

Collect Guardian V3 verdicts for actions that require a fresh Guardian V2
review while keeping Guardian V2 in control of approval and tool execution.

## What changed

When Guardian V3 shadowing is enabled and an enrolled reviewer is available,
run a single background review for eligible fresh approvals and log the
outcome with the live review ID. Skip shadowing when the reviewer is busy,
shadow intake has stopped, or a rollout budget is configured.

## Testing

Add app-server coverage for immediate approvals, ordinary synchronous
reviews, and fresh reviews with and without a rollout budget. Hold a shadow
denial in flight to verify that the tool and turn can finish, a second
request skips the busy reviewer, and stopped intake prevents new shadow
reviews while the in-flight verdict can still finish.

GitOrigin-RevId: 5e31f3d7e3b0433455b8f2a5fb52e483588b1b29
2026-11-30 18:27:38 +00:00
jif e3694f5cba Keep one-shot command timeouts active after approval decisions (#64781)
## Why

Recording a declined command can delay tool-result delivery. When
one-shot commands shared that pause for runtime limits, a sibling
command could keep running past its configured `timeout_ms`.

## What changed

Track command timeouts separately from tool-result delivery. A proposed
command holds result delivery through setup and resolution, while its
approval prompt pauses command timeouts only while a decision is
pending. A running one-shot command can then time out while its result
is still held, with its terminal ID remaining addressable until result
collection finishes.

## Testing

Cover the pause states before, during, and after the approval prompt.
Exercise both a sibling command that times out and one that exits
normally while a decline is being recorded, checking terminal access
and the exit status in the eventual tool result.

GitOrigin-RevId: d359bfc99fb9c23e6c61e94d75040cd6c1b09c49
2026-11-30 18:16:01 +00:00
jif 9baf9789e1 Honor interrupts during resumable exec_command startup (#64753)
## Why

A turn interrupt can arrive while a command is waiting for its executor
connection or while a newly launched shell is still being registered.
The command can then launch after the interrupt or keep running before
the caller has a session ID to interact with it.

## What changed

Check for cancellation before dispatching a resumable command, including
after remote connection recovery. If the shell has already started and
is still running, stop it when cancellation wins before registration and
return the usual `aborted by user` result. Preserve the result of commands
that already reported an exit.

Track any pending command begin and end events for interrupted startups
so session shutdown waits for them to be published.

## Testing

Add regression coverage for interrupts before dispatch and after launch
but before registration, including command history on shutdown. Cover
cancellation during remote executor recovery and cleanup of abandoned
remote starts.

GitOrigin-RevId: 624df736ca2cb077e879f52a194ee4d89afd225a
2026-11-30 16:29:58 +00:00
jif 31d8ed6d0f Resume idle V3 workers with send_message (#64750)
## What changed

In multi-agent V3, `send_message` starts a new turn in an idle
worker's existing conversation, including after eviction. The worker
receives the input as a `MESSAGE`. Sends to `/root` still follow
its wake policy.

Remove `followup_task` from the V3 tool set and select role instructions
that match the agent tree's version.

## Testing

Cover delivery to active workers at the concurrency limit, retrying
an idle worker once a slot opens, and resuming workers after eviction
or session restore.

GitOrigin-RevId: 3b0e55f150784896aa6e0dfa926bc490bdd2627d
2026-11-30 16:12:41 +00:00
jif 6c7f53890f Assert the turn stays active after declining exec approval (#64744)
Check that the approval request's turn is still current before sending
`Op::Interrupt` while the decline is waiting to be recorded.

GitOrigin-RevId: c1e23a77efc0d5550e9ffa280d72bb66da711ed8
2026-11-30 15:22:51 +00:00
jif 7caec30d71 Honor Stop while recording a declined command approval (#64740)
## Why

Recording a declined command approval can delay a subsequent Stop request while other commands in the same turn are still running.

## What changed

If Stop is next in the submission queue, interrupt the active turn while the decline is still being recorded. Consume Stop only if it interrupts that turn, and leave other submissions in order.

## Testing

Extend the approval cancellation regression test to cover declining a command and then pressing Stop. The test checks that a running sibling command stops before the decline is recorded and that output from a completed sibling remains available in the next turn.

GitOrigin-RevId: 9f08cb35f96e497d95eaa0aefb039ca9729761e7
2026-11-30 14:40:49 +00:00
jif 808f3345e9 Support the V3 multi-agent selector on the V2 runtime (#64735)
## Why

Enabling `multi_agent_v2` forced the V2 tool version before a fresh
thread could use the model selected for its first turn. The shared
runtime needs to support both V2 and V3 selections.

## What changed

- Let the first turn select V2 or V3 from the active model, with V2 as
  the fallback when the shared runtime is enabled.
- Pass the selected version to fresh and forked subagents, including
  through host-prepared child creation.
- Report both selections as `v2` in app-server model metadata because
  they use the same runtime.

## Testing

Extend integration tests to cover model switches between V2 and V3
before the first turn and V3 inheritance in fresh, forked, and
host-prepared children.

GitOrigin-RevId: de1fd9836d8cb3c4dc19805507462f4f5cfe3959
2026-11-30 13:51:38 +00:00
jif bda8fc3c04 Centralize multi-agent V2 runtime checks (#64731)
Add `MultiAgentVersion::uses_v2_runtime` to identify versions that use
path-addressed workers and turn-scoped execution slots. Use it to gate
runtime behavior such as subagent spawning and resumption, forked
history handling, and message routing. The predicate matches only
`MultiAgentVersion::V2`, preserving existing behavior.

GitOrigin-RevId: 712243c5df310c0745bf69c4faff660a44f05be5
2026-11-30 13:09:06 +00:00
jif acd1a3794b Frame pending native multi-agent calls in Guardian reviews (#64729)
## What changed

When native multi-agent v2 history is enabled, Guardian automatically
frames the pending call and its paired output as a distinct approval
request. Mark the separate `guardian_native_action_framing` flag as removed.

## Testing

Update the incremental review snapshot to capture the framed
`send_message` and its paired output. Update the root handoff test to
match setup handoffs at the approval boundary so historical calls
cannot mask the final command's separate denial.

GitOrigin-RevId: 5194a8cdf21e5d71f3a7942c0ce637f115316476
2026-11-30 12:52:50 +00:00
jif ae78265f08 Streamline rollout history handling for thread forks (#64704)
## Why

Forking before a known user message only needs its rollout position. The
previous path replayed turn history even when that position was available.

## What changed

Compute the fork boundary on the borrowed rollout before taking ownership
of its records. Use rollback-aware user message positions for in-range
requests and inspect the unfinished turn only for out-of-range requests.

Share unfinished-turn detection and closure between interrupted thread
forks and subagent forks that preserve the parent prefix. Read turn
metadata without materializing the active turn's items.

## Testing

Cover empty fork histories and verify that an interrupted fork persists
the original turn ID, root turn ID, and start time in its abort event.

GitOrigin-RevId: 8d732f9f9c5fcc9aa4be27c3e48b68e43531e938
2026-11-30 09:40:54 +00:00
rhan-oai 39e7013b3f Wake sleeping hosted roots on injected agent mail (#64680)
## Why

With native tools disabled, injected agent mail could be persisted without
waking a hosted root in durable sleep.

## What changed

Schedule a mailbox wake for sleeping hosted roots after injected plaintext
mail is durably recorded. Keep the interrupted turn active through
`TurnAborted` so mail arriving during the interruption can start a turn
only after the abort event is published.

## Testing

Add regression coverage for queue-only mail waking a hosted root with its
previous turn context and for mail injected during the sleep interruption
starting a turn after `TurnAborted`.

GitOrigin-RevId: 939db5ffca9af1273e4fb4c8d0dfb6bb7a95ea09
2026-11-30 05:06:55 +00:00
smurching-oai f0f1040931 Allow local MCP HTTP header helpers to receive selected env vars (#64672)
## Why

Local MCP HTTP header helpers run with a restricted environment. A helper that needs a host setting such as `HTTPS_PROXY` needs a way to receive that variable while keeping the rest of the host environment restricted.

## What changed

- Add `http_headers_helper_env_vars` for local Streamable HTTP servers. A nonempty list requires the server URL and an absolute helper executable path in the same user or administrator configuration entry. Codex launches that executable directly, and Windows requires an `.exe` path. Helper entries without the list retain shell command syntax.
- Revoke inherited access when a higher-priority entry overrides the URL, helper, or variable list. An empty list explicitly clears an inherited grant.
- Show effective variable names in `codex mcp get` and the JSON output of `codex mcp list`, while keeping helper commands and variable values out of the output. Make `codex mcp add` and `codex mcp remove` edit only the named server so unrelated grants stay in their original configuration layer.

## Testing

Add coverage for grant validation and revocation, variable forwarding during OAuth startup and header refresh, CLI redaction, and preservation of administrator grants during unrelated CLI edits.

GitOrigin-RevId: d1ebdcf4dbd7946c0f3bfb982464a0024768d585
2026-11-30 04:08:38 +00:00
Dylan Hurd ab95e048b2 Verify Guardian network approvals against a mock origin (#64653)
## Why

The routing test needs to verify that Guardian's decision controls whether
a request reaches its destination. Loopback addresses are covered by
`NO_PROXY`, so the probe must explicitly use the managed proxy.

## What changed

Send both probes through `HTTP_PROXY` to a local mock origin. Assert that
the approved command exits successfully and receives the origin's response,
and that the denied command reports Guardian's denial without sending a
second request to the origin. Collect output across the initial
`exec_command` response and subsequent polls so the test can check stdout
even when it arrives before the process exits.

GitOrigin-RevId: aa32a588e9ad9a049621242d8b8a567462237cca
2026-11-30 01:26:59 +00:00
ioanbudea-OAI fd7f1f0346 Add metadata-only reads to the thread store (#64651)
## Why

Callers that only need canonical session metadata should be able to read it
without loading the full rollout history.

## What changed

Add `ThreadStore::read_session_meta`. The default implementation looks for
the session header in the latest model context and falls back to history if
the header is absent or model context reads are unsupported.

The local store reads only the selected rollout's header and skips SQLite
read repair, which can parse the full rollout. If archiving or unarchiving
moves the file before SQLite updates its path, the lookup can follow the
rollout to its new location while respecting `include_archived`.

## Testing

Cover paginated metadata reads, the history fallback for a saved child
thread, and metadata reads with missing or stale SQLite entries. Verify that
a valid header can still be read when the rest of the rollout contains invalid
bytes.

GitOrigin-RevId: 08790b2db80d35e67f5a101dc38d760987b2d710
2026-11-30 00:51:08 +00:00
Dylan Hurd 065e18b040 Keep MCP guardian elicitation fixtures local in remote tests (#64425)
## Why

The automatic test builder registers only the selected execution
environment. When that environment is remote, the Python MCP fixtures
need access to the local environment.

## What changed

Use `build_with_remote_and_local_env` for the guardian elicitation tests
and set each Python MCP fixture's `cwd` to the test process's current
directory.

Attach the in-memory metrics client through `with_thread_extension` so
the yielded Code Mode elicitation test can use the thread created by
the builder.

GitOrigin-RevId: edc65db60665970e1c98686ab01e0012b47f5c79
2026-11-28 06:13:28 +00:00