Commit Graph
6074 Commits
Author SHA1 Message Date
Charlie Marsh 575cc5351e Fix app-server thread listener startup and shutdown races (#57787)
## Why

A thread runtime can shut down while listener setup is awaiting I/O, and a cold resume can start before the previous listener forwards `ShutdownComplete`. Listener replacement must preserve those buffered terminal events.

## What changed

- Coordinate listener installation and connection subscriptions with pending unloads, and reject closing or replaced runtimes.
- Allow a newly created runtime that has already shut down to drain its queued events, while enforcing one event reader per runtime.
- Track shutdown draining with a shared watch channel so cold resume and runtime replacement wait for terminal events to be processed.
- Serialize idle unloading with goal edits and cold resume, and recheck thread state after acquiring the lock.

GitOrigin-RevId: d05e348b0a81bddb2defa963d0cfd3fde08dbd03
2026-10-28 16:53:55 +00:00
aakash-oai 5fdb50af95 Restrict code-mode host replacement to session admission (#57782)
## Why

Automatic gRPC reconnection could spawn a replacement host while dispatching an RPC for an existing session. Host loss must remain visible so recovery can report lost state without replaying execution or completed external effects.

## What changed

- Bind each local host channel to one child process and allow only `OpenSession` to replace a dead host.
- Add caller-owned transport support to `GrpcCodeModeSessionProvider` and map local transport failures to `Unavailable` so initial connection failures use the existing bounded admission retries.

## Testing

Add regression coverage for child exit during initial connection and between channel selection and dispatch, concurrent session recovery, and child reaping after teardown. An integration test kills the host after a command completes and verifies that recovery reports the reset, clears stored state, and leaves the command's external effect unchanged.

Increase the remote MCP stalled-handshake test's initialization timeout and mock response delay to let requests reach the server on loaded CI workers.

GitOrigin-RevId: 4ffd810e4cfcfb7a56e606816aa867bc206a09b6
2026-10-28 16:46:41 +00:00
ioanbudea-OAI 5c0e42161e Respect model catalog origins when selecting Guardian reviewers (#57770)
## Why

A bundled reviewer entry does not establish that a custom gateway offers that model. Guardian should fall back to the parent model when the reviewer is neither advertised by the provider nor explicitly configured.

## What changed

Track model metadata origins as `Bundled`, `Provider`, or `ExplicitConfig`, including across catalog merges and cache reloads. Exclude bundled entries from Guardian reviewer selection unless `auto_review_model_override` is set. Continue selecting reviewers from provider and explicitly configured catalogs.

## Testing

Add coverage for gateway reviewer selection with each catalog origin, plus origin tracking across cache reloads, empty provider responses, and authentication changes.

GitOrigin-RevId: f8bf865d406e56ee0ade90087b55f2e33b98181e
2026-10-28 16:00:30 +00:00
jif 7c11b8074d Include terminal launch commands in Guardian stdin reviews (#57758)
## Why

Guardian's `write_stdin` approval requests lacked the command used to launch the receiving terminal, leaving reviews without that context.

## What changed

- Carry `original_command` from the terminal's launch command into the approval request and Guardian action JSON. This describes the original launch, not the terminal's current state.
- Exclude `original_command` from the 8,000-byte stdin approval size check so launch context does not consume the budget for input, permission details, and the approval reason. Launch context remains subject to Guardian's normal request budget.

## Testing

Extend serialization coverage to check `original_command` and the strict stdin review integration test to verify that a launch command longer than 8,000 bytes reaches Guardian intact.

GitOrigin-RevId: cc765a6bf80d080baf94c959eafa6227b2889e1f
2026-10-28 15:10:52 +00:00
jif fc916a22b5 Expose Guardian assessments in response streams (#57757)
## What changed

Decode `response.metadata` Guardian assessments into typed `GuardianAssessment` events over SSE and WebSocket, carrying `response_id`, `item_id`, and `requires_review`. Ignore assessments with missing, empty, or incorrectly typed required fields while preserving independent delivery of other metadata.

Expose the assessment type to request-scoped extension interceptors. Keep assessments out of conversation history; they do not authorize tool execution.

## Testing

Add SSE coverage for assessment ordering, malformed metadata, and mixed metadata delivery. Extend model request tests to cover SSE and WebSocket interceptor delivery and exclusion from subsequent model input.

GitOrigin-RevId: 282b8817ee97346d76b40bcb412eef023df60ff1
2026-10-28 15:04:29 +00:00
jif ce2d47bdc4 Move Guardian MCP elicitation helpers into the reviewer crate (#57743)
## What changed

Extract MCP approval elicitation parsing and review-decision response conversion from `core/src/session/mcp.rs` into `codex-guardian-reviewer`. Export the helpers and `GuardianElicitationReview` for the session code to use, while keeping session lookup, provenance checks, and approval enforcement in the host.

## Testing

Move the existing elicitation tests into the reviewer crate, retaining coverage for request construction, opt-in requirements, unsupported forms, decision mapping, and model-specific timeout instructions.

GitOrigin-RevId: fb745fa0e49a29f015bbda16c14b5fc2b12278b9
2026-10-28 13:56:17 +00:00
jif 6c839b3694 Separate test-only Rust sources from Bazel library and binary inputs (#57741)
## What changed

Add `unit_test_srcs` to `codex_rust_crate` to exclude test-only modules from library and binary sources while making them available to unit tests through `compile_data`.

Configure `codex-core` and `codex-tui` to use this option for their test modules and support files.

GitOrigin-RevId: 437b5ddb75e66a96f3c5cb9b309cb0e2608ba169
2026-10-28 13:53:43 +00:00
ioanbudea-OAI 5fd36fc550 Remove free_guardian configuration from Guardian tests (#57729)
Remove `[features.guardianv2].free_guardian` setup and test parameters
from the Guardian review suite, along with redundant opt-in cases.
Retain coverage for authentication-dependent requests, HTTP fallback,
and session prewarming and reuse without explicitly setting the flag.

GitOrigin-RevId: ba1f985ae2f7f0e0b0c8b32cb47ac9993cbb43f2
2026-10-28 13:16:05 +00:00
jif 5d5e5c507d Move ReviewAction into the Guardian reviewer crate (#57720)
## What changed

Export `ReviewAction` and its conversion from `GuardianApprovalRequest` from
`codex-guardian-reviewer`. Keep host-specific approval preparation and environment
validation in core as standalone functions, and update callers accordingly.

## Testing

Move the `write_stdin` serialization and tool-call provenance test into the
reviewer crate, preserving coverage for input, Windows working directories, and
sandbox permission modes.

GitOrigin-RevId: 9a1caf9bbb67ba017e4950a2da9ef2543b013007
2026-10-28 12:31:24 +00:00
jif e742db9f7b Preserve parent routing affinity for Guardian reviews (#57710)
## Why

Shared routing cookies can change after a parent connection is established. Guardian reviews need the routing affinity captured with their parent response so unrelated traffic does not replace that hint.

## What changed

- Capture `__oailb` and `__cflb` cookies from successful ChatGPT WebSocket handshakes and pair them with the parent response ID.
- Retain the snapshot throughout a review and its retries, and apply it only to Guardian requests with the matching parent response. Reconnect cached reviewer sockets when the parent affinity changes.
- Preserve cookie expiry and restrict reuse to the original secure origin and endpoint path. Replace routing cookies while retaining unrelated cookies, and keep the captured affinity out of prompts, history, and serialized metadata.

## Testing

Add coverage for cookie scope, expiry, duplicate rejection, and merging; replaying a captured pin after shared cookies change or are deleted; and retaining the matching parent snapshot through compaction without exposing cookies in review prompts or metadata.

GitOrigin-RevId: d180679e6265b612a3617f20ca1f5dec89e73aa8
2026-10-28 11:48:00 +00:00
jif e6de6a2423 Move Guardian review evidence into the reviewer extension (#57702)
## What changed

Move review evidence storage, authorization snapshots, sender exchange selection,
and bounded Node REPL evidence into `codex-guardian-reviewer`. Update core to
call or re-export these APIs while retaining host-specific context rendering and
capture-mode selection.

Move the existing Node REPL evidence and text truncation tests alongside their
implementations in the reviewer crate.

GitOrigin-RevId: d851cd353cf9f31eb47ce13f43f6f935dc2f5d93
2026-10-28 11:25:13 +00:00
jif 13b0217567 Move Guardian context policy and prompts into the reviewer extension (#57698)
## What changed

Move `GuardianContextMode`, parent compaction checkpoint policy, and reviewer instruction assembly into `codex-guardian-reviewer`. Export the conversation-history prompt and follow-up reminder from the same crate, and update core to use these shared definitions.

Keep session-specific authorization version lookup in core while preserving existing context selection, checkpoint validation, and prompt behavior.

GitOrigin-RevId: a4cadb6c8ad95e756467316b7d8658e8cd527b24
2026-10-28 11:02:51 +00:00
jif d09a5cd8cf Move Guardian review state into the reviewer extension (#57697)
## What changed

Move review state, fork history, checkpoint recovery bookkeeping, and Node REPL evidence admission into `codex-guardian-reviewer`. Expose helpers for session initialization and snapshot publication, and update core to delegate to them while preserving the existing review logic.

GitOrigin-RevId: 56d6a0124301a3c70908614d4bc3bfe970ac1c85
2026-10-28 11:01:32 +00:00
ioanbudea-OAI f021168bde Wait for turn profiles before asserting sampling counts in trace tests (#57692)
## Why

`ShutdownComplete` can arrive before detached task cleanup records and exports `codex.turn_profile` events, causing the turn phase trace test to read incomplete profile counts.

## What changed

Poll exported spans until the expected number of profiles is available, with a 10-second timeout, before asserting sampling request and retry counts for reply and interrupt cases.

GitOrigin-RevId: 43cdcdde71bbcd16ed2e6c8b2accaa2a5de03001
2026-10-28 10:13:29 +00:00
Abhinav 154e8736a5 Support managed OpenTelemetry metadata and PEM client identities (#57658)
## Why

Managed OpenTelemetry requirements could not specify span attributes or tracestate metadata.

## What changed

- Accept `otel.span_attributes` and `otel.tracestate` in requirements, merge them by attribute or member field, and expose them through app-server configuration and requirements reads.
- Protect required entries and their ancestors from configuration writes while preserving unmanaged sibling values and their origins. For example, requiring `otel.tracestate.vendor.tenant` leaves `vendor.region` writable. Empty metadata maps impose no requirements.
- Select Rustls when configuring an OTLP HTTP client certificate and private key so PEM client identities are accepted.

## Testing

Add coverage for metadata precedence, effective configuration, field-level write protection, and preservation of unmanaged values. Add blocking and asynchronous HTTP client construction tests using generated PEM certificates and keys.

GitOrigin-RevId: ada6000cc5e575b9a33451ec4aa58b6686dc20f7
2026-10-28 06:24:24 +00:00
arnavpatidar-OAI bea47c06df Redact OTEL exporter headers in app-server config responses (#57654)
## Why

OTEL exporter headers can contain credentials. Configuration responses exposed these values in effective config, source layers, managed requirements, and write-override metadata.

## What changed

Replace header values with `[redacted]` across these responses for log, trace, and metrics exporters while preserving header names. Keep the original values available to runtime exporters, and redact them in debug output. Update protocol schemas and generated client documentation to describe the redacted values.

## Testing

Add coverage for effective config and source-layer redaction, managed requirements, and single and batch write-override metadata, including header names containing dots. Extend telemetry integration coverage to verify that runtime requests still carry the configured header value.

GitOrigin-RevId: ad24e8b91e615bd36c03c4c0ca205ac64bbd8cbf
2026-10-28 05:46:04 +00:00
Abhinav 727283cea5 Support managed OpenTelemetry configuration requirements (#57649)
## What changed

- Allow `requirements.toml` to manage OpenTelemetry logging flags, tool-result byte limits, environment, and log, trace, and metrics exporters.
- Apply higher-priority managed values over user configuration, replacing exporters atomically and warning when configured values conflict. Preserve unmanaged settings, including `span_attributes` and `tracestate`.
- Expose managed `otel` settings through `configRequirements/read`, apply them in `config/read` without ordinary field origins, and reject configuration writes that overlap managed fields.
- Distinguish omitted tool-result limits from explicit values while preserving the runtime default.

## Testing

Add coverage for requirement precedence, relative TLS paths, override warnings, managed write protection, effective configuration reads, and exporter serialization through the app-server API.

GitOrigin-RevId: 6a3343563bd3acb53a366ea6723684e3d0a4a01d
2026-10-28 05:11:45 +00:00
Brent Traut 04e365c698 Release sampling prompts after stream setup (#57618)
## Why

Legacy notifications only need user text, but retaining the full sampling input keeps image and audio payloads alive while the response streams.

## What changed

Extract notification text from the first request attempt only when `notify` is configured, and retain those strings across retries. Consume and drop the prompt after setting up the response stream, excluding attachments and media wrapper labels from notification text.

## Testing

Extend the notification integration test to verify that `input-messages` contains only user text while the model request still includes image and audio attachments.

GitOrigin-RevId: af4653c0e7ac2bf7006f5ae5a82a3e724c30c734
2026-10-28 02:00:30 +00:00
cassirer-openai 68b67f0ff4 Preserve rollout tracing across sub-agent reloads (#57615)
## Why

Reloading an evicted sub-agent disabled its rollout tracing, leaving later turns out of the trace. Replacement Code Mode sessions could also reuse cell IDs from earlier sessions.

## What changed

- Reattach reloaded children to the root rollout trace and emit `ThreadResumed` without duplicating `ThreadStarted`.
- Reopen existing threads during replay, preserving their identity and history while clearing stale runtime cell and terminal process mappings.
- Allocate Code Mode cell generations across sessions for both gRPC and stdio hosts to prevent ID reuse after reload.
- Record an aborted trace when session startup fails before the session loop begins.

## Testing

Add regression coverage for child eviction and reload, including a failed reload, continued inference tracing, distinct cell IDs, and preserved mail and follow-up context. Extend replay tests for history preservation and reused runtime handles, and host tests for cell IDs across session replacement and reconnection.

GitOrigin-RevId: 6c146c04b5cda9295afb7d973c0d5474b363a822
2026-10-28 01:29:34 +00:00
cooper-oai 9cce575134 Share runtime authentication with model providers and catalogs (#57607)
## Why

Model catalog refreshes need to use the same registered actor and credential owner as model requests when runtime authentication is enabled.

## What changed

- Add `ProviderAuthContext` to carry credentials and optional runtime authentication into model providers and catalog clients.
- Select runtime authentication independently for inference and catalog destinations. Reject unsupported OpenAI origins while preserving provider authentication for other destinations.
- Include API organization and project selectors in runtime registration. Reuse registered runtimes across projects within an organization and replace them when the organization changes.
- Preserve transport restrictions and account bindings, and strip sensitive headers on cross-origin redirects.
- Apply the catalog timeout to authentication and fetching while allowing credential refresh and registration to finish safely.

## Testing

Add coverage for runtime-authenticated catalogs, provider isolation, resource selection, gateway authentication, cross-origin redirects, and timeout recovery that preserves registration and refreshed tokens.

GitOrigin-RevId: c14f1a02159031ea0af1f9b26ea890f8dca7d6ad
2026-10-28 00:51:29 +00:00
goodman-oai e8e6a922c0 Support catalog headings for saved command-prefix notices (#57599)
## What changed

- Add `permissions.approved_command_prefix_saved` to model messages and use valid plain-text headings in saved-prefix notices, with or without full permissions instructions. Reject empty, oversized, control-character, and markup-like headings.
- Keep `Approved command prefix saved:` as the leading marker for older clients and recognize saved-prefix content kinds when trimming rolled-back context.
- Shut down analytics test exporters asynchronously and serialize workspace-switching tests that share authentication environment state.

## Testing

Extend coverage for heading validation, sparse wire values, single-notice emission, rollback with and without metadata, and saved-prefix behavior across model switches.

GitOrigin-RevId: a70175deca64a6339abac2fa69af970f470e3f4f
2026-10-27 23:53:34 +00:00
rhan-oai 37f199dab1 Add host-reserved V2 child creation APIs (#57586)
## What changed

- Add `CodexThread::create_child` to create an idle child from a live tool invocation using a host-reserved thread ID and controller.
- Add `prepare_child` and `ThreadManager::create_prepared_child` to capture inherited settings and fresh or forked history, then start the child on another manager even after the parent shuts down. Reject detached preparation when live bindings cannot be transferred.
- Add opt-in `HostToolInvocationLookup` to track live calls and reject duplicate active call IDs within a turn. Revoke invocation access when dispatch ends and clean up provisional children when startup fails or is cancelled.

## Testing

Add tests for invocation lifetime and call ID reservation, inherited policy and live bindings, detached startup with fresh and full history, and cancellation cleanup.

GitOrigin-RevId: 71f17ecb4cd7636517e675df59289a8e8c7105b8
2026-10-27 23:02:27 +00:00
Krish Chainani cb66dbecf2 Replace unavailable image references in model requests (#57585)
## Why

Image files can become unavailable between turns. Model requests should reflect their current availability while preserving the original references in saved history.

## What changed

- Add opt-in availability checks through `AttachmentStore::is_resolvable`, retaining references by default and on backend or access errors.
- Check distinct file IDs concurrently for each prepared request and replace confirmed-missing images with `[image unavailable]` in messages and tool outputs.
- Apply the same handling to compaction requests, with background image checks running outside the session lock without delaying foreground turn completion.

## Testing

Add unit tests and multi-turn scenarios covering placeholders, preserved history and annotations, concurrent deduplicated checks, backend errors, and nonblocking background compaction.

GitOrigin-RevId: ec98c7014c6e6b5063d87b943d2cd66a9ce7c1e3
2026-10-27 22:59:22 +00:00
Sean Huang 5078420b01 Preserve output boundaries through token truncation (#57584)
## What changed

Add `OutputBoundary` and token-budget formatting APIs that map item indices and UTF-8 text offsets to their positions after truncation. Normalize input positions, remap boundaries within omitted text, and keep end boundaries before generated omission notices.

Unify code mode output formatting: merge text-only output for truncation with a warning, and budget mixed text and audio in input order while preserving images and encrypted content. Accept owned output items to reuse allocations and move retained media without cloning.

## Testing

Add coverage for boundary normalization and remapping, UTF-8 offsets, zero and nonzero budgets, owned and borrowed output equivalence, and allocation reuse.

GitOrigin-RevId: 598407caa88b5a1f84130c4bc2273b85ab02f7f2
2026-10-27 22:56:23 +00:00
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
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
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
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
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
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
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
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
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
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