Commit Graph
6570 Commits
Author SHA1 Message Date
Charlie Marsh 8b2070d29f Centralize schema selection for config diagnostics (#62587)
## What changed

Choose the full config or shell environment filter schema inside the
diagnostics module. Config loaders call the helper for the validation
that failed without passing a deserialization type or the
`config.toml` filename. Both helpers use the same layer traversal and
source location reporting.

GitOrigin-RevId: 5dcc7984b907e3769904c303cd08577c6faf4769
2026-11-19 20:42:24 +00:00
ioanbudea-OAI 90dd6cf9df Enforce refreshed Guardian policy on running threads (#62585)
## Why

A Guardian policy refresh could leave a thread using its previous restrictions
if the new policy disallowed its current model. A refresh could also report
success after its managed policy source changed before publication.

## What changed

- Use the app server's configuration manager to load Guardian policy from
  current local and managed configuration. Report an error when the policy
  source changes before publication or a live thread rejects the update.
- Apply updated reviewer and model restrictions even when they block the
  current model. Keep automatic work queued while the model is blocked and
  wake it when a later refresh permits it. Allow a new turn to supply a
  compliant replacement model.

## Testing

Regression tests cover policy changes during thread startup and live refresh,
queued work resuming after a blocking policy is lifted, and updated policy
text reaching Guardian reviews without reconnecting MCP.

GitOrigin-RevId: c7d3e119aa409342cc2fa18946ce2b6a4392e0e3
2026-11-19 20:26:00 +00:00
jif 3869f396aa Keep async Guardian scoring active for serving probes (#62571)
## Why

A serving probe that reports no review needed can bypass async scoring.
Keeping the async path active lets Guardian compare the two signals
while using the existing approval policy.

## What changed

Treat streamed review flags as observations. Match each flag to its
response item, carry the enclosing item's flag into Code Mode tool
calls, and discard the flag when a pre-tool hook rewrites the payload.

Emit correlated `codex.guardian_probe_comparison` logs for tool calls,
async classification outcomes, and synchronous review results.

## Testing

Update integration tests to expect async scoring even when a probe
reports no review needed, and verify that Code Mode retains the probe
across yield and resume.

GitOrigin-RevId: 715f56ba4a82d544ce59f0291bcd1a84dd2daa51
2026-11-19 18:54:22 +00:00
Bryan Ashley 65454c7b99 Add OpenTelemetry for subagent lifecycles (#62567)
## Why

Correlating a subagent's creation, turn attempts, and stop requests
helps explain what happened when those actions span workers.

## What changed

- Emit structured events and counters for successful spawns and accepted
  `close_agent` and `interrupt_agent` calls. Count accepted stops even
  when the target is already idle or unloaded.
- Track initial, follow-up, and resumed turn attempts for spawned
  subagents. Record each start and at most one outcome per attempt:
  completed, failed, interrupted, or suspended.
- Use thread, turn, and call IDs to correlate structured events while
  keeping those IDs out of metric labels.

## Testing

Add coverage for lifecycle counts, duplicate outcomes, stop handling,
and event correlation across workers. Improve the Windows elevated
sandbox test for an approved `git pull` by provisioning the sandbox
before the turn and reporting setup or launch failures with diagnostics.

GitOrigin-RevId: bc1190302e1dffbdd79c7ac984b6debe1dac4a65
2026-11-19 18:39:32 +00:00
Dylan Hurd 692292695b Fix timing races in core integration tests (#62564)
## Why

Steering can cancel a paused mock HTTP stream, realtime handoff and turn
events can arrive in either order, and streaming tools can run before the
response reports token usage. Tests that assume a fixed sequence can fail
depending on timing.

## What changed

- Pause the hooks test at assistant message completion so both queued prompts
  enter the same batch before the turn resumes.
- Track the handoff and turn events in one pass, waiting for the matching
  turn to complete on the unblocked path.
- Call `get_context_remaining` during the compaction fallback and assert
  zero remaining tokens using the preceding response's usage.

GitOrigin-RevId: ec8a108517c819d7087681e8e2c7b5b57f4b341e
2026-11-19 18:22:41 +00:00
tongzhou wang 65d69f25b4 Reject overflowing rollout budget charges before posting (#62559)
## Why

An overflowing hook total could send a partial charge to the host, and
an overflow in native accounting could leave the posted balance infinite.

## What changed

Reject overflowing hook totals before reporting usage. Check both the
combined provider and hook charge and the cumulative rollout balance
before posting, preserving the previous balance on overflow. Native
budgets with limit enforcement enabled still stop new work on overflow.

## Testing

Update the hook overflow integration case to verify that the response's
tool is blocked and the host receives no usage report.

GitOrigin-RevId: 2ac80a6aa1d857924a8807df7bb70c6b7c107cd2
2026-11-19 17:46:53 +00:00
jif 4d517cce4a Preserve process state across concurrent unified exec updates (#62557)
## Why

Process lifecycle handlers could overwrite each other's updates by reading
and replacing the entire state. For example, a rejected stdin write could
restore an older snapshot after the output collector recorded an exit code.

## What changed

Apply lifecycle transitions in place under the watch channel's write lock.
Rejected stdin writes and confirmed termination only mark the process as
exited, preserving any exit code already reported by the executor.

## Testing

Regression tests cover both closed stdin and unknown-process responses.
They verify that subsequent lifecycle updates preserve the exit code and
sandbox denial recovered from the final read, and that repeated calls to
`fail_and_terminate` preserve the first failure message.

GitOrigin-RevId: f090c0860c86b6e668c31d122d986ea4f4a119b6
2026-11-19 17:33:26 +00:00
Charlie Marsh ac784eb10e Enable MCP connection sharing by default (#62552)
## Why

Local stdio discovery needs to accommodate legacy servers that return an
empty response to `server/discover`, take longer to initialize than the
discovery watchdog allows, or require `initialize` as their first request.

## What changed

Mark `mcp_connection_sharing` stable and enable it by default. Treat an
empty discovery response as an unsupported method and let legacy
initialization use the configured startup timeout. Give legacy restarts
a fresh timeout and keep modern version retries within the original
deadline.

## Testing

Cover empty discovery responses, slow initialization on the original
connection, and restarts after ignored or rejected initialization.
Explicitly select legacy mode in tests that depend on legacy behavior.

GitOrigin-RevId: 04d87ddfe02fac8491f879ce420bf294dc725128
2026-11-19 16:56:55 +00:00
jif f6a1b61912 Borrow user input in extension turn contexts (#62540)
Pass the host's existing `&[UserInput]` into `TurnInputContext` to avoid
cloning the input when building extension turn items. Use the borrowed
slice directly for skill mention detection and shadow selection.

GitOrigin-RevId: f4983b584830e481d914f0c9aa1e39e78b965a19
2026-11-19 15:46:27 +00:00
jif 0b248182be Respect app-server turn admission for agent mailbox wakes (#62537)
## Why

Automatic mailbox wakes can start new turns while the app-server is
draining or has paused turn admission. Native child results still need
to reach the parent during drain so they can survive a daemon restart.

## What changed

- Require a turn admission permit for ordinary automatic mailbox wakes
  and hold it through turn registration. Retry queued work when a
  temporary pause ends. Explicit follow-ups and native child results can
  still wake the parent during drain.
- Let `thread/inject_items` queue plain-text agent messages for native
  child threads when native tools are enabled. Injected mail follows the
  ordinary wake rules.
- Extract the remote app-server client, shared event and request types,
  and WebSocket compression into `codex-app-server-remote-client` so
  callers can use them without linking the app-server runtime.

## Testing

Cover delivery of queued mail when admission reopens, injection into
native child threads, and recovery of a child result after a daemon
restart.

GitOrigin-RevId: 4c5ceeca8829c2612cc2b6b74c03d0c7677a9244
2026-11-19 15:45:17 +00:00
tongzhou wang 27e16c08c3 Add built-in namespace guidance and budget tool description prefixes (#62534)
## Why

Namespace-wide guidance can repeat on every entry in flat Code Mode listings. The existing prefix limit covers only reachable `functions` tools, leaving indirect namespace guidance outside the budget.

## What changed

- Add `builtin_tool_namespaces` to put guidance on namespace headers in Code Mode prompts and tool search responses, including headers shared with client tools. The selector applies to namespaces with a registered built-in tool and is omitted from flat listings. Overlapping selectors must agree after trimming.
- Validate all four prefix maps together against the selected model's `description_prefix_budget_bytes`, which defaults to 512. Count each trimmed value once in UTF-8 bytes, including unused selectors. Exclude keys, paragraph separators, and rendered copies.

## Testing

Cover shared headers, flat listings, and conflicting selectors. Exercise the default budget boundary with multibyte text and verify that a model can raise the limit.

GitOrigin-RevId: 1570c23ea1dbad6041cc8e48d0dc2b77f92596c7
2026-11-19 15:31:33 +00:00
jif dabe0643a4 Avoid cloning the PostToolUse hook payload (#62532)
Take the payload from the successful tool result and pass it directly
to the post-tool-use hooks.

GitOrigin-RevId: bb7dbe82bbc7b565257b94a0473476326e60db12
2026-11-19 15:14:37 +00:00
igorrybalka-oai 1826d80eca Expose Daybreak availability in model discovery (#62499)
## Why

Clients need to distinguish a caller who must enroll in Daybreak from a
model that does not support it. The list of accepted access programs
alone cannot express that distinction.

## What changed

Carry the server-resolved status for each caller and model from the
model catalog into `model/list` as `availableAccessPrograms.daybreakAvailability`.
Update the JSON schemas, TypeScript bindings, and Python SDK to expose
the field.

Rust decoders use `default` for missing or unrecognized statuses. The
Python SDK also defaults missing statuses and preserves new strings
from newer hosts.

## Testing

Cover catalog decoding, app-server response serialization, and Python
SDK round trips with known, missing, and future status values.

GitOrigin-RevId: c1e5ddef68fd19b25e583bb6996a93fd78ab9d18
2026-11-19 12:28:34 +00:00
ioanbudea-OAI b0ecad9cf9 Refresh managed Guardian policy across Codex threads (#62496)
## Why

A thread can start while managed Guardian policy is being refreshed. Startup
and refresh need to coordinate so the thread does not register with policy
that the refresh has already superseded.

## What changed

Let hosts provide a `GuardianPolicyLoader` to `ThreadManager` for startup
and on-demand refresh. Pause thread registration while a refresh loads and
publishes policy. If publication overtakes a thread's startup configuration,
reload Guardian policy before registering the thread.

Apply the published policy to live threads concurrently. Once published, the
updates continue even if the refresh caller is canceled. Return an error if
any live thread rejects the update.

## Testing

Add regression coverage for an idle thread receiving the update while
another thread holds its session lock, and for reporting a live thread's
rejection of invalid Guardian configuration.

GitOrigin-RevId: ca0cfa2a30f0d45c4ac5ded3400e0e18177ede1d
2026-11-19 12:07:28 +00:00
felixxia-oai d52a39b307 Honor elastic budgets for attached Guardian reviews (#62489)
## Why

Attached reviews used fixed evidence limits even when elastic budgeting
was configured. This could reject a pending tool call whose exact
arguments would fit within the review request's input budget.

## What changed

Use the configured budgeting policy to prepare the pending action and
permissions for attached reviews. With elastic budgeting enabled, check
whether the exact call fits when enforcing the final request budget.

## Testing

Add a regression test for a tool call that exceeds the fixed evidence
limit. Elastic budgeting rejects it when the request budget is too small
and preserves the original call when it fits.

GitOrigin-RevId: 42cc4a8682a98badfe6be95434703500403e7118
2026-11-19 10:46:39 +00:00
Charlie Marsh 6271f35f52 Box the thread startup future in spawn_thread (#62477)
## Why

Boxing the thread startup future at each call site makes each caller
compile its own copy of the future.

## What changed

Return a `BoxFuture` from `spawn_thread` and move the startup logic into
`spawn_thread_inner`. Thread start, resume, and fork paths now await
`spawn_thread` directly.

GitOrigin-RevId: 5004651423551e173b1cc98b185c6a1dc2bc097e
2026-11-19 09:47:54 +00:00
Channing Conger 336dc645fb Use gRPC for all code-mode host connections (#62476)
## What changed

Remove the legacy framed stdio protocol and its client and server.
Local Codex launches the standalone host with `--listen grpc+stdio://`,
which is also the host's default. The `stdio` and `stdio://` aliases
now select gRPC over stdio. The `features.code_mode_host_grpc` setting
is deprecated and ignored.

Carry execution trace context into gRPC tool callbacks and
notifications. Reject oversized execute requests before sending them
so an encoding failure does not appear as a connection reset.

## Testing

Exercise gRPC callback cancellation, trace context across overlapping
yielded cells, and isolation of tool preload failures between sessions.
Check that both values of the deprecated feature setting are ignored.

GitOrigin-RevId: f5faff3901dc60958627f677f50cfad834291b69
2026-11-19 09:37:29 +00:00
ssetty-oai 083bf59b6b Send authorized connector results over Responses WebSockets (#62474)
## Why

HTTP sampling can attach private connector result bodies, but Responses
WebSocket sampling leaves them out. WebSocket requests need the same
destination and account checks before sending those bodies.

## What changed

Apply the existing HTTP eligibility checks to each WebSocket attempt and
attach only result bodies that belong to the current account and match
the input being sent, including when that input is an incremental update.
Keep prewarm requests free of private result bodies. Update
`tungstenite` and `tokio-tungstenite` to keep sensitive payload bytes
out of frame diagnostics.

## Testing

Add regression coverage for connector results reaching the server while
staying out of request observers and client logs. Cover custom-provider
requests and retries across an account change with results from both
Code Mode `exec` and `wait`.

GitOrigin-RevId: df5ec8608e59bb3a0444fafd5268279e669ccb55
2026-11-19 09:36:18 +00:00
ningyi-oai 83f73a818c Defer Git worktree status until the turn starts (#62437)
## Why

A turn interrupted during setup can be discarded before it runs. Starting
the worktree scan during setup can spend time scanning for a turn that
will never send a model request.

## What changed

Collect `HEAD` and remote URLs in the background after turn setup, and
start the worktree status scan only after the turn is admitted to run.
Model requests use the latest available Git metadata while collection
continues, and later requests can include the worktree status once it
is available.

Use shared background Git root discovery for the memory extraction
change probe and pass the resolved root into the probe.

## Testing

Regression tests cover requests proceeding while status is blocked,
later requests carrying the updated `HEAD`, remote URL, and dirty
status, and an interrupted wake skipping the worktree scan.

GitOrigin-RevId: 00f465a5621d672d8b6d9063c384fb62e493c79f
2026-11-19 06:03:09 +00:00
Oliver Tepman c764c44a05 Let extensions attach metadata to MCP tool requests (#62435)
## What changed

Add `ToolLifecycleContributor::mcp_tool_request_meta` so an extension can
use thread and turn data and the captured tool registration to attach an
entry to the outgoing request's `_meta`. Codex rejects duplicate keys.
Expose the registering plugin's package ID in `McpToolContext` so
contributors can scope metadata to that plugin.

Export `PERSISTED_MCP_RESULT_MAX_BYTES`, the existing 64 KiB limit for
untruncated MCP results in durable history.

## Testing

Extend the multi-environment MCP scenario to check that only the call
for the selected plugin receives the metadata and that the result
callback sees the same plugin context.

GitOrigin-RevId: 25a2afc5402a5c9323de184313d614aede3692fb
2026-11-19 05:37:58 +00:00
ssetty-oai 524e15989b Expand connector result metadata coverage across auth configurations (#62434)
## What changed

Pass the resolved result-body destination into sampling, where its owner
is used to select retained bodies for the turn. Check that the capture
owner is current under the retention lock before converting an MCP
result and again before retaining its body.

## Testing

Extend the request-budget integration test for direct calls and Code Mode
to check when executed calls carry result metadata. Cover ungranted and
custom endpoints, independent model credentials, hosted Apps OAuth and
header overrides, and disabled result-body passthrough. Check that the
shared configuration preserves metadata on a subsequent turn.

GitOrigin-RevId: 8e5ac88ba323d10e0f3e696d4ae356d52bdf22a3
2026-11-19 05:26:15 +00:00
ssetty-oai b5d9f7116e Include nested Apps tool results in Code Mode sampling requests (#62423)
## Why

Result body capture covered direct Apps calls, leaving eligible calls made inside Code Mode without their result bodies in follow-up sampling metadata.

## What changed

Capture eligible nested MCP results and bind them to the originating `exec` or `wait` output for the current turn. Send `tool_result` and `tool_result_call_id` together when both fit the request budget. Keep the bodies out of conversation history and reclaim capture capacity when the output binding is lost.

Require analytics to be enabled and the provider to allow request metadata before starting turn-level capture. Check the call's credentials at dispatch and again when recording the result.

## Testing

Add coverage for yielded and finished outputs, late results, retries with replacement output items, capture budget recovery, and the request size boundary for sending the body and call ID together.

GitOrigin-RevId: 0983261ac39021099d14efa5c9a9acac47ac9269
2026-11-19 03:58:29 +00:00
ssetty-oai 770c38d0b1 Reject provider query parameters for connector result passthrough (#62421)
## Why

The Responses client checks the gateway URL and request headers before
allowing connector result bodies to be attached. Provider query parameters
can also change the request while leaving those checks satisfied.

## What changed

Require an empty provider query parameter map, or no map, when selecting
a connector result destination. Check the ChatGPT credential variants
directly and retain the current auth owner for thread grant verification.

## Testing

Extend the client setup test to check that a custom provider URL is
ineligible even with refreshed ChatGPT credentials. Extend the enterprise
MCP lifecycle test to check that the configured provider receives the
account bearer token and executed tool-call metadata. Allow HTTP client
tests to cache a direct system proxy decision as well as a proxied route.

GitOrigin-RevId: 1e7e77ec6e65263eaff658ba39943ec51230d332
2026-11-19 03:58:01 +00:00
Charlie Marsh fc483d4b4d Box the future returned by response item injection (#62420)
## Why

Callers of `CodexThread::inject_response_items` each compile a copy of
its concrete future, duplicating compilation work.

## What changed

Return a `BoxFuture` from `CodexThread::inject_response_items` so the
concrete future stays in the core crate. Raise the core integration
test crate's recursion limit to 256.

GitOrigin-RevId: 2ccb280c7887278fc8011c37df35df84c47b3e35
2026-11-19 03:56:40 +00:00
Anthony Tafoya cf881a627d Enable network access in the shell snapshot filesystem test (#62415)
## Why

Remote runners can block bubblewrap from creating a nested network
namespace, preventing the shell from starting and reaching the
filesystem checks.

## What changed

Enable network access in `denied_read_in_second_workspace_root` so the
test can exercise denied reads across both workspace roots without
requiring a nested network namespace.

GitOrigin-RevId: 26eada1e5efde4a31190628f4696c6beb400454d
2026-11-19 03:03:32 +00:00
ssetty-oai d1d1ba0b83 Pass eligible connector results through to ChatGPT Responses (#62392)
## What changed

Add the off-by-default `features.connector_tool_result_passthrough` flag. For direct ChatGPT Apps calls, capture eligible text and structured content from the original MCP result before tool output processing. Attach the captured body to the matching executed-tool record on follow-up HTTP Responses requests to the ChatGPT Codex endpoint when the request uses the same authenticated account and turn.

Bound captured bodies in memory for the originating turn. Enabling passthrough alone scopes executed-tool metadata to calls with a captured result ID.

## Testing

Add coverage for same-turn HTTP delivery, omission on later turns or after an account change, and omission of shell-call metadata on HTTP and WebSocket requests when only passthrough is enabled.

GitOrigin-RevId: 410c81559bfc15022b896cf006cb631f3fd9454e
2026-11-19 01:27:01 +00:00
iceweasel-oai c332754aa3 Pause runtime sandbox integrity checks (#62389)
## Why

The telemetry-only integrity checks duplicate policy preparation already
performed by sandbox enforcement.

## What changed

Disable integrity checks at the shared entry point for exec-server and legacy
local execution. Command launches now skip integrity dependency discovery,
policy preparation, and telemetry.

## Testing

Ignore the command-launch integration cases for checker errors and timeouts
while runtime checks are paused. Keep the isolated checker tests.

GitOrigin-RevId: e29d3538e5c8fc943c1a265d75508ee904bfc166
2026-11-19 01:16:07 +00:00
ssetty-oai f1b6986416 Support optional Apps tool results in Responses requests (#62388)
## What changed

Allow callers to attach eligible Apps tool results as `tool_result` on
selected executed tool calls in Responses HTTP and WebSocket requests.
Keep text content and optional object-valued `structuredContent`, with
a 1 MiB per-result limit and a 15 MiB budget for the enriched message.

Attach results after request observers receive the original JSON. Keep
result IDs local and suppress WebSocket payload tracing for enriched
frames. Preserve the enriched HTTP body on retries to the original
endpoint and retry with the original JSON on HTTP 307 and 308 redirects.
Codex's default request construction supplies no result bodies.

## Testing

Add coverage for result eligibility and size limits, HTTP retry and
redirect behavior, and TLS fallback without forwarding the enriched
body to a redirect destination.

GitOrigin-RevId: c3f2f86f31349e40fcb699d48637c3cbbbe38837
2026-11-19 01:14:54 +00:00
Joe Savona 2d58165651 Expose custom status lines in /experimental (#62387)
## Why

Custom status lines previously depended on a feature flag in the TUI
client's configuration. When the TUI connects to a separate app server,
that flag can differ from the setting in the server's active profile.

## What changed

Add **Custom status line** to `/experimental` as an opt-in feature. Save
the toggle on the connected app server, restart the TUI, then use
`/statusline` to choose a provider.

Read `tui_extensions_statusline` from the app server's effective
configuration at startup. Keep that value when switching conversations
or reloading local status line preferences, so toggling the feature
takes effect on the next TUI launch.

## Testing

Add a menu snapshot and regression coverage for saving the toggle in a
server profile while preserving the active provider across a thread
change.

GitOrigin-RevId: 4025c9771e560d6d7b1e6bd97236bffc44201556
2026-11-19 00:59:23 +00:00
viyatb-oai e1b7558492 Prepare managed proxy settings once per sandbox command (#62386)
## Why

Proxy settings are bound to the command's execution environment. Preparing
them again at launch can overwrite the settings already bound to the
command, including credentials prepared for its shell.

## What changed

Have `SandboxManager` prepare the proxy environment and sandbox network
context together when the caller hasn't supplied a prepared route. Pass
the prepared environment through to the child and use the prepared
context for sandbox policy, including macOS Seatbelt's proxy ports and
Unix socket rules.

## Testing

Add regression coverage for preserving shell-specific credentials and
environment-bound proxy settings, reporting proxy setup errors for the
requested environment, and deriving Seatbelt rules from the prepared
route.

GitOrigin-RevId: 7a9b5822d8d53f6c93e6318a19222bf06abf0da0
2026-11-19 00:17:19 +00:00
richardopenai ab1ad9299b Skip the sandbox denial wait when unified exec output closes (#62382)
## Why

The sandbox denial check can spend 20 ms waiting for more output even
after the stream has closed and all denial context is available.

## What changed

Classify the buffered output immediately if the stream is already closed.
While the stream is open, wait up to 20 ms for new output or closure.
Register for the closure notification before rechecking the stream state
so closure during setup wakes the check.

## Testing

Paused-clock tests cover output closed before or during the check,
preservation of the timeout for open streams, and classification of
sandboxed and unsandboxed failures. The remote process-event suite adds
a direct sandbox denial case with a `process/closed` event.

GitOrigin-RevId: 1f3029055d70ff4cd63939564872fe5d37240a33
2026-11-18 23:42:25 +00:00
felixxia-oai fecf5cc672 Reconsider denials in attached Guardian reviews (#62374)
## Why

The denial reconsideration feature only applied to standalone reviews, so
attached Guardian reviews could deny an action after a single verdict even
when the feature was enabled.

## What changed

Move denial reconsideration into the shared verdict runner so attached
reviews can also take one additional sample on a denial. Keep the first
denial and its rationale if the second sample runs past the review deadline.

## Testing

Extend the app-server integration test to verify that attached reviews
sample denials exactly twice with identical input, can approve on the
second sample, and retain the first denial and its rationale on timeout.

GitOrigin-RevId: 06cc730d08dc755863f715362328aa48d15678f0
2026-11-18 21:58:11 +00:00
felixxia-oai d7c289ec25 Add opt-in in-memory message boards for Guardian v3 (#62373)
## What changed

Set `features.guardianv3.message_board_in_memory = true` to give each
new or cleared root thread an in-memory SQLite board. The housekeeper
and reviewer share the board until the last handle closes. The reviewer
can read evidence and update its own subscriptions. On-disk storage
remains the default.

With in-memory storage enabled, the attached reviewer is unavailable
on resumed roots because evidence intake starts at the end of history
and a fresh board has no earlier evidence.

## Testing

Exercise evidence catch-up and later post delivery with both storage
modes. Check that only the on-disk mode creates a database file, the
reviewer cannot update channels, and a cold resume skips evidence intake
in memory mode.

GitOrigin-RevId: 338f44720fca510b2baf40fd4b3a4b30245d4fc2
2026-11-18 21:57:35 +00:00
felixxia-oai 8bbe7c7d66 Make Guardian V3 routing and retrieval guidance configurable (#62372)
## Why

Guardian V3 uses fixed guidance for grouping evidence into board channels
and deciding when to retrieve more evidence. Longer routing instructions
also leave less room for evidence in the model's context window.

## What changed

Under `features.guardianv3`, add `housekeeper.routing_instructions` and
`reviewer.retrieval_instructions` to customize those strategies while
preserving the routing format and the reviewer's board and authorization
rules. Blank or omitted instructions use the built-in guidance.

Add an optional `max_instruction_tokens` cap that validates each custom
prompt separately using an estimated token count. Ignore both prompts and
the cap in project config. The `housekeeper.batch_timeout_ms` setting
controls the per-batch routing timeout and defaults to 90 seconds.

Size routing batches to fit the model's input window after accounting for
the prompt and response schema. Route the largest fitting prefix of whole
evidence records within the tool-output budget and leave the rest pending.

## Testing

Cover prompt validation, project config filtering, feature toggle merging,
and default retrieval guidance. Exercise custom prompts in model requests
and verify that routing reduces a batch under context pressure or stops
without advancing the cursor when even one record cannot fit.

GitOrigin-RevId: 83b3fcd23c680e90d2b2aea82a4a290633729658
2026-11-18 21:56:16 +00:00
Charlie Marsh 637c429472 Enable lazy startup for stdio MCP servers by default (#62366)
## What changed

Mark `mcp_lazy_stdio_startup` stable and enable it by default. When a
tool catalog is already cached, Codex can expose tools from an optional
stdio MCP server and defer starting the server until the first tool
call. Required servers still establish a live connection at startup.

## Testing

Exercise lazy startup with the default configuration in the tool-cache
test and explicitly disable the feature for the eager-start control.
Update the code mode and working-directory tests to proceed without
waiting for an optional server when its catalog is cached.

GitOrigin-RevId: a65d83fd1a4c141dba3c10e68b138539aa0a44f0
2026-11-18 21:30:23 +00:00
jameswt-oai 1b80bd9412 Allow per-tool approval reviewers for Codex apps (#62360)
## Why

A connected account or app can choose an approval reviewer, but that
setting applies across its tools. Users may want to review calendar
event creation themselves while keeping automatic review for other tools.

## What changed

Set `approvals_reviewer` on an individual app tool in `config.toml`:

```toml
[apps.calendar.tools.calendar_create_event]
approvals_reviewer = "user"
```

Codex matches the tool by raw name first and falls back to its title.
The tool's reviewer takes precedence over the connected account, app,
app defaults, and session settings, subject to managed requirements.
This applies to tool-call approval prompts and MCP approval requests
that match a verified app tool invocation. The app-server
`config/read` response also exposes the per-tool setting.

## Testing

Extend coverage for reviewer precedence, tool title fallback, managed
review requirements, tool-call approval routing, strict MCP elicitation,
and app-server config reads.

GitOrigin-RevId: c92bd39b9e708dada9d314c19a446b4c580edf91
2026-11-18 20:42:18 +00:00
viyatb-oai 5387162ef0 Reserve credential permission tables in Codex configuration (#62358)
## What changed

Reserve `[permissions.credentials]` in `requirements.toml` for shared
credential policy. The table currently accepts no settings and should be
omitted. Empty tables and legacy profile definitions with profile fields
produce a migration error that tells administrators to rename the managed
profile and update references. Profiles named `credentials` remain valid
in `config.toml`.

Accept an empty `[permissions.<profile>.credentials]` table in named
profiles in both files and expose it in the `config.toml` schema.

## Testing

Add regression coverage for rejecting direct and inherited selection of a
user profile through an empty managed credentials table, preserving MCP
configuration reads, and enforcing network policy inheritance checks for
legacy managed profiles.

GitOrigin-RevId: 33dcca30b37d3f07ce670967342199f5302e1d98
2026-11-18 20:30:33 +00:00
akak-oai ed9becd2fc Report why turn critical path capture is incomplete (#62357)
## Why

The `incomplete` status alone gives no indication of which timing dependency was missing or which operation prevented capture.

## What changed

Emit deduplicated `critical_path_incomplete_reasons` in turn analytics for incomplete captures. Reasons cover unsupported Code Mode and agent operations, unattributed reviews and user waits, missing turn starts, and forced teardown, with an `unclassified` fallback. External tools that share a built-in name can still invalidate capture without being classified as the built-in operation.

During interruption, use the task's join result to distinguish forced teardown from normal completion so a task that already finished can still report a complete path.

## Testing

Add coverage for analytics serialization, concurrent reason deduplication, tool name collisions, and interrupted tasks that finish normally or require forced teardown.

GitOrigin-RevId: fab9aa1ff881997a34dcf75adc5638133cedc7fe
2026-11-18 20:29:59 +00:00
Charlie Marsh 513577302a Surface Responses stream errors as soon as they arrive (#62356)
## Why

If a provider keeps an SSE connection open after reporting a failure, Codex
can hit the idle timeout and lose the original error and its retry advice.

## What changed

End the SSE stream immediately on `response.failed` or a recognized
`error` event. Classify statusless quota, plan usage, invalid prompt, and
misalignment errors consistently across both event forms. Preserve
`Retry-After` for overload and capacity errors, preferring error-level
headers over event-level headers when both provide valid advice.

## Testing

Add SSE regression tests that hold the connection open and verify immediate
error delivery, terminal error handling, and retry delays. Extend WebSocket
coverage for statusless errors received before the close handshake.

GitOrigin-RevId: 69afd1d3b18ca3139e9b7ad98ae1481a432179f0
2026-11-18 20:28:44 +00:00
Charlie Marsh c5cff4335c Treat statusless bio and cyber policy errors as terminal (#62354)
## Why

When the Responses API sends a policy rejection in an `error` event
without an HTTP status, the SSE client can wait until its idle timeout
to report the failure.

## What changed

Recognize `bio_policy` and `cyber_policy` in the shared terminal error
parser so both SSE and WebSocket clients surface the corresponding
policy error. Preserve the provider's message and use a default when
it is missing or blank. End the SSE stream as soon as the error arrives.

## Testing

Add SSE tests for both error codes, including when the stream stays
open, and WebSocket cases that verify both errors surface without a
close handshake.

GitOrigin-RevId: 1b46b6557a39a61a1bb10bdd0d8ede48ecd6fa13
2026-11-18 20:17:25 +00:00
jif 9d8ca1df71 Preserve queued agent messages when a parent turn is interrupted (#62348)
## Why

A parent turn can acknowledge a child agent's final reply while a model
request is in flight. If the parent is interrupted before consuming the
queued reply, turn cleanup can discard it.

## What changed

Record queued agent messages in conversation history during interruption
and flush the rollout before emitting `TurnAborted`, even when the
interruption marker is disabled.

## Testing

Add a regression test that interrupts a parent while a child's final
reply is queued. The test checks that the reply is persisted when
`TurnAborted` arrives and appears exactly once in the next model request.

GitOrigin-RevId: 5bd828c4101942fa4fe7ba5040355a8244f02018
2026-11-18 19:39:41 +00:00
Dylan Hurd c695d267e3 Box the config reload future for persistent MCP tool approvals (#62337)
## Why

The MCP tool call future reserves space for the large config reload
future even on ordinary calls that never reload configuration.

## What changed

Pin the reload future on the heap after successfully persisting a tool
approval. Ordinary MCP calls no longer carry the inline storage for it.

GitOrigin-RevId: a883f7619f520e730dda139d967c6a0f945b5df2
2026-11-18 19:00:47 +00:00
Alex Chang cc7a62e19c Report API spend limit errors by scope (#62329)
## Why

Generic quota errors hide whether the project or organization spend limit
blocked a request. Reporting the scope tells users which limit to check.

## What changed

Recognize API key, project, and organization spend limit errors across
HTTP, SSE, and WebSocket responses. Show a message that names the scope and
treat the error as non-retryable, even when the provider sends
`Retry-After`. Apply the existing usage-limit handling to goals and
compaction.

Expose distinct `CodexErrorInfo` values in the app-server protocol and
generated bindings so clients can identify the limit in live errors and
failed turn history.

## Testing

Extend the transport tests to cover all three scopes and verify that they
stop retries. Extend the app-server test to check that the error survives
`thread/read` and that a subsequent turn can succeed in the same thread.

GitOrigin-RevId: 03341f7a78daa7540e7baa519f1a29ec07e34509
2026-11-18 18:11:54 +00:00
bkotsopoulos 0ba514837d Measure plugin recommendation latency during initial context setup (#62326)
Record how long initial context assembly waits for prompt-only plugin
recommendations in `codex.initial_context.plugin_recommendations_wait_ms`.
Use named info-level spans for loading recommendations, reading the
tooling change marker, and fetching the recommendation catalog.

GitOrigin-RevId: 67b26f79252f8cba6e770f43df252ec1d73a569f
2026-11-18 17:57:12 +00:00
richardopenai c1ed51ca2c Accept inbound Noise connections in remote exec-server (#62325)
## Why

Remote Noise executors previously connected outbound to a rendezvous relay. An inbound listener lets harnesses that can reach the executor connect directly while retaining registry-backed authorization.

## What changed

Use `--listen ws://IP:PORT` with `--remote` in Noise mode to accept inbound WebSockets. The listener serves RPCs over encrypted Noise streams after the registry authorizes the harness. It limits concurrent connections and handshake attempts, closes sockets that miss the first authorization deadline, and drains connections on shutdown.

Noise clients can attach optional admission headers from the connection bundle to `wss://` requests.

## Testing

The inbound integration test exercises a registry-authorized file read, rejection of a registry-denied harness, the absence of a plaintext RPC response, and connection closure on shutdown. Unit tests cover handshake limits and rejection of admission headers before dialing a plaintext WebSocket.

GitOrigin-RevId: b388672e49a3fe806e38f6db38825435ba25d27a
2026-11-18 17:55:49 +00:00
viyatb-oai 6257fbc4bd Move sandbox preparation into platform backends (#62317)
## What changed

Have `SandboxManager` handle backend selection and shared preparation, then
delegate command wrapping and session setup to the Linux, macOS Seatbelt,
Windows token, and Windows MXC backends.

Centralize Windows managed proxy routing in `codex-sandboxing` so the exec
server and other callers use the same rule for selecting dedicated MXC
listeners.

GitOrigin-RevId: a75886809aefebf6c267bb39dbc104f76bda3409
2026-11-18 17:09:03 +00:00
rhan-oai daa59ebd29 Keep authorization evidence local to agent forks (#62314)
## Why

A prepared agent fork needs its ancestor's conversation for context.
Treating that conversation as the child's own authorization evidence
can attribute the ancestor's messages and approvals to the child.

## What changed

Allow host-started prepared forks that reference stored history to
inherit the root session ID. Keep ancestor messages as conversation
context and exclude ancestor authorization evidence when starting or
resuming the fork and when reconstructing sender evidence from storage.
Preserve the inherited disabled-plugin settings and the child's own
authorization evidence.

## Testing

Cover prepared forks across startup and resume, including inherited
context, plugin settings, and child-local authorization. Verify that
live and stored sender evidence both contain only the child's messages.

GitOrigin-RevId: 5c5a6547d31fe78dfad3742efb8a41df539173c6
2026-11-18 16:37:03 +00:00
felixxia-oai 924a48835d Use attached Guardian reviewers for synchronous approvals (#62309)
## Why

An attached reviewer needs to catch up on evidence before issuing a verdict. If the approval context changes during that preparation, the first verdict must still be checked against the authorization captured before preparation began.

## What changed

Bind the attached reviewer to the pending action and reserve a review session after evidence preparation. Submit the action and its permissions for a synchronous verdict, checking authorization before and after the verdict. Retries reserve a new session under the original review deadline.

## Testing

Extend the review tests to check that preparation and verdict execution share a deadline. Cover when optional synchronous review falls back to user approval after local input exhaustion and when context-limit or server failures result in denial.

GitOrigin-RevId: 0ea835ba897069d19d045605d97b58f47406a4b4
2026-11-18 16:17:57 +00:00
felixxia-oai 665b147afd Extract Guardian verdict execution and pending-action context (#62308)
## What changed

- Extract synchronous verdict execution into the Guardian review session.
  It starts the review turn, tracks evidence admission, and clears
  pending routing and context when the attempt ends.
- Add a context builder for reviewers that already have the evidence.
  It presents the exact pending action and any applicable permission
  restrictions without repeating the transcript.

## Testing

Add a composition test that checks that an encrypted tool call is
replayed unchanged with its matching evidence-only output.

GitOrigin-RevId: a0c120936c80459b0928550d23ba1137e125013c
2026-11-18 16:16:32 +00:00
jif 5a6fb36a4d Route local MCP board notifications through response item injection (#62302)
## What changed

In opt-in local MCP mode, deliver board notifications through
`inject_response_items` when the recipient uses Multi-Agent V2 with native
tools enabled. Other deliveries continue to use `Op::InterAgentCommunication`.

## Testing

Extend the HTTP board scenario to check that the parent receives exactly one
`CHANNEL_POST` agent message with the worker as author, the parent as
recipient, and the expected post preview text.

GitOrigin-RevId: deaa1451619a94d9c70c771327892069325c5e60
2026-11-18 15:38:06 +00:00