Commit Graph
6743 Commits
Author SHA1 Message Date
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
jif 045a11fe2c Respect sandbox read restrictions in remote plugin approvals (#64369)
## Why

Remote command approvals could attribute a command to a plugin by reading
a script that the turn's filesystem permissions denied access to.

## What changed

Use the remote environment's sandbox policy and stored permission grants
when resolving script paths, checking file metadata, and reading scripts
for approval attribution. If the lookup is denied, the approval prompt
still appears without plugin attribution.

## Testing

Add a regression test that checks for an approval prompt without a plugin
ID or script path when either the environment policy or a stored turn
grant denies reads of an otherwise matching plugin script.

GitOrigin-RevId: 123fd72c14cd31121d271fa800f005d3fc41a366
2026-11-27 19:09:58 +00:00
jif 005a57e890 Interrupt running commands promptly when approval is canceled (#64368)
## Why

Recording a declined command can block on history writes. If turn
cancellation waits for that write, sibling commands can keep running.
The same write can also delay recording results from commands that
already finished.

## What changed

Signal cancellation before recording the declined command and publish
the decline before `TurnAborted`. Start the task's shutdown grace period
after publication so it has time to record completed tool results.

## Testing

Add a regression test that blocks publication of the decline, verifies
that a running sibling stops while publication is blocked, and checks
that another sibling's completed output reaches the next model request.

GitOrigin-RevId: c0b2e40e711ffe5ee46b76b110410518d2191041
2026-11-27 19:08:45 +00:00
jif 187f00e805 Finish approved remote one-shot commands after startup interruption (#64367)
## Why

Interrupting an approved one-shot command while remote plugin attribution
is pending can stall session shutdown and leave the command without a
terminal record. An open elicitation can also delay output collection.

## What changed

On interruption, skip the pending remote attribution lookup and optional
plugin metrics read, and bypass the elicitation pause during output
collection. Keep session history open until the command's terminal event
is published, including when the exit watcher publishes it.

## Testing

Extend the remote startup interruption test to cover resumable commands
and approved one-shots. Verify process termination and session shutdown
with the attribution request still pending, and check that the approved
one-shot records exactly one failed completion with an unrelated
elicitation still open.

GitOrigin-RevId: e9b78290544d634797876119006540150a7672b1
2026-11-27 18:55:47 +00:00
jif 18c09f20ce Share tool approval logic across initial attempts and retries (#64355)
## What changed

Build `ApprovalContext` and submit approval requests through shared
code. Retry requests add the retry reason and any network approval
context, while the initial request retains its approval source for
later execution decisions.

GitOrigin-RevId: a8210c7b32fcc1414141198bdacfe55fff39b9b6
2026-11-27 17:04:35 +00:00
jif 30ffdd0619 Preserve command approval items through turn interruption (#64349)
## Why

The app server could show a command awaiting approval before core had
recorded its start. Interrupting the turn or abandoning launch after
approval could leave the live command item and saved history out of sync.

## What changed

Have core publish the command item before prompting for approval and
retain it across approval and sandbox retries until execution takes over.
Complete abandoned items as declined when interrupted while awaiting
approval, or as failed when interrupted after approval but before launch.
Wait for pending approval item writes during shutdown.

## Testing

Extend the app-server interrupt test to restart the server and verify
that the interrupted turn contains exactly one declined command item with
the original approval item ID.

GitOrigin-RevId: c9f027fc7096d091dc8cf1936c88aa69d3eed8c1
2026-11-27 16:25:10 +00:00
jif c8cb4e36ed Drain unified exec launch failure events before session shutdown (#64346)
## Why

A launch failure can still be publishing its command events after the turn
is interrupted. If the session shuts down during publication, the failed
command can be lost from persisted thread history.

## What changed

Track in-flight launch failure publications and wait for them to finish
before running session-end hooks and emitting the thread-stop event.
Once shutdown closes the tracker, skip new launch failure publications.

## Testing

Add a regression test that pauses publication for a command with a missing
working directory, interrupts the turn, and requests shutdown. It checks
that shutdown waits and that persisted history records the command as failed
in the interrupted turn.

GitOrigin-RevId: 1fb33d1fd3c11939c0013f5feb4edb737702b0ad
2026-11-27 15:57:38 +00:00
Felipe Coury 1a1f005766 Gate hosted Guardian test helpers to non-Windows builds (#64345)
The hosted Guardian scenarios are already excluded on Windows, leaving
their reload and stall helpers unused in Windows test builds.

Apply the same platform gate to the `Reloaded` and `Stalled` read modes
and the stall notification. Make the root snapshot mutable only in
the reload branch.

GitOrigin-RevId: 1f517e56ba6ce436b96c6e44c4dc4731b94e1e97
2026-11-27 15:45:48 +00:00
jif 6bf1e3e687 Persist command completions when approval is declined or fails (#64341)
## Why

The app server completed command items for rejected approval responses
directly in the live stream. That bypassed core's history recording, so
clients could see a completed command live and lose it when reloading
the turn.

## What changed

Keep top-level command items with their pending approvals in core.
Record and emit the command completion before unblocking the turn.
Declines and cancellations produce a `declined` item, while invalid
responses and approval request failures produce a `failed` item.

## Testing

App-server integration tests cover cancellation, decline, and malformed
responses. They check that `item/completed` precedes `turn/completed`
and that paginated history returns the same command item after restart.

GitOrigin-RevId: d3d95272c8a6af2fa65fa980f312260313cc5e32
2026-11-27 15:31:18 +00:00
jif 181d051417 Fix lifecycle hook dispatch for hosted subagents (#64310)
## Why

Hosted workers keep the host's session source, so hook dispatch
can mistake them for root sessions and run `SessionStart` and
`Stop` on worker turns.

## What changed

Recognize host-managed workers by their inherited session ID and
dispatch `SubagentStart` and `SubagentStop` for them. Resolve the
parent transcript for `SubagentStop` using the immediate parent
thread ID when available.

## Testing

Add a regression test that verifies a hosted worker runs only the
subagent lifecycle hooks, receives start-hook context, and reports
its own transcript and final message in the stop hook.

GitOrigin-RevId: 272d29d275120a1b020b1a00a0db2e00402ebe06
2026-11-27 11:13:25 +00:00
felixxia-oai 58961aa3a2 Configure Guardian V3 shadow reviews from the root thread (#64187)
## Why

Shadow reviews used default routing and retrieval instructions even when
the root thread supplied Guardian V3 settings.

## What changed

- Replace `features.guardianv3_shadow` with
  `features.guardianv3.shadow_enabled` to opt into shadow reviews alongside
  Guardian V2. Project config cannot set the toggle, and feature
  requirements can override it.
- Use the root thread's routing instructions, retrieval instructions, and
  board size limit for its shadow board. Child reviewers share the root's
  board and retrieval instructions.
- Keep shadow boards in memory and skip shadow reviews when
  `features.guardianv3.message_board_in_memory` is explicitly false.

## Testing

Add coverage for shadow-only opt-in, config precedence, in-memory
enrollment, and root routing and retrieval instructions.

GitOrigin-RevId: 085089d70a66c535a86d31906ff59a449ffcb61f
2026-11-26 17:16:53 +00:00
felixxia-oai d0b140efb5 Cap evidence stored on Guardian v3 shadow boards (#64166)
## Why

Shadow routing can store the same evidence in multiple channels. A per-root
limit bounds how much evidence each shadow board accumulates.

## What changed

- Default to 32 MiB of serialized evidence per root shadow board and count
  each stored channel copy. Allow users to set
  `features.guardianv3.shadow_board_limit_mib` in user config. Ignore project
  overrides of the limit and discard positional Guardian v3 project settings
  that could bypass filtering for user-only fields.
- Reject batches that would exceed the limit before creating channels or
  appending posts. Skip the routing call when even one copy of the first
  source would exceed the remaining budget.
- Signal root and child shadow reviewers when intake stops, independently of
  reviewer cancellation. Record channel counts, post counts, and evidence
  bytes after successful batches, and tag worker failures by stage.

## Testing

Tests cover byte accounting across distinct destinations, overflow before and
after routing, an unchanged board after a rejected batch, intake stop signals
for root and child reviewers, and project config filtering.

GitOrigin-RevId: 9d908ceb6f33ba69eed2a07223b3f9177afbe11e
2026-11-26 15:22:56 +00:00
Charlie Marsh 42c320991e Add compact filesystem context for workspace-write profiles (#64164)
## Why

The filesystem context sent to the model repeats the same generated
read-only metadata entries under each writable path.

## What changed

Add the opt-in `features.compact_filesystem_context` flag. For matching
workspace-write profiles with multiple writable paths, list workspace
roots and other writable paths separately, then state the shared
read-only rule for `.git`, `.agents`, `.codex`, and `.aws` once.
Keep temporary-directory write grants explicit and use the full listing
for profiles with rules the summary cannot represent.

## Testing

Cover compact rendering and fallback for explicit metadata reads or
Windows paths with different casing. Snapshot shared and per-environment
context across two turns to verify that unchanged permissions carry
forward.

GitOrigin-RevId: 4e9f36a054a96f06c9e5d0b3882148b132233e4f
2026-11-26 15:09:58 +00:00
ioanbudea-OAI 61369c4e95 Verify manual approval provenance in Guardian transcripts (#64160)
## Why

Guardian identified manual approvals by the opening text of a developer
message. Hook output could use the same opening text, and unrelated
content in the same message could be included with an approval.

## What changed

Check each developer text part before joining it into the transcript.
Require the manual approval prefix, the `guardian.approved_action` content
kind, and provenance from the harness outside of hooks.

## Testing

Transcript tests cover missing provenance and same-prefix text with hook
provenance or a different content kind. The context budget test checks
that the full manual approval stays ahead of a later user restriction
and that adjacent hook text is excluded.

GitOrigin-RevId: 64fafc3a429ce1e21eb5233c8223228947d1c20b
2026-11-26 14:29:37 +00:00
jif 7ca4eada90 Simplify tool executor lifetimes (#64159)
## Why

Extension tools borrow host capabilities for each call. Expressing that
borrow in the executor's type argument requires higher-ranked lifetime
bounds wherever extension executors are stored or returned.

## What changed

Define the per-call input as `ToolInput::Call<'a>` so `ToolExecutor`
can use the same lifetime for the input, the executor borrow, and the
returned future while remaining usable as a trait object. Default to
borrowed `ToolCall<'a>` inputs so extension contributors can return
`Arc<dyn ToolExecutor>`. Core handlers continue to take owned
`ToolInvocation` inputs.

GitOrigin-RevId: efbf56c1e758c59a18b192d210c2ab1b368793e2
2026-11-26 14:27:37 +00:00
swastik-oai ad7176f787 Use Guardian V3 to assess recorded tool calls (#64157)
## Why

`thread/guardianReview` used the transcript reviewer even when the app
server was configured to use Guardian V3 for live approvals. Recorded
calls can now be assessed with the same reviewer as live calls.

## What changed

When Guardian V3 is enabled at app-server startup, `thread/guardianReview`
waits for pending injected history to reach the Guardian board, then
returns a fresh assessment without executing the tool call or caching an
approval. When V3 is disabled at startup, the endpoint uses the
transcript reviewer.

V3 requires a fresh, idle, non-ephemeral root thread with paginated
history and rejects `rootEvidence`. Recorded browser calls receive the
same browser policy as live calls.

## Testing

Add coverage for sequential history batches without tool execution,
unsupported thread types, routing failures and timeouts, and preservation
of the initial denial when reconsideration stalls.

GitOrigin-RevId: a8ad15cd2bb2d6d5d105c672f64c6cc71dfc6ff8
2026-11-26 14:14:59 +00:00
jif 8727186a0a Test hosted root turn suspension before roster preparation (#64128)
Extend the hosted turn admission test to suspend the root turn both
before roster preparation and during the roster read. In the new case,
hold turn startup until suspension detaches the active task so the test
exercises the initial input handoff.

Both cases assert that the admitted prompt appears exactly once in
recoverable thread history and that no model request is sent.

GitOrigin-RevId: 51a3ca65a55fb3db4547e770c3bf49a3eee59521
2026-11-26 10:57:00 +00:00
Anthony Tafoya 963d4f5717 Honor per-executor plugin settings in capability discovery (#64052)
## Why

A plugin can be installed in several executor environments. Disabling one
installation should leave the others available, while a thread-wide exclusion
needs to apply across environments.

## What changed

- In executor capability discovery V2, allow an executor to list its own
  plugin installations subject to marketplace policy. A named entry such as
  `"notes@market": {}` inherits the executor default when the thread has
  no enablement preference. A default alone does not list any plugins.
- Apply thread enablement preferences across installations and scope executor
  opt-outs to the affected installation. When MCP server names are shared,
  use the first enabled installation.
- Preserve connector mappings for explicit `disabledPluginIds` exclusions
  so Apps tool search can honor them even when the executor has already
  disabled the installation.

## Testing

Add regression coverage for marketplace filtering, thread and executor
precedence, installation-scoped exclusions, and Apps connector suppression
after an executor opt-out.

GitOrigin-RevId: d3465a38f3ebf5042d5c45dabfdb32f8ada81727
2026-11-26 02:32:11 +00:00
Eric Traut 653def34fb Preserve native exit codes in Windows PowerShell hooks (#64013)
## Why

PowerShell's `-Command` can report a native command's exit code `2` as
`1`, so a `PreToolUse` hook can fail to block a tool call.

## What changed

Use `$?` to preserve successful hook results and forward
`$LASTEXITCODE` on failure when available. Pass scripts with named
blocks through as written because PowerShell forbids trailing
top-level statements after those blocks.

## Testing

Add Windows regression coverage for a native command and a PowerShell
`end` block that each exit with code `2`. Both cases check that
`PreToolUse` denies `apply_patch` before approval, reports the denial
reason, and leaves the target file uncreated.

GitOrigin-RevId: 9668b1382bb56f168794dd8d4d2fecac13d2f649
2026-11-25 22:53:41 +00:00
sayan-oai e54baff042 Move environment selection tests into a dedicated file (#64012)
Move the existing selection, readiness, and configuration inheritance
tests into `environment_selection_tests.rs` and keep them wired up as
the `environment_selection::tests` module.

GitOrigin-RevId: 304944a8875c5d92e21bcc2ab39e760e41083d37
2026-11-25 22:53:05 +00:00
jif 44d359767f Preserve initial turn input when suspension races with startup (#64002)
## Why

Suspension can detach the active task just as startup tries to save
unrecorded input before reading the host roster. If detachment wins,
cleanup can miss the initial submission when saving the turn for recovery.

## What changed

Store pending initial input in the shared `TurnContext` during host
admission and startup steps that can wait on the host roster. Save the
input before checking whether the task is still active, so suspension
and abort cleanup can retrieve it after the task exits. Reclaim it under
the active-turn lock when startup completes so only one path records
the submission.

GitOrigin-RevId: 2f180fc372daaa8f2d8e0ebcb4787a1b2cfd61fa
2026-11-25 22:47:01 +00:00
iceweasel-oai f39c3c78d7 Initialize Statsig feature gates across Codex launch modes (#64001)
## Why

Enabling `statsig_gates` can only load evaluations if the process starts
the Statsig runtime. Several Codex entry points never started it.

## What changed

Start Statsig in standalone and embedded app servers, the TUI when it
connects to a separate app server, eligible `codex sandbox` launches, and
local and remote exec servers. This also covers `codex exec` through its
embedded app server. Use the serving or local account where applicable
and installation identity for remote execution. Share the runtime with
the embedded TUI and flush it on normal shutdown.

## Testing

Add a CLI integration test that checks which evaluation endpoint each
launch mode requests, including signed-in and signed-out sandbox launches.
Supply a bundled fixture key in Bazel and nextest CI builds so the test runs.

GitOrigin-RevId: 64df9933c1a9783a86be8712fa012b495f34b0f8
2026-11-25 22:46:26 +00:00
jif f3c6076ac2 Skip SessionEnd hooks when child threads shut down (#64000)
## Why

A hosted child thread can inherit the root session ID and use a custom
session source. The existing subagent source check can miss that child,
allowing its shutdown to fire `SessionEnd` while the root is still active.

## What changed

Before preparing `SessionEnd` hooks, skip threads whose ID does not match
the session ID.

## Testing

Extend the shutdown test to close a hosted child with an inherited
session ID before closing the root and verify that exactly one
`SessionEnd` hook invocation is logged for the session.

GitOrigin-RevId: 4c80a17724cab57003b33080482d00f3cc2afea4
2026-11-25 22:45:49 +00:00
felixxia-oai 9938ffba35 Notify extensions when Guardian policy changes the approvals reviewer (#63995)
## Why

A Guardian policy refresh can switch a running thread from Auto Review
to user approvals. Without a config change notification, Guardian's
shadow reviewers can stay active after that switch.

## What changed

Notify config contributors with the previous and updated effective
configs when a policy refresh changes the approvals reviewer. Send the
notification after releasing the session locks, even if the refreshed
policy blocks the current model.

## Testing

Extend the Guardian shadow test to refresh policy on a root thread and
its child. Verify that both receive the reviewer change, that switching
to user approvals cancels their shadow reviewers, and that allowing
Auto Review again restores the requested reviewer.

GitOrigin-RevId: fd61acf7fb161be341a63a2e867582e6c308d0dc
2026-11-25 22:42:49 +00:00
jif 06c718ae68 Remove the shadow skill ranking experiment (#63993)
## What changed

Remove the background ranking of skill candidates and the metrics that
compared those rankings with skills actually used. Drop the experiment's
per-thread state and metrics wiring.

Continue accepting `skill_search` in existing feature configurations as
an ignored compatibility key.

## Testing

Extend the feature configuration test to cover both `true` and `false`
values for `skill_search`.

GitOrigin-RevId: 9492533bdeea58d4976bc9fbcffb6b82036b7894
2026-11-25 22:41:36 +00:00
Charlie Marsh a089ec6a93 Use lightweight settings for app-server thread metadata (#63990)
## Why

Enriching loaded thread results builds a full configuration snapshot,
including an execution permission profile, just to read display settings.

## What changed

Read the configured model, reasoning effort, environment selections, and
session source directly from the loaded thread when enriching results.
The environment data still includes the working directory and runtime
workspace roots.

## Testing

Extend the core test to verify that reading display settings matches the
configured snapshot's display fields without triggering a model lookup.
Extend the app-server test to verify that thread reads and lists return
explicit runtime workspace roots.

GitOrigin-RevId: f7053554fdb0f02bebb51b4cafda2ef39e6e81a5
2026-11-25 22:40:22 +00:00
jif c6bbf8a413 Extract shared network policy types from the proxy crate (#63986)
## Why

The protocol and feature configuration crates depend on the network proxy
crate for data types. Give them a smaller dependency that contains the
shared definitions.

## What changed

Move environment network policies, domain and Unix socket permissions,
policy decisions and their sources, and credential provider definitions
into `codex-network-policy-types`. Use the new crate directly from
`codex-protocol` and `codex-features`.

Re-export the moved types from `codex-network-proxy` and keep environment
policy conversion and application, along with credential provider
validation, in the proxy crate.

GitOrigin-RevId: 8af684da746830bce45ac00135aed8052dba3824
2026-11-25 16:09:51 +00:00
felixxia-oai 06f334aa4b Add opt-in shadow intake for Guardian V3 (#63949)
## What changed

Add the default-off `features.guardianv3_shadow` flag and ignore it in
project config. When Guardian V2 handles Auto Review and Guardian V3
is disabled, enroll eligible new threads in background evidence intake
while Guardian V2 keeps making approval decisions.

Share an in-memory evidence board between the root and its child agents.
Keep shadow reviewer sessions ephemeral and suppress their events in
the parent thread. Retry failed intake startup on a later turn, and
stop shadow work when the root leaves Auto Review or shuts down.

## Testing

Cover enrollment for opted-in new threads, startup retry, child
attachment and cancellation, and the absence of an on-disk board.
Verify that project config cannot set the flag.

GitOrigin-RevId: 7c31c1d831498ba012193579123ac87779b76b85
2026-11-25 16:07:45 +00:00
felixxia-oai cc6e8a968d Use reset checks for attached Guardian V3 reviews (#63948)
## Why

Attached reviewers need to detect root history resets that can invalidate an approval. Preparing an attached review previously fetched root conversation evidence even though the reviewer did not use it for preparation.

## What changed

- Check the root history version before starting an attached review and while it runs. Local MultiAgent V2 workers resolve the currently loaded root thread, and hosted workers use the host's root snapshot.
- Skip root evidence capture when preparing or prewarming attached reviewers. Skip per-attempt evidence collection for attached observers and sessions without an evidence store. Live reviewers with an evidence store still record their verdicts.

## Testing

Add coverage for root history version changes on reset, version stability on append, root resolution after reload, and verdict recording when the first approval reuses a prewarmed reviewer.

GitOrigin-RevId: b3ff7e58883d5f72bea3d774e05ba2f678df45fc
2026-11-25 16:04:45 +00:00
felixxia-oai b144e0e239 Remove unused Guardian evidence write acknowledgments (#63942)
## Why

Guardian's public review path does not consume per-write acknowledgments. The session still needs to finish saving accepted evidence when a turn is canceled.

## What changed

Replace the acknowledgment tracker with a `PreserveReviewWrites` opt-in for Guardian root sessions. The session continues to save changed evidence across turn cancellation and waits for those writes during shutdown. Remove the append callback from `LiveThread`.

## Testing

Add a regression test that interrupts a turn while forwarded user instructions are still being saved, then checks that the instructions appear in persisted history.

GitOrigin-RevId: 01e8b2665034f46e766cb382ace99c416f29aab6
2026-11-25 15:38:14 +00:00
felixxia-oai d1e982d7eb Let Guardian V3 review actions while evidence routing is pending (#63941)
## Why

Guardian V3 approval reviews waited for the housekeeper to catch up on
conversation history before they could start. Slow evidence routing could
delay an action review, and a routing failure could prevent a verdict.

## What changed

Each review attempt, including retries, drains the reviewer's available
inbox when it reserves the reviewer. The housekeeper flushes and routes
history independently in response to thread activity.

## Testing

Cover reviews that start with an empty board or while evidence routing
resumes after a root thread reload. Verify that a revocation published
during an in-flight verdict is available to a subsequent review.

GitOrigin-RevId: f84f424b57538fa9562d8f4d47e38ce7a0a84dcd
2026-11-25 15:37:35 +00:00
felixxia-oai 34fcbc8caf Keep Guardian V3 verdicts valid across unrelated context updates (#63940)
## Why

An unrelated thread goal update could invalidate a pending Guardian V3
approval and trigger a second assessment even though the update never
reached the attached reviewer.

## What changed

Let attached Guardian V3 reviewers finish with the evidence admitted for
the current attempt. Later evidence can inform subsequent reviews. Keep
the cancellation, deadline, and root history checks for attached verdicts.

## Testing

Update the app-server regression test to change the thread goal while
an MCP approval is pending and verify that the original approval stands
after a single assessment.

GitOrigin-RevId: 6e7ffad243c7c59f0f97bdbe555886ff58531835
2026-11-25 15:36:14 +00:00
jif ecb223f525 Remove the connector dependency from codex-tools (#63929)
## What changed

Have core pass connector IDs, names, descriptions, and install URLs
through `DiscoverableConnectorInfo` for tool discovery and install
prompts. Move installation verification into the core handler, where it
checks accessibility using `AppInfo`.

Enable `serde_json`'s `arbitrary_precision` feature directly in
`codex-tools` to preserve large numbers in tool arguments and results.

## Testing

Cover install verification for accessible, inaccessible, and missing
connectors, including an accessible connector that is disabled.

GitOrigin-RevId: fd84e8e9b739d86658396e17e4dcd7b48a4b2fdd
2026-11-25 14:34:40 +00:00
jif d3ca5182df Present encrypted subagent replies as evidence in Guardian reviews (#63926)
## Why

Encrypted replies from subagents can provide evidence for a Guardian
decision. Reviewer compaction can drop those replies when it filters
descendant progress and completion messages.

## What changed

When native multi-agent history is enabled and the reviewer uses the
OpenAI provider, send encrypted replies from descendants to ancestors
as standalone `guardian.subagent_reply` tool outputs in Guardian review
and async scoring requests. Include the sender and recipient, preserve
the encrypted payload, and keep native message IDs in stored history
for deduplication.

Retain qualifying replies across reviewer compaction within the existing
per-message and shared token budgets.

## Testing

Extend regression coverage for incremental reviews, compaction recovery
with and without native agent review, and reply ID stability across
retained WebSocket scoring requests.

GitOrigin-RevId: bb46149426b1a60a6ed5cac6765283ec77682d23
2026-11-25 14:22:54 +00:00
Dylan Hurd e8fb104cd6 Make the context spill threshold configurable for MCP hooks (#63922)
## Why

MCP hooks could only use the default spill threshold. Hooks that return
larger context, such as a session-start memory hook, need a way to keep
more of that context inline.

## What changed

Allow `mcp_tool` hooks to set `additionalContextLimit` for events that
can emit `additionalContext`. Plaintext context spills to disk above
approximately 2,500 tokens by default. MCP hooks can set a threshold
from 1 to 10,000 tokens. A value of 0 or above 10,000 warns and uses
10,000. Hook trust hashes use the effective threshold.

Expose the setting in app-server configuration requirements and hook
list responses.

## Testing

Cover limit normalization, warnings, trust hashes, and app-server
reporting. Verify that a bundled memory hook with a higher threshold
injects its full context at startup and after compaction.

GitOrigin-RevId: 318704ac1532267b3eb2f138f130b6799863a5c0
2026-11-25 14:03:11 +00:00
jif 1c69d01451 Publish process exit status and exit code together (#63896)
## Why

Separate reads and writes of the exit flag and exit code could let
unified exec observe a process as exited before seeing its exit code,
or return a live session ID alongside an exit code.

## What changed

Store the exit code in a shared `OnceLock` for pipe, PTY, and
driver-backed processes. Derive `has_exited()` from the presence of
that code. Unified exec reads the code when it retires the session,
after any pending output it needs to retain has been drained.

## Testing

Extend the pipe, PTY, and driver-backed tests to check that the
process handle exposes the exit code reported by the exit notification.
The driver-backed test also verifies that output arriving after the
notification is still collected.

GitOrigin-RevId: 6192e5ceb9c71c6321e76f750c531c0ea6554dca
2026-11-25 12:06:15 +00:00
Dylan Hurd 077eab36fd Isolate Git discovery in remote apply_patch turn diff tests (#63889)
## Why

An ancestor's `.git` marker can change the repository root discovered by
the tests, which affects the paths in the emitted turn diffs. Manual
cleanup at the end of the shared-path test can also be skipped when the
test fails early.

## What changed

- Add `.git` markers to keep repository discovery within the fixtures.
- Reuse the executor's working-directory path on both filesystems and
  give the local directory a `TempDir` owner so both fixtures are cleaned
  up when the test exits early.

GitOrigin-RevId: 2534688ae1ed4aace16d47f6f58e461e546dc8ee
2026-11-25 11:50:50 +00:00
psachdeva-oai 16466d9e3a Carry prompt wellbeing results through answer moderation (#63886)
## What changed

Add optional `promptWellbeingResults` to answer moderation metadata.
Each result contains the scored input item's ID, labels, and numeric
scores. Preserve the results on live agent messages and when rebuilding
thread history, and expose them in the app-server v2 schemas and Python
SDK models.

Ignore malformed wellbeing results when reading stored moderation so
the moderation decision and its display instruction can still be applied.

## Testing

Cover serialization round trips with and without a display instruction,
and verify that older moderation records without wellbeing results
deserialize.

GitOrigin-RevId: b3ed41fb529e33638eb5486bf2a22ff8b926f82a
2026-11-25 11:48:12 +00:00