Commit Graph
12770 Commits
Author SHA1 Message Date
goodman-oai 133c11db43 Allow model catalogs to customize approval instruction headings (#57581)
## What changed

Add optional `request_permissions` and `auto_review_suffix` fields to catalog approval messages. Use them to customize the permission tool heading and introduce automatic review guidance while preserving the bundled instruction bodies and existing policy gates. Accept `request_permissions_tool` as a deserialization alias.

Limit headings to 500 UTF-8 bytes on a single line and fall back to bundled text for missing or invalid values. Complete catalog approval messages retain precedence.

## Testing

Add coverage for heading validation, serialization aliases, policy gates, fallback behavior, and complete-message precedence. Integration tests verify that model switches append the selected model's headings without rewriting history or repeating unchanged instructions.

GitOrigin-RevId: 3311591a464cc086783fe25271a352dd5a229790
2026-10-27 22:26:12 +00:00
ben zhang e343a12d5c Refactor HTTP client construction and request execution (#57575)
## What changed

Construct the direct transport explicitly in `HttpClient::new` and reuse `without_request_logging` in `new_without_request_logging`.

Bind awaited request results before matching them in transport execution and the Windows proxy retry path.

GitOrigin-RevId: 58b2524491db80ff4d7a954868c1e030a1643a9d
2026-10-27 22:03:01 +00:00
swastik-oai 83747ccc71 Add filesystem-free classification of intercepted patch commands (#57573)
## What changed

Add `MaybeApplyPatch::intercepts_command` to identify commands intercepted by exec without reading patch target files. Recognize explicit patch invocations, malformed patch bodies in those invocations, and implicit raw patches. Share implicit-patch detection with verified parsing, preserving its rejection of implicit invocations.

## Testing

Add a unit test covering explicit, implicit, and malformed patches, plus an unrelated `echo apply_patch` command, without a filesystem.

GitOrigin-RevId: 0bc9f63ca049094a2b17689f4f5585798792fe02
2026-10-27 22:02:35 +00:00
bkotsopoulos d03a6e1a6a Support Apps tool catalogs without shared snapshots (#57572)
## What changed

- Add `ConnectorRuntimeManager::without_shared_snapshot()` to keep connector catalogs local to each client and disable disk caching.
- Use the thread's own Apps discovery when snapshot sharing is disabled, preserving its catalog across turns.
- Expose `apps_tools_from_mcp_client()` to read a ready, unshared Apps client's tools without starting or waiting for discovery.

## Testing

Extend coverage for shared-cache eligibility and verify that an unshared thread waits for its own Apps discovery and uses its own tools on successive model requests, even when a peer finishes discovery first.

GitOrigin-RevId: d57ddacaede047e67c09d378c86c1aa3577ca56f
2026-10-27 22:01:13 +00:00
ztanner-oai 6562117a81 Preserve process output and control replies under backpressure (#57569)
## Why

Slow consumers can lose process output or block control replies when the in-process event queue fills. Descendants can also keep output streams open after the child exits, leaving clients unable to tell whether captured output is complete.

## What changed

- Require delivery of `process/outputDelta` and `process/exited` notifications, while allowing process request replies to proceed when event delivery is blocked.
- Exclude time spent delivering output to slow clients from the post-exit drain budget, and drain queued bytes after the deadline closes a stream.
- Keep draining after an output byte cap is reached so the child can finish writing; abort each stream's reader when its drain deadline expires.
- Add optional `outputDrainTimedOut` to `process/exited` and generated bindings. Report incomplete output separately from the child's exit code, treating a fully captured requested byte cap as complete.
- Deliver the exit notification before moving Windows console cleanup to a blocking task.

## Testing

Add regression coverage for full event queues, stalled consumers issuing process control requests, slow output delivery, inherited pipes, output caps, Windows console descendants, and compatibility with exit notifications that omit `outputDrainTimedOut`.

GitOrigin-RevId: 04cfeea5daa7c2b833cdec3f1fff7efeb4d1a86e
2026-10-27 21:51:50 +00:00
mandal-OAI 02bc25c89f Configure memory consolidation service tiers independently (#57568)
## Why

Memory consolidation inherits the session's service tier. Give background consolidation its own setting, defaulting to Standard.

## What changed

Add `memories.consolidation_service_tier` with a default of `"default"` and apply it to the consolidation agent. Normalize recognized tier aliases, including `"fast"` to `"priority"`, and expose the setting in the configuration schema.

## Testing

Add coverage for configuration parsing and alias normalization, Standard consolidation despite an Ultrafast session tier, and an explicit `"flex"` consolidation override.

GitOrigin-RevId: 58031ad56196152d212531d56e7fe9813f83317e
2026-10-27 21:51:26 +00:00
jamy-OAI f00c70f5d0 Allow catalog URL overrides for the built-in OpenAI provider (#57567)
## What changed

Allow `model_catalog_url` under `[model_providers.openai]` while preserving the built-in provider's identity, authentication, and inference routing through `openai_base_url`. Reject other non-default overrides and require an HTTPS catalog URL on an allowed ChatGPT host, without embedded credentials.

Apply the same catalog override merging when checking managed provider requirements for existing threads, preserving each thread's inference endpoint even if user defaults change.

Document the required Codex catalog format, credential forwarding, and existing discovery and access restrictions.

## Testing

Add coverage for allowed and rejected catalog destinations, preservation of built-in provider settings, and managed requirement changes. Add integration coverage for API key and ChatGPT authentication that verifies separate catalog and inference routing.

GitOrigin-RevId: 4d91ada518ebd2a09cbf6ded0ddf4b11c92b77dd
2026-10-27 21:50:08 +00:00
Benjamin Carlsson fab1a57545 Preserve rich composer content in Vim registers (#57564)
## What changed

- Retain mention targets, image paths, and collapsed paste contents when copying or deleting into the register. Pasting creates fresh element identities and image/paste labels.
- Preserve rich register contents across draft clears and composer replacement.
- Capture `Ctrl+Y` register contents for dot-repeat, restore exact mention bindings through undo/redo, and keep pasted rich objects atomic in Replace mode.

## Testing

Add composer tests and snapshots for repeated rich pastes, register handoff, undo/redo, Replace-mode Backspace, and selection replacement. Add a test ensuring register contents are omitted from debug output.

GitOrigin-RevId: d543d21fd542492af49cce01c2a673e6d3d01664
2026-10-27 21:13:45 +00:00
Brent Traut d93071fae8 Avoid retaining unneeded output items in HTTP response streams (#57563)
## Why

HTTP response streams retained copies of completed output items even when inference tracing was disabled, keeping their payloads alive until the response completed.

## What changed

Collect completed output items only when inference tracing or WebSocket last-response bookkeeping needs them. Make the last-response sender optional and create its channel only for WebSocket requests.

## Testing

Add a regression test that verifies an untraced HTTP stream releases a completed item's shared payload after delivery, while the response remains open. Update existing tracing and WebSocket bookkeeping tests for the optional sender.

GitOrigin-RevId: 7695534c6d00f3002005324c43c23bf733f01804
2026-10-27 20:42:47 +00:00
Benjamin Carlsson 33d306d457 Keep submitted prompts shaded when terminal colors are unavailable (#57554)
## Why

Terminals that do not answer the default-color probe lose the background shading on submitted prompts.

## What changed

Use an ANSI `DarkGray` background as a fallback. Keep the default text foreground when the background's RGB value is unknown, and preserve the red voice marker in terminal history and transcript selections.

## Testing

Add regression coverage for prompt shading without a terminal palette, voice marker colors under both history wrapping policies, and spoken-prompt selection contrast in compact and detailed transcripts.

GitOrigin-RevId: b8217a2ee1d37a2ea4a011faa75427c881202b82
2026-10-27 19:55:40 +00:00
Steve Coffey f088e0c4ff Allow replacing dynamic tools between model steps (#57553)
## What changed

Add `CodexThread::replace_dynamic_tools` to replace the tool catalog without starting a turn. Updates apply to subsequent model steps and future turns while preserving in-flight calls; an empty list clears the catalog.

Require host opt-in through `allow_persistent_dynamic_tool_updates` for persistent threads. Persist replacements before publishing them, restore the latest catalog on resume, and preserve replacements and explicit clears through compaction. Keep explicit resume overrides separate from the persisted catalog.

## Testing

Add coverage for pending calls during replacement, replacement and clearing across restart, compaction recovery, resume overrides, submission ordering after caller cancellation, host opt-in, and persistence failures.

GitOrigin-RevId: fd2634906895a9b72ae7892ddd9435dced45eccb
2026-10-27 19:50:41 +00:00
jimxie-oai 0d6838318f Expose and persist image generation IDs (#57552)
## What changed

Expose the backend-provided `generationId` on image-generation items and preserve it through legacy completion events, thread history reconstruction, and rollout migration. Default missing IDs to `None` for older history.

Update the generated JSON schemas, TypeScript types, and Python models to include the nullable field.

## Testing

Extend coverage for ID serialization round trips, completed-item notifications, persisted and resumed history, and legacy rollout migration.

GitOrigin-RevId: a7f06faa7ac6833417b257a535d2901c03b79135
2026-10-27 19:43:27 +00:00
rhan-oai aa854dabf5 Add model-gated literature search to standalone web search (#57542)
## What changed

Expose `literature_search_query` in standalone `web.run` when the active model lists it in `experimental_supported_tools`. Support query text, domain filters, and recency filters, and reject literature search calls for models without the capability.

Pass the active model information to extensions for each step and report literature queries as search actions in web search events.

## Testing

Add coverage for capability rejection, model-dependent schema exposure, app-server round trips with a turn-level model override, and a scenario that searches for a paper and opens the returned reference.

GitOrigin-RevId: 87ef1fadd80ca7bfc2a7642c4e443f9b9f2e0e00
2026-10-27 19:11:56 +00:00
Zack Brunson e3149ddb11 Preserve host-assigned user input IDs in Responses messages (#57538)
## What changed

Add optional `TurnInputRequest.user_item_uuid` and carry it through turn starts and steering to the recorded user message. When supplied, use `msg_input_<uuid>` as the Responses item ID; inputs without a UUID retain generated IDs. Raw response items ignore this field.

Add `ResponseItemId` helpers to construct and recognize the reserved `msg_input_` namespace.

## Testing

Add regression coverage for steered inputs with identical text and client IDs, checking that each supplied UUID survives recording and UI item IDs remain distinct. Add a scenario test verifying that the assigned ID reaches Responses and persists in subsequent request history alongside an identical ordinary prompt.

GitOrigin-RevId: 440e306bfdaa7facb69b21930c5244a83db2fdae
2026-10-27 19:00:03 +00:00
jif 4d3ed3f3b4 Release empty PID probe locks explicitly on Unix (#57533)
## Why

A concurrent fork can inherit a PID reservation probe's file descriptor and keep its lock held after the probe closes it, making a stale reservation appear active.

## What changed

Add a drop guard that explicitly unlocks empty PID reservation probes on Unix, including when inspection fails or is cancelled.

## Testing

Extend the duplicated-handle regression test to cover empty PID files, read errors, and cancellation alongside missing PID files. Verify that cancellation occurs while the lock is held and that subsequent status checks do not report an active reservation.

GitOrigin-RevId: 793569c9bcaca02900662a66c33aa48f2bebfd5e
2026-10-27 18:35:19 +00:00
swastik-oai 19d730175f Add isolated reviews to the guardian reviewer pool (#57522)
## What changed

Add `ReviewerPool::review_isolated` to run a review in a temporary session without reading or changing the reusable reviewer. Build the request context without a previous session and spawn without a cached snapshot.

## Testing

Add a test verifying that an isolated review receives no snapshot, uses a separate session, and preserves the prewarmed session for the next regular review.

GitOrigin-RevId: 6cceff0c399f30f3c3303b0bf5232c274c902e3a
2026-10-27 17:29:03 +00:00
ioanbudea-OAI 6574bcdba8 Defer synchronous Guardian heartbeat compression to preparation (#57519)
## What changed

Keep original scheduled messages and heartbeat provenance during synchronous transcript collection. Add `prepare_sync_context` to compress repeated heartbeat instructions across the complete collected transcript before selecting the requested suffix, preserving reference numbering in full and delta prompts.

Route synchronous reviewer prompts through this preparation step and reject composition of unprepared scheduled messages. Move transcript profiles and REPL evidence rendering into the preparation module. Asynchronous heartbeat compression remains in collection.

## Testing

Extend heartbeat transcript coverage to compare prepared full and delta prompts with the existing rendering and verify that direct composition rejects unprepared scheduled messages.

GitOrigin-RevId: c9824b8862021301a1f537a74f83bc7eb20aa0ad
2026-10-27 17:19:51 +00:00
Eric Traut 4c54667b40 Add profile and provider status line items (#57516)
## What changed

Add selectable `profile` and `provider` items to the TUI status line, including setup previews and theme colors. Render them as `profile: <name>` and `provider: <id>`, omitting the profile when unset and the provider until a thread is active. Accept `model-provider` as an alias for `provider`.

## Testing

Extend status line tests to cover omitted values, the active thread's provider, provider updates, and a selected profile. Update the setup popup snapshot to include both items.

GitOrigin-RevId: e7cbb7fb1e7017cfbd6ee71e1df7d0ddb1836ed4
2026-10-27 17:08:08 +00:00
iceweasel-oai 77f0cbfdd5 Limit MXC volume expansion probes to symbolic links (#57515)
## What changed

Use directory-entry file types when expanding volume-root grants, and resolve metadata only for symbolic links. Skip links whose targets cannot be resolved, while preserving grants for ordinary children and valid links.

## Testing

Extend the volume-expansion test to cover dangling and self-referential links alongside an ordinary file, a valid symbolic link, and an explicit deny grant.

GitOrigin-RevId: 8acb4072a1f5edd4351738b5780ac659fdf94f01
2026-10-27 17:07:43 +00:00
dhruvgupta-oai d257beb16a Add experimental ChatGPT workspace switching to app-server (#57514)
## What changed

- Add `accountSession/list` and `accountSession/switch` for the active managed ChatGPT login, with optional workspace membership refresh.
- Validate membership and workspace policy, pause new turns, and unload running threads before switching credentials. Notify clients with `thread/closed` and `account/updated`; selecting the current workspace leaves threads running.
- Support browser sign-in for SSO through `allowBrowserLogin`, binding the callback to the requesting login and workspace. Require a separate sign-in for government workspaces.
- Preserve the selected workspace across token refresh and conditionally restore the previous workspace if routing validation fails. Guard credential writes against concurrent login or logout changes.

## Testing

Add app-server and auth tests covering workspace switching, credential preservation, policy and identity rejection, conditional rollback, stale sessions, and SSO callback validation.

GitOrigin-RevId: 1234abc33b71e69b66318da3e201fccc08867906
2026-10-27 17:04:16 +00:00
Michael Bolin 27ace641fe Replace the npm wrapper with the native binary using execve (#57513)
## Why

Replacing the Node process lets the native binary receive signals and report its termination directly.

## What changed

- Use `process.execve` on non-Windows platforms when available, preserving CLI arguments and the prepared environment.
- Install a `SIGXFSZ` handler before replacement so the native binary gets the default signal disposition instead of inheriting Node's ignored signal.
- Retain asynchronous spawning for Windows and older Node versions.

## Testing

Extend the exit-status test to check that `execve` leaves no child process and that `SIGHUP` and `SIGXFSZ` terminate it with the original signal, while retaining coverage for the spawn fallback.

GitOrigin-RevId: 7437f15af419fce5b10c1c00425c7d38160991fc
2026-10-27 16:55:48 +00:00
jif 5a361b5596 Explicitly unlock daemon PID reservation probes on Unix (#57512)
## Why

A concurrent fork can inherit a PID reservation probe's file descriptor and keep its lock alive after the probe closes it. This can make the app-server daemon appear to be starting even when no live startup reservation exists.

## What changed

Explicitly release the probe's lock on Unix before returning that no reservation is active, and propagate unlock failures.

## Testing

Add a regression test using a duplicated file handle to simulate fork inheritance and verify that the probe leaves the daemon inactive. Extend coverage to confirm that a held reservation still reports `Starting` when the PID file is missing, and include pruning results in release-retirement assertion failures.

GitOrigin-RevId: ecc58df1fe5cadecb6ed658352f1300c39237358
2026-10-27 16:50:34 +00:00
jif 73bdd06fed Extract Guardian planned-action assembly into the reviewer crate (#57509)
## What changed

Move planned-action construction from the core Guardian prompt builder into the exported `codex_guardian_reviewer::build_guardian_planned_action` helper. Keep the existing action kinds, MCP tool and connector descriptions, and reason selection unchanged.

GitOrigin-RevId: 119323523ed2e199c998c1139fb8e6255bc730d9
2026-10-27 16:37:01 +00:00
Joe Savona 2d1984b9f7 Add a bounded V8 runtime for UI plugin processes (#57508)
## What changed

- Add `--codex-ui-plugin-process` to `codex-code-mode-host` and a typed protocol for initializing, invoking, and closing UI plugin isolates.
- Support persistent module state and string results from synchronous or promise-based exports across up to 32 isolates in one helper process.
- Require sandbox-enabled V8 with JIT disabled, restrict executable loading and globals, and enforce execution deadlines and per-instance queue, source, result, and promise limits.
- Close affected isolates on script failures, cancellation, or overload, and return bounded script diagnostics.
- Bump the helper handshake to version 3 and increase the maximum frame size to 1 MiB.

## Testing

Add wire-level integration tests and runtime unit tests covering promise settlement, cancellation, loading restrictions, diagnostics, failure isolation, capacity reuse, transport bounds, and watchdog synchronization. Add CLI tests for argument validation before helper startup.

GitOrigin-RevId: bad6a57c84d9197c1fd76a78cf060502c5bc8bb8
2026-10-27 16:36:32 +00:00
swastik-oai a43fffca74 Resolve Guardian command path conventions inside ReviewAction (#57507)
## What changed

Move executor path-convention selection from the approval caller into `ReviewAction::from_approval_action`, using the supplied `GuardianReviewContext`. Preserve Windows and POSIX rendering based on the executor OS, with path inference for legacy executors that do not report an OS.

## Testing

Update the command approval test to exercise `ReviewAction` with Windows, Linux, and legacy executor contexts, checking both approval JSON and assessment working directories.

GitOrigin-RevId: b13fad1d4033976cb94b899b62a3779c97e171fa
2026-10-27 16:36:04 +00:00
jif 479f7046eb Move Guardian request mappings into the reviewer crate (#57506)
## What changed

Move approval-request assessment and analytics mappings, target item lookup, and turn ID selection into `codex-guardian-reviewer`. Export the helpers from the crate and re-export them in core, preserving existing behavior.

## Testing

Move the apply-patch serialization test into the reviewer crate. It checks that Windows paths are preserved and patch text is omitted from the assessment action.

GitOrigin-RevId: 3a011db0bc51c653bb0877c4b0cb52eb61c63244
2026-10-27 16:28:42 +00:00
Eric Traut c8e73bf719 Use the native clipboard for WSL SSH sessions with X11 forwarding (#57504)
## Why

Copying in a WSL SSH session with X11 forwarding should use the forwarded display's clipboard instead of writing to the Windows host clipboard.

## What changed

Treat a nonempty `DISPLAY` in an SSH session as X11 forwarding and bypass the Windows clipboard backend on WSL. Keep terminal clipboard forwarding in place.

## Testing

Add a regression test that verifies a WSL SSH session with X11 forwarding uses the native clipboard without invoking the Windows clipboard backend.

GitOrigin-RevId: 29f98dc39e5851d63d0459a55e234346167da26f
2026-10-27 16:22:08 +00:00
Eric Traut 615a8c98d6 Fix macOS standalone release pruning (#57503)
## Why

macOS `lsof +D` can return status 1 even when it finds open files, causing release cleanup to be skipped. It can also escape non-ASCII installation paths, preventing full-path matching from recognizing releases in use.

## What changed

Accept `lsof` status 1 while preserving matches, and continue to reject other failures or any stderr. Match the installer-owned ASCII path suffix on macOS and recognize processes whose working directory is the release root. Apply these checks before and after moving a release for deletion.

## Testing

Add coverage for `lsof` exit statuses, output, and errors. Exercise release retention with a non-ASCII installation path and, on macOS, a process holding the release directory open.

GitOrigin-RevId: 06181467c7d1bb256b6781241a444976b890d7c9
2026-10-27 16:21:43 +00:00
Eric Traut f40f3dfeb9 Preserve local image attachments when restoring killed text (#57502)
## Why

Restoring killed text should restore its local image attachments along with their placeholders.

## What changed

Keep image paths in the composer's kill buffer, including across composer replacement, and restore attachments with fresh labels when text is pasted back. Preserve plain-text insertion in Vim Replace mode so per-character recovery continues to work.

## Testing

Add regression coverage for restoring images after submission, transferring the kill buffer between composers, and preserving existing images and Backspace recovery in Vim Replace mode.

GitOrigin-RevId: 9bc052a1b372d5a1245ddc54c7ffafee4a637494
2026-10-27 16:21:15 +00:00
Eric Traut b07a347381 Render escaped percent signs in TUI math (#57501)
## What changed

Recognize `\%` as a literal `%` in inline and display math, so expressions such as `$3.8\%$` render as `3.8%`.

## Testing

Extend inline and display math snapshots to cover escaped percent signs, including an inline expression with multiplication and a fraction.

GitOrigin-RevId: a0f9935dc8492fe1cd5a0d33d62930c48c5433b8
2026-10-27 16:20:45 +00:00
Alex Daley 2edc8dcb0c Add an option to omit descriptions from skill catalogs (#57500)
## What changed

Add the disabled-by-default `omit_skill_descriptions` feature flag to omit descriptions from model-visible host, executor, and cloud skill catalogs while retaining names and locators. Adapt catalog introductions, usage instructions, and alias budget accounting to the selected policy.

Persist the description policy in catalog snapshots and refresh usage instructions when it changes. Ignore description-only edits in catalog deltas while descriptions are omitted.

## Testing

Add coverage for alias token budgets, policy changes with older snapshots, and suppressed description-only updates. Extend scenario snapshots to cover plugin visibility and catalog deduplication with descriptions omitted.

GitOrigin-RevId: 5bf1dcee8c04059c7a78998affc1efcdef8ec883
2026-10-27 16:16:17 +00:00
ioanbudea-OAI 603a7baff0 Centralize synchronous Guardian context preparation (#57494)
## What changed

- Retain captured root conversation sources until synchronous preparation applies request limits. Keep asynchronous snapshots limited to the bounded messages.
- Move approval-reason truncation and tool-description escaping and truncation from composition into preparation.
- Extract synchronous image preparation and admission into `guardian-context`, preserving the prompt token cap and model context-window checks.

GitOrigin-RevId: d3a864c77d8f16bd3e77df436d80c4d2738c43cc
2026-10-27 15:53:50 +00:00
jif 6b56106ed9 Move Guardian action JSON formatting into the reviewer crate (#57493)
## What changed

Move approval request serialization and model-visible action formatting from `codex-core` into `codex-guardian-reviewer`, expose both helpers publicly, and re-export them from core. Preserve the existing JSON shapes and formatting.

## Testing

Move the MCP tool-call and network-access trigger serialization tests into the reviewer crate, retaining coverage for omitted optional fields and Windows path rendering.

GitOrigin-RevId: c0093c023b2f4c1be16bac481f1173a5da6ac25c
2026-10-27 15:49:32 +00:00
jif 3b600d0566 Move guardian prompt composition into the reviewer crate (#57488)
## What changed

Export `GuardianPromptItems` and `compose_guardian_prompt` from `codex-guardian-reviewer`, and delegate prompt composition from core to the new helper. Core continues to collect context sections and choose the history version.

Preserve full and delta transcript selection, empty-transcript placeholders, cursor accounting, and Node REPL evidence sequencing.

GitOrigin-RevId: e3e2b2a87a42709ddb5441f47cbb7461b0130579
2026-10-27 15:39:10 +00:00
Charlie Marsh dddc3c0a79 Skip unrelated indexed rollouts during selected thread migration (#57483)
## Why

Migrating selected threads reads rollout headers even for unrelated threads. Use the state database to skip files whose indexed owner and canonical filename agree that they belong to an unselected thread.

## What changed

- Read thread IDs and rollout paths without creating or migrating the state database, and fall back to header inspection if the index cannot be read immediately.
- Keep inspecting selected, unindexed, misnamed, and conflicting paths so rollout headers still determine ownership.
- Recognize stable thread IDs in reverted rollout filenames and match plain and compressed paths when filtering.

## Testing

Add a regression test covering pruning of unrelated indexed rollouts, including archived and compressed files, while retaining header inspection for selected and ambiguously named files.

GitOrigin-RevId: d76827174c00f5bc9e38ad9b69dadeee91f4415f
2026-10-27 15:19:58 +00:00
jif 75667b341a Move Guardian approval request types into the reviewer crate (#57478)
## What changed

Export `GuardianApprovalRequest`, `GuardianNetworkAccessTrigger`, and
`GuardianMcpAnnotations` from `codex-guardian-reviewer` and re-export them in
core. Move environment lookup and scope classification with the request type,
preserving existing classification and credential-safe debug output.

GitOrigin-RevId: 5253a5124d5e370a1230b46aa7dc48b24b1c902e
2026-10-27 15:01:35 +00:00
jif e344f4b6fc Move Guardian session helpers into the reviewer crate (#57476)
## What changed

Move Guardian session-source detection, the reviewer name constant, and parent-thread prompt cache key generation into `codex-guardian-reviewer`. Re-export them from core, preserving existing behavior.

## Testing

Move the existing prompt cache key test into the reviewer crate, retaining coverage for parent-thread scoping, key length, and missing or inapplicable inputs.

GitOrigin-RevId: c14b3c030ba93676a0799aba56b23a676dbbc56d
2026-10-27 14:56:16 +00:00
jif 6b3b67d71f Test encrypted native call history across Guardian reviews (#57474)
## What changed

Extend the incremental Guardian review scenario with historical encrypted `send_message` calls in the default and custom tool namespaces. Add snapshots and assertions that both reviews retain each call and parent reply exactly once, in order, preserving call IDs, namespaces, and encryption metadata with a paired evidence-only output.

Verify that successive reviews reuse the same thread and append to the previous input. The scenarios use mocked ciphertext and decisions to check transport behavior, not backend decryption or authorization outcomes.

GitOrigin-RevId: a0927531b6cdae496fefa2a7f35032f7413807b6
2026-10-27 14:48:48 +00:00
jif b89952d582 Fix guardian handoff mocks for native history tests (#57468)
## What changed

Add mock guardian approvals for setup handoffs in `handoff_scenario` when native multi-agent history is enabled. Match only the trailing `function_call_output` so historical handoffs cannot consume the final command's separate denial response.

Require five approval requests with native history enabled and none with it disabled.

GitOrigin-RevId: 7b14c97aa85adc63c4d3bf95014c44831eae1c85
2026-10-27 14:28:15 +00:00
swastik-oai 2ebf42f269 Always put Code Mode tool descriptions before namespace descriptions (#57462)
## What changed

Make tool descriptions precede namespace descriptions in Code Mode execution and tool search. Mark `code_mode_tool_description_first` as removed and simplify cached definitions to depend only on the input schema budget.

## Testing

Update Code Mode integration assertions and catalog snapshots to expect tool descriptions before namespace descriptions.

GitOrigin-RevId: 1344d4c264d1d2b18ee0388a064b6813ca81f770
2026-10-27 14:14:16 +00:00
jif 50983c7a93 Move Guardian token usage calculation into the reviewer crate (#57458)
## What changed

Export `token_usage_delta` from `codex-guardian-reviewer` and use it in the core review session. Preserve the existing calculation, including clamping negative deltas to zero.

## Testing

Move the existing nonnegative token usage delta test alongside the helper in the reviewer crate.

GitOrigin-RevId: fcfce24b8d50a63dcd1122a4204939bc6750feda
2026-10-27 14:01:44 +00:00
jif 90de7b92b6 Centralize Guardian classification of multi-agent tool calls (#57455)
## What changed

Add `GuardianScope::for_multi_agent_tool` and use it for both tool review requirements and asynchronous scoring. Classify `spawn_agent`, `send_message`, `followup_task`, and `interrupt_agent` as native tools when they match the configured namespace, accepting default namespace spellings when none is configured. Keep review enablement checks at each call site.

GitOrigin-RevId: 9180ccdc629532f6c171d899dc5881e15b447141
2026-10-27 13:55:51 +00:00
Tom Leach (@toml) 6a6e2fb1f0 Distinguish policy-restricted capacity failures from server overloads (#57452)
## What changed

- Recognize `policy_capacity_unavailable` in HTTP and streaming API errors and expose it as `policyCapacityUnavailable` through the app-server protocol and generated bindings.
- Display “Policy-restricted capacity is unavailable. Please try again later.” while preserving overload retry behavior based on `Retry-After`.
- Handle the new error in TUI overload rendering, reviewer retries, and error telemetry.

## Testing

Add coverage for HTTP and streaming error classification, retry advice, WebSocket terminal error attribution, protocol serialization, and TUI rendering with and without an upstream message.

GitOrigin-RevId: 1b9536fba1e11cc891dcf689aee35410d82f5412
2026-10-27 13:31:38 +00:00
jif 824b7666fb Route state-changing multi-agent calls through Guardian review (#57451)
## What changed

When `GuardianNativeMultiAgentHistory` is enabled, require Guardian review for wrapped Multi-Agent V2 calls to `spawn_agent`, `send_message`, `followup_task`, and `interrupt_agent`.

Include these calls in Guardian's asynchronous native-tool scoring scope, honoring the configured multi-agent namespace and preserving that configuration across overrides.

## Testing

Extend the incremental-review scenario with an encrypted, namespaced `send_message` call. Verify that the encrypted parent reply remains present exactly once in both Guardian reviews and the subsequent agent request, and update the snapshot to cover native tool-call review evidence.

GitOrigin-RevId: 2af9561b0d69af4a8f878fa32365ce845368e02d
2026-10-27 13:21:20 +00:00
jif eec8bde1e9 Preserve native multi-agent calls in Guardian review history (#57448)
## Why

Native multi-agent calls must stay intact for backend decryption during Guardian review.

## What changed

When `guardian_native_multi_agent_history` is enabled for multi-agent v2, preserve `spawn_agent`, `send_message`, `followup_task`, and `interrupt_agent` function calls in the configured tool namespace as native transcript items. Use `functions` when no namespace is configured.

Include the paired evidence-only output in token accounting, and omit native evidence whole when limits require it.

## Testing

Extend transcript tests to cover native call ordering, paired-output budgeting, and whole-item omission. Add a native-history snapshot alongside the existing text-history delegation handoff scenario.

GitOrigin-RevId: e7d9b4f5ea772890bf14b79fdb53b0f9d0a842e4
2026-10-27 13:02:57 +00:00
jif a5ef02e561 Add Guardian native multi-agent history feature flag (#57441)
## What changed

Register `guardian_native_multi_agent_history` as an under-development feature,
disabled by default, and expose it in the configuration schema.

GitOrigin-RevId: d434750c1aa0cc78b36d1d661a4df0def5426f02
2026-10-27 12:28:07 +00:00
jif e1dd7ed1ba Preserve Guardian request metadata with custom OpenAI base URLs (#57439)
## Why

Custom OpenAI base URLs caused Codex backend authentication to lose Responses headers and Guardian metadata when the URL did not match a recognized backend route.

## What changed

Apply model-scoped Responses headers, Guardian reviewer and classifier markers, and eligible ChatGPT parent credit requests based on the OpenAI provider and authentication configuration, regardless of the base URL. Keep API-key requests and other providers excluded from this behavior.

## Testing

Extend coverage for custom `/v1` URLs and direct `/api/codex` endpoints with ChatGPT, header-based, and API-key authentication, including HTTP fallback and WebSocket requests.

GitOrigin-RevId: cc4bb5b4a1a6596904ecf8965237c7a4f09e112b
2026-10-27 12:17:14 +00:00
swastik-oai 5557e08853 Carry prepared commands through unified execution (#57438)
## What changed

Pass `PreparedExecCommand` through the process manager and runtime instead of copying command, shell, environment, and permission fields into separate request structs. Move approval requirement evaluation and approval action construction onto the prepared command, and use it for shell snapshots and launch failure events.

GitOrigin-RevId: 3e9f87e0974218fea6fffc0f7740616d696b9800
2026-10-27 12:12:55 +00:00
swastik-oai aeb6b22c8b Extract unified exec command preparation into a reusable module (#57435)
## What changed

Move argument parsing, working-directory and shell resolution, permission validation, and command lifetime setup into `unified_exec::preparation` with crate-visible parsed and prepared command types.

Update `ExecCommandHandler` to use the extracted preparation flow, preserving implicit skill event emission between parsing and preparation.

GitOrigin-RevId: 79e9be5d87c1b0ab905afdf1e343ac141fb7d4c6
2026-10-27 11:42:38 +00:00
jif ed1b92fa45 Add opt-in synchronous Guardian review for native tool calls (#57433)
## What changed

- Add `CoreToolRuntime::requires_guardian_review` to review opted-in function calls before dispatch and stop execution when review rejects the call.
- Deliver proposed calls as native review evidence, preserving encrypted argument metadata. When hooks rewrite arguments, review the updated arguments and discard the original encrypted replay content.
- Deduplicate native call evidence against reviewer history and include paired evidence outputs in input budgets.
- Keep review accounting and metrics for native calls without emitting action-specific client assessment events, and omit approval payloads from debug output.

## Testing

Extend regression coverage for rewritten native calls across review retries, denied calls that never execute their handlers, oversized native evidence, and review metrics without client events.

GitOrigin-RevId: c3b22c0220344581c2b38f233001abaed49cba34
2026-10-27 11:37:24 +00:00