Commit Graph

5081 Commits

Author SHA1 Message Date
Ahmed Ibrahim
f31bd3adff Persist provider and auth identity with model catalog caches (#43897)
## What changed

Add a SHA-256 identity derived from provider routing, headers, and authentication scope. Return it with each model catalog response and persist it in `ModelsCacheEntry`. ChatGPT credentials with stable account and user metadata retain the same identity across token refreshes; opaque API credentials contribute to the digest.

## Testing

Add identity tests covering account, user, email, plan, auth mode, provider routing, headers, and API credential changes, plus stability across ChatGPT token refreshes. Update cache tests to include the persisted identity.

GitOrigin-RevId: 3f51c6cabcb01bc03505150a768a61dfe5d6569f
2026-09-08 19:48:37 +00:00
caseysilver-oai
9d83c48e5c Preserve thread identity in code-mode tool dispatch traces (#43894)
## Why

Code-mode callbacks can resume outside the turn's local span ancestry, leaving tool dispatch traces without the thread identity inherited from a turn span.

## What changed

Record `thread.id` directly on the `dispatch_tool_call_with_code_mode_result` span using the session's thread ID.

## Testing

Add a regression test that dispatches a code-mode tool callback from a fresh task without a turn span and verifies that the dispatch span records the thread ID, tool name, and an `exec-` call ID with a valid UUID.

GitOrigin-RevId: a25a0d8fcaf1b6501473151c486fc9940065df91
2026-09-08 19:36:05 +00:00
jelson-oai
5a65fd87d8 Close active network proxy connections on teardown (#43884)
## Why

Stopping proxy listeners could leave accepted connections and half-closed tunnels alive after their owning thread was unloaded.

## What changed

Tie HTTP and SOCKS5 connection work, including HTTP CONNECT upgrades, to the lifetime of the proxy listeners. Cancel connections across the main and environment proxies when the handle is dropped, shutdown is requested, or `wait()` is canceled. Explicit shutdown waits for connection cleanup.

## Testing

Add live TCP regression tests for HTTP keep-alive connections and open or half-closed HTTP CONNECT and SOCKS5 tunnels across shutdown, handle drop, and canceled waits. Verify that half-closed tunnels still carry return traffic while the proxy is running, and that repeated thread creation and unloading closes managed proxy tunnels.

GitOrigin-RevId: b523f3b08d73e9ae368f6932952cc930c7b038c9
2026-09-08 18:40:17 +00:00
Alec Barber
c1f1467f30 Handle undefined values before JSON serialization in code mode (#43873)
## Why

Passing `undefined` to a tool could fail JSON parsing because V8 stringifies it as the non-JSON text `undefined`.

## What changed

Return no JSON value for JavaScript `undefined`, so explicit `undefined` tool arguments behave like omitted arguments. Attempts to `store` an undefined value report the existing serializability error and preserve the previous stored value.

## Testing

Add regression coverage for storing `undefined` over an existing `null` value, and extend the current-time tool test to cover `{}`, omitted arguments, and explicit `undefined`.

GitOrigin-RevId: 071050ebb2ecc44c8f08453cf8523b4d21728c7e
2026-09-08 17:51:40 +00:00
rhan-oai
6515a72db7 Preserve runtime workspace roots across thread resume (#43848)
## Why

Resuming a thread should retain its selected workspace folders, including additional roots and explicit empty selections. Resume overrides also need to survive a subsequent resume when no turn has run.

## What changed

- Persist `runtime_workspace_roots` in startup metadata and thread settings snapshots, separately from explicit environment selections and permission-profile roots.
- Restore roots from the latest snapshot owned by the resumed thread, falling back to owned startup metadata only when no snapshot exists. Honor explicit `runtimeWorkspaceRoots` overrides, retarget the old `cwd` root when `cwd` changes, deduplicate roots, and validate restored paths for the current host.
- Checkpoint effective settings on resume and restored settings after revert. Reload resume configuration if saved workspace roots change during loading.
- Normalize Windows rollout path spellings when matching thread search results, preserving selection of the correct rollout after revert, including compressed rollouts.

## Testing

Add regression coverage for workspace restoration, empty and explicit overrides, foreign paths, compaction and revert, resume checkpoints without recency changes, concurrent settings persistence, and rollout search path matching.

GitOrigin-RevId: d98d9d34dd63934d441120916c61c12b69e7f062
2026-09-08 16:24:38 +00:00
Nick Steele
b090e901f8 Add staged enterprise OIDC login and coordinated logout (#43844)
## Why

Enterprise sign-in needs to keep browser completion separate from credential storage so callers can recheck the active account and configuration before saving a grant. Logout must also prevent an earlier sign-in from restoring credentials, including from another process sharing `CODEX_HOME`.

## What changed

- Add enterprise login APIs in `rmcp-client` that return an authorization URL and stage validated credentials for an explicit `commit_if` call. Store grants only in the keyring after rechecking caller authority under the credential lock.
- Require a registered client ID, published metadata matching the configured issuer, HTTP loopback callbacks, a refresh token, and a valid OIDC identity assertion. Request `openid` and `offline_access` with `prompt=consent`, and omit MCP resource indicators from authorization and code exchange.
- Persist a login generation under the credential lock so logout invalidates pending and staged sign-ins across processes, even when no grant is stored.
- Keep credentials and account identifiers out of enterprise error chains and logs, and avoid logging callback payloads when the receiver has closed.

## Testing

Add coverage for discovery validation, loopback callbacks, PKCE, staged keyring storage, cancellation, stale attempts, cross-process logout, and error/log privacy. Preserve ordinary MCP OAuth login without a refresh token, and adjust the terminal polling test deadline to include the minimum empty-poll wait.

GitOrigin-RevId: 2a27b9a26505a2f6fdecce8877f6e2c21e148f72
2026-09-08 16:07:38 +00:00
andrewgu-oai
cbfa321ecd Wait for parent idle before rollback in guardian fork tests (#43842)
## Why

`TurnComplete` precedes active-turn cleanup, so waiting for it alone can race with rollback in the guardian retained-context fork test.

## What changed

Wait for a thread-scoped idle notification after each parent turn, including optional compaction, before checking rollback boundaries. Consume notifications separately so earlier turns or child completion cannot satisfy the wait. Fail immediately on rollback errors to expose the failure directly.

GitOrigin-RevId: 3caabee45e4e6eb6b2618d84ab68dff7de2a1196
2026-09-08 15:56:58 +00:00
jif
2cbbf0c9b5 Add memory dual writing and v2 readiness reporting (#43827)
## Why

Allow v2 memories to build in the background while the selected memory version continues supplying context, and let clients check whether v2 has enough consolidated data and a valid summary to use.

## What changed

- Add `memories.dual_write`, disabled by default, to run v1 and v2 extraction and consolidation concurrently with separate stores and directories.
- Add the experimental `memory/status` endpoint, returning `v2ConsolidatedThreads` and `v2Ready`. Readiness requires a valid v2 summary and a consolidation thread count meeting `minConsolidatedThreads` (default 20, supported range 1–4096).
- Persist the largest thread count from a successful consolidation across pruning and clear it on memory reset.
- Share v2 summary validation between consolidation and status reporting, and tag memory metrics with `memory_version`.

## Testing

Add tests for independent dual-write outputs, preserving existing notes without importing them into v2, and readiness behavior across consolidation ownership checks, missing summaries, configurable thresholds, thread deletion, and memory reset.

GitOrigin-RevId: 54417cc60bf419062401355c0da8c79119995f61
2026-09-08 14:23:23 +00:00
jif
553df1c691 Add dedicated memory v2 consolidation and read prompts (#43813)
## What changed

- Consolidate v2 rollout summaries into `memory_summary.md` without generating `raw_memories.md` or requiring `MEMORY.md`. Validate the summary's required sections and size below 10,000 UTF-8 bytes.
- Add v2 read instructions for selective history retrieval, evidence-grounded preferences, citations, and explicit memory edits. Split injected instructions into fragments to preserve the complete summary within fragment byte limits.
- Record memory citation usage in the store selected by `memories.version`.

## Testing

Add coverage for v2 consolidation without a handbook, summary validation, version-isolated memory reads, and resetting both memory versions while preserving threads.

GitOrigin-RevId: 1d895fb4a23a973f1a45ba03be07a1f480c10227
2026-09-08 12:58:11 +00:00
jif
e7f5de0a6a Move v2 extraction chunking into the memory writer (#43808)
Move `extraction_messages` from `MemoryContextFragment` in `codex-core` to
`codex-rs/memories/write/src/rollout_input.rs` and update the phase-one caller.
Preserve the existing 8,900-byte chunk limit and Unicode-safe boundaries.

Move the accompanying test with the helper, retaining coverage that bounded
user messages reconstruct the original evidence without loss.

GitOrigin-RevId: 48ac501acbfa50c4195195fd40efc7588a6c714d
2026-09-08 12:46:39 +00:00
felixxia-oai
0337192dfd Centralize Guardian transcript policy in context profiles (#43806)
## What changed

Add `ContextProfile` to `codex-guardian-context` and route synchronous and asynchronous Guardian transcript rendering through it. Move default limits, retention, formatting, and async chunked eviction into the shared crate while preserving the distinct retention policies and host-managed full/delta cursors.

Carry transcript truncation observations through `RenderedTranscript` into context composition, and derive async image collection flags from the resolved profile.

## Testing

Add a profile regression test covering distinct sync/async retention priorities, original entry numbering, omission notes, and async truncation observations. Adapt existing transcript tests to the updated input API.

GitOrigin-RevId: 7f7dc249629d8017e9547085f6617f815ae43a1b
2026-09-08 12:17:28 +00:00
felixxia-oai
0034ef93a7 Centralize Guardian context composition (#43805)
## Why

Synchronous approval reviews and asynchronous scoring assemble Guardian evidence separately, duplicating transcript framing and section placement.

## What changed

- Move evidence ordering, framing, and delivery into `codex-guardian-context`, while keeping transcript retention, budgets, and delta cursors with their callers.
- Pass composed messages directly to the asynchronous sampler, preserving roles, annotations, trusted message boundaries, and image placement.
- Reject unsupported synchronous delivery with `SectionError::UnsupportedDelivery` instead of silently dropping content.

## Testing

Add composition coverage for preserving separate messages and rejecting them for synchronous delivery. Extend Guardian integration coverage to check trusted tool and skill messages, mixed text and image evidence ordering, and full and delta review framing.

GitOrigin-RevId: efc06695ee4e2b7400b123b77ef2a21c8bf40646
2026-09-08 12:06:44 +00:00
jif
6924ce636b Prioritize human evidence in memory v2 extraction (#43799)
## Why

Memory extraction has a limited rollout budget. Select evidence by source so human input and assistant final responses take priority over commentary, context, and tool output.

## What changed

- Use tiered selection for memory v2, preferring newer evidence within each tier and rendering selected items in chronological order with omission markers.
- Keep answered `request_user_input` questions alongside human replies, label evidence sources, replace message media with placeholders, and bound tool output and individual rows.
- Add typed memory context fragments with bounded messages and Unicode-safe extraction chunking.

## Testing

Add tests for memory v2 startup using tiered input and for extraction chunks preserving Unicode evidence within message bounds.

GitOrigin-RevId: 1b2bba4e3264b4fda271e429ad3b7d5f69caed59
2026-09-08 11:12:01 +00:00
jif
5371951292 Batch non-user history eviction to preserve Guardian transcript deltas (#43798)
## Why

Evicting entries on every append once history fills invalidates Guardian's transcript cursor, forcing repeated full transcripts instead of deltas.

## What changed

On non-user history overflow, evict at least the oldest half of existing non-user entries, removing more if needed to meet the byte limit. This leaves room for subsequent appends without invalidating the cursor. Preserve the separate user-message retention limits.

## Testing

Update retention assertions and add a regression test that verifies a full transcript after eviction, followed by a delta on the same Guardian thread, while retaining the user's earlier restriction.

GitOrigin-RevId: 7ba18f01e2962d3de35488d981b667ccbb8995c7
2026-09-08 11:03:44 +00:00
jif
3f76e88a48 Add configurable memory versions with isolated storage (#43797)
## What changed

- Add `memories.version` with `v1` as the default and `v2` as an opt-in selection.
- Route memory generation, summaries, and retrieval tools through the selected version. Store `v2` artifacts in `memories_v2` and lazily create a separate SQLite database, keeping jobs and outputs isolated while sharing the thread catalog.
- Preserve the initial memory version across extension config updates so summaries and retrieval tools use the same namespace.
- Clear both versions on memory reset and remove thread memory from both stores on thread deletion. Recognize both artifact roots in shell usage telemetry.

## Testing

Add regression coverage for version defaults and validation, independent job claims and outputs, deletion and reset across versions, and shell usage classification for both memory roots.

GitOrigin-RevId: aa799bf87ab6ec10c8f5668213931e57547d080b
2026-09-08 10:55:48 +00:00
felixxia-oai
35d9e4bc4d Preserve reasoning effort through compaction and reset it on success (#43796)
## Why

With reasoning effort overrides enabled, compaction used the selected effort even when sampling requests still used an earlier pinned effort. Successful compaction also left that old pin active in the new context window.

## What changed

- Use the pinned request effort for local and remote compaction when it matches the model.
- Resolve fallback models' effort without mutating the live pin, preserving it if compaction fails.
- Reset the pin after successful compaction so the next sampling request establishes the selected effort as its baseline without a redundant `configuration_update`.

## Testing

Add regression coverage for remote compaction success and failure, fallback model effort selection, pin preservation during fallback lookup, and compaction after resuming with overrides disabled.

GitOrigin-RevId: 35e666b0c8026553500715ddbe7bef02cd759f4a
2026-09-08 10:46:07 +00:00
felixxia-oai
31ccaf40c2 Pin request reasoning effort while configuration overrides are active (#43795)
## Why

Reasoning-effort changes should preserve the request baseline while trusted `configuration_update` items carry the selected effort.

## What changed

- Pin request-level reasoning effort for the current model when reasoning-effort overrides are available, including during WebSocket prewarm.
- Re-establish the selected effort after rollback, resume, or a model switch, refreshing the trusted override even when the selection is unchanged.
- Continue using the selected request effort when overrides are unavailable.

## Testing

Add regression coverage for WebSocket prewarm and reconnect, rollback, resume, and model switches. Update transition tests to assert that request-level effort stays pinned while configuration updates change.

GitOrigin-RevId: 89cfee6289543230347b0488d1388190b4da7216
2026-09-08 10:41:15 +00:00
Eric Traut
49a9d78999 Make older app-server notices configurable in the TUI (#43698)
## What changed

Add `tui.show_server_version_notice`, enabled by default. Set it to `false` to suppress informational notices about older stable app servers at startup, on reconnect, and in the agents overview. Compatibility errors and version status remain unaffected.

Refresh the overview notice when local settings change, clearing pending notices when the setting is disabled.

## Testing

Add coverage for disabling and re-enabling overview notices, clearing pending notice state, and preserving remote version status. Extend reconnect and local-settings tests to cover the new setting.

GitOrigin-RevId: d50dcf4472ee221ce31cdd7ab2cd766f901a8039
2026-09-08 04:35:21 +00:00
Benjamin Carlsson
4b0f44d304 Add worktree classification to thread telemetry (#43621)
## What changed

Add `is_worktree` to thread initialization analytics and the `codex.thread.started` metric using validated Git repository metadata. Classify linked worktrees as `true` and primary checkouts as `false`; report an unavailable classification as `null` in analytics and `unknown` in metrics. Subagent initialization analytics leave the field unset (`null`).

## Testing

Add analytics coverage for primary checkouts, linked worktrees, unknown repositories, and event serialization. Extend the account-switch telemetry test to check that the `is_worktree` tag reaches the next account's collector.

GitOrigin-RevId: bc9bcd3c0212c0a123e4bcfed0c7020eef17dda6
2026-09-07 23:38:35 +00:00
felixxia-oai
d75ed505d7 Move Guardian REPL evidence rendering into the shared context registry (#43602)
## What changed

Move completed REPL response rendering into `codex-guardian-context` and register a synchronous-only `NodeReplEvidence` section. Core supplies a borrowed view of its evidence snapshot and retains responsibility for capture, storage eviction, and the delivery cursor.

Preserve the existing text and multimodal layouts, rendering bounds, omission markers, image ordering, and deduplication. Exclude evidence payloads from the rendered section's debug output.

## Testing

Adapt the existing evidence tests to exercise the shared renderer. Extend registry coverage to verify synchronous-only inclusion, rendered content, and omission of evidence payloads from debug output.

GitOrigin-RevId: eb181870558a7f2f77270dee7c17d36700f3e148
2026-09-07 21:54:56 +00:00
felixxia-oai
b4373e53ab Move Guardian image selection into shared context sections (#43601)
## What changed

Move bounded transcript image collection into `codex-guardian-context` and expose it through an optional `TranscriptImages` section. Update the async scorer to consume this section, preserving source filtering, image detail, omission accounting, and the existing limits of four images and 8 MiB of image URL data.

## Testing

Add coverage for source order, tool-output filtering, disabled image collection, oldest-image eviction, oversized images, and omitted-byte accounting.

GitOrigin-RevId: 097799ea1be6d73b347088f959de1fd23f02ec2c
2026-09-07 21:46:23 +00:00
felixxia-oai
f5331dc237 Move trusted skill evidence into the Guardian context registry (#43599)
## What changed

Move trusted skill rendering into `codex-guardian-context` as `TrustedSkills` and collect it through an async-only context section. Pass the collected section to the sampler, preserving the separate developer message and bounded JSON rendering. Omit skill paths from `Debug` output, exposing only their count.

## Testing

Move rendering tests alongside the shared type, covering multiple paths and escaped UTF-8 within the size budget. Extend registry tests to cover async-only inclusion, omission for empty input, section ordering, and path redaction in debug output.

GitOrigin-RevId: c0778067f19d31e693ca954aee1a7d7be8f9739a
2026-09-07 21:38:25 +00:00
felixxia-oai
2554239561 Move trusted tool metadata into shared Guardian context (#43597)
## What changed

Represent host-verified tool metadata as `TrustedTool` in `codex-guardian-context` and collect it through an async-only context section. Route Guardian v2 sampling through that section while preserving separate developer-message delivery and the 512-token rendering budget. Omit tool metadata from debug output.

## Testing

Move the rendering-budget test into the shared crate, extend registry coverage for async-only collection and debug redaction, and narrow the scoped approval test to messages tagged `guardian.trusted_tool`.

GitOrigin-RevId: ee7cb4e9b9ceced70438cb58060d1a2973e1dc6a
2026-09-07 21:29:31 +00:00
felixxia-oai
0b9b5ecff3 Centralize bounded Guardian review evidence in guardian-context (#43595)
## What changed

Move prior-review rendering and developer-message construction into `codex_guardian_context`, and route async scorer evidence through a dedicated `PreviousReviews` context section.

Validate a maximum of eight review fragments and a per-fragment byte budget equivalent to 1,000 approximate tokens. Reject oversized evidence without rewriting or dropping records, and fail closed when validation fails. Preserve authorization-version filtering and the existing developer-role delivery. Keep review contents out of debug output.

## Testing

Add coverage for count and UTF-8 byte-size boundaries, preservation of accepted fragments, async-only section delivery, and omission of review contents from debug output.

GitOrigin-RevId: 05e9f53a6405f490b2424b2491a834cd90ab24f0
2026-09-07 21:20:31 +00:00
Benjamin Carlsson
b01c3986fd Add live WebRTC voice conversations to the TUI (#43581)
## What changed

- Add feature-gated `/voice`, `/voice mute`, and `/voice stop` commands with local WebRTC audio and app-server signaling.
- Show live transcripts, conversation status, and microphone and speaker levels. Preserve captions and undelivered answers across thread switches.
- Speak final answers from voice handoffs while keeping delegated reasoning and commentary hidden and typed answers unspoken.
- Retry eligible startup failures once and clean up voice sessions on thread switches and disconnects.
- Stop voice and block late handoffs after a misalignment policy violation. Remove realtime event payloads and spoken text from receipt and debug logs.

## Testing

Add coverage for voice command mapping, rejected starts, disconnect cleanup, delegated final-answer speech, late handoff rejection, and transcript and footer rendering.

GitOrigin-RevId: 11def1f86b0e023b21d0d92072d6636ccad89815
2026-09-07 20:25:30 +00:00
jif
98a5cb46b1 Manage synchronous Guardian reviewers through the thread manager (#43570)
## What changed

- Store the shared `GuardianReviewSessionManager` in thread extension data and let the Guardian extension spawn and fork reviewers through `ThreadManager`, independently of async scorer startup.
- Preserve reviewer reuse, concurrent forks, cancellation, inherited environments, and user instructions. Gate managed reviewer startup on parent registration and remove terminated reviewers from the manager.
- Retain the `guardian` subagent identity in saved conversations. Reject resume of live Guardian reviewers and reject client archive or delete of live owner-managed workers with JSON-RPC error `-32600`; allow normal access after the owner releases them.
- Keep standalone reviewer support for inline delegates and remove duplicated extension prompt and configuration code.

## Testing

Add app-server tests covering reviewer reuse and concurrent forks, inherited instructions and prompt cache keys, live resume and removal rejection, saved reviewer discovery and resume after parent shutdown, and strict Guardian assessment inside an inline review.

GitOrigin-RevId: 4f9893c1ade151eacb4c11ffeae3d9e9ec019187
2026-09-07 19:43:10 +00:00
felixxia-oai
81f23bc186 Move Guardian permission context into the shared section registry (#43538)
## What changed

Represent denied read paths and globs with `PermissionContext` and render them through a sync-only section in `codex-guardian-context`. Keep policy resolution in the host and preserve the existing permission warning in Guardian review prompts.

## Testing

Extend registry tests to verify permission sections appear only for synchronous reviews. Extend the session reuse test to check that resolved denied paths and globs appear in both the initial review request and the next review's delta.

GitOrigin-RevId: a966a14b367f1eedb5a577f7ed74a869559ae646
2026-09-07 18:10:05 +00:00
felixxia-oai
93ac341410 Preserve Guardian context sections and share planned-action rendering (#43534)
## What changed

- Replace `ComposedContext` with ordered `ContextSection` values that retain section identities through transcript selection and rendering.
- Add a shared `PlannedAction` section and renderer for core synchronous approval prompts and the Guardian V2 asynchronous scorer, preserving full, delta, terminal-input, and network-request framing.
- Keep action JSON and retry reasons out of `PlannedAction` debug output.

## Testing

Update registry and transcript tests to assert section identities and source roles. Extend registry coverage to verify planned-action collection for both consumers and omission of action JSON and reasons from debug output.

GitOrigin-RevId: 675b841a2cad06afce03f414615b4d7aa0553b13
2026-09-07 18:02:06 +00:00
jif
1e66885a16 Discount an approval's own code-mode wrapper from Guardian score lag (#43527)
## Why

A code-mode `exec` wrapper and its nested tool calls each advance Guardian's score lag. Counting the unscored wrapper against its own nested approval can trigger a synchronous review sooner than needed.

## What changed

Track originating response items and approval tool-call IDs so cached approvals discount their own wrapper when it is newer than the latest score. Preserve wrapper identity across yields and waits, and retain the full lag when provenance is missing or evicted. Other wrappers and scoring failures still count.

Use the current `write_stdin` call's identity for approval freshness, and omit tool-call identity for `execve` intercepts that only retain the launch ID.

## Testing

Add coverage for wrapper-specific discounts, already-scored wrappers, missing and evicted provenance, identity across code-mode resumes, and approval identities for stdin writes and `execve` intercepts.

GitOrigin-RevId: 4002a06d64c4e1e0a13c072303503d6ddfacad09
2026-09-07 17:35:23 +00:00
riley-oai
f326857cf4 Restrict MCP user verification and add workspace-scoped identity (#43524)
## Why

Configured MCP servers must not be able to request user verification, even when they reuse the hosted apps server name. Local verification identity selection also needs to distinguish a user's workspace memberships.

## What changed

- Advertise `userVerification` only to the host-owned apps MCP server and cancel verification requests from other servers before prompting the client.
- Add `CodexAuth::get_chatgpt_account_user_id()` to read the access token's opaque `chatgpt_account_user_id` only when its workspace matches the selected account. Missing or malformed claims return no identity, without falling back to another user ID or breaking ordinary authentication.

## Testing

Add coverage for capability filtering, rejection of configured servers including those using the hosted apps name, and account-user identity selection with malformed or mismatched claims. Add an MCP round-trip test showing that verification waits for a client response even in full access mode, returns the supplied proof, and discards response metadata.

GitOrigin-RevId: 156e83d5a0302c013b85e564b46b4bfe858cbdb0
2026-09-07 17:26:10 +00:00
jif
9f70e348e0 Allow internal sessions to fork from selected history (#43495)
## What changed

Add `ThreadManager::fork_internal_session` to start an internal session from caller-selected committed history without reading an in-flight parent turn or appending an interruption marker. Preserve parent authentication and budget sharing, and propagate fork lineage. Keep `spawn_internal_session` starting with fresh history.

## Testing

Add a regression test verifying that the fork contains only the selected history, retains its parent association and authentication manager, and stays outside the public thread registry.

GitOrigin-RevId: df4260ed3adfa0abe7a07c2b6d8b8c6ef6ba3d16
2026-09-07 15:27:52 +00:00
jif
d665e3bbc8 Include unloaded children in multi-agent v2 environment context (#43491)
## Why

After a cold resume and compaction, the subagent roster omitted children whose threads had not been loaded.

## What changed

Build the multi-agent v2 roster from registered direct children and render their full agent paths. Prioritize loaded children, sort alphabetically within each group, and cap the rendered roster at eight agents and 1,024 bytes. Preserve the existing behavior for other multi-agent versions.

## Testing

Extend the cold-resume integration test to check that post-compaction context includes unloaded children, excludes grandchildren, and lists a loaded child before an alphabetically earlier unloaded sibling.

GitOrigin-RevId: 745c1622133b9c01e61f4702e4b2ef6255417f39
2026-09-07 15:10:37 +00:00
jif
d70044072c Expose shared Guardian reviewer helpers through guardian_review (#43490)
## What changed

Add a public `codex_core::guardian_review` module exposing `GuardianAssessment`, the assessment parser and output schema, and the review session configuration builder for reuse by the Guardian extension.

Extract assessment handling and reviewer configuration into dedicated modules, preserving the existing parsing defaults, policy prompt, and read-only reviewer settings.

## Testing

Move the existing embedded-JSON, bare allow/deny, and output-schema tests alongside the assessment implementation.

GitOrigin-RevId: cb2aba3ccdb597e2876015e718e923d4f8f36802
2026-09-07 15:01:16 +00:00
felixxia-oai
16ff14c266 Retain inherited Guardian instructions in standalone forks (#43478)
## Why

A standalone root forked from a worker needs its inherited user instructions for Guardian review, including after compaction. Parent input counters belong to a different thread, and omitted parent answers may have restricted an inherited authorization.

## What changed

- Adopt inherited user instructions into thread-owned retained context for standalone roots, recovering surviving checkpoint messages when needed.
- Keep inherited instructions before local evidence without sharing local acceptance counters, and preserve that distinction during reconciliation and rollback.
- Mark parent verified answers as incomplete and treat recovered checkpoint instructions as incomplete excerpts.

## Testing

Add coverage for standalone forks from copied history and truncated checkpoints, retention through compaction and resume, inherited/local ordering collisions, and rollback scope.

GitOrigin-RevId: bf716e224a1d29d6c528ef0dd7cdb118a413a08c
2026-09-07 13:58:57 +00:00
felixxia-oai
aa12ab45df Recover missing Guardian root instructions in acceptance order (#43472)
## Why

Incomplete retained checkpoints can omit root user instructions that still survive in live history. Queued input can also reach model history after a later-accepted answer, so recording order cannot reliably order grants and restrictions for subagent authorization reviews.

## What changed

- Reconcile retained evidence with surviving local user messages using source identity and persisted acceptance order, including answers present only in the checkpoint.
- Preserve checkpoint gaps and mark evidence incomplete when recovered instructions lack an order or conflict with an existing order.
- Restore the input-order counter from surviving local metadata so new instructions sort after recovered evidence, even without a retained checkpoint.

## Testing

Add unit coverage for source matching, acceptance ordering, persistent gaps, conflicting orders, and counter restoration. Extend subagent authorization tests to cover checkpoint resume, queued approvals, missing sources, and a subsequent revocation.

GitOrigin-RevId: 8bfbfd2c797d725796187e5cecf7f3f11a5f3380
2026-09-07 13:40:29 +00:00
jif
db0568dbbb Remove legacy Guardian approval review paths (#43462)
## What changed

- Remove the `fast_decision` and `full_review` extension hooks and `ApprovalAssessment`, leaving `ApprovalReviewContributor::decide` as the approval decision interface.
- Remove the duplicate Guardian V2 fast-approval implementation and `StrictReviewReason` state.
- Require an explicit `GuardianReviewReason` for synchronous reviews.

## Testing

Migrate Guardian reviewer tests to the production `decide_approval` path and cached-score tests to the registry's decision interface.

GitOrigin-RevId: 1f9092c0ff5bb1eed0c63fa557fb3807e2e71564
2026-09-07 13:02:46 +00:00
felixxia-oai
8260619cb6 Centralize Guardian context mode and checkpoint policy (#43458)
## What changed

Resolve `GuardianContextMode` once at session construction and share it across history retention, replay, evidence capture, compaction, and review consumers.

Extract synchronous reviewer context policy and consolidate Guardian V2 parent checkpoint selection so sampling and fast approval use the same eligibility checks. Preserve legacy checkpoint omission and strict compatibility requirements for thread-owned context.

## Testing

Adapt existing review and history tests to the explicit context mode. Move checkpoint tests alongside the extracted selector, retaining coverage for latest-item identity, unusable checkpoints, and complete-item size limits.

GitOrigin-RevId: c73fb6fea556921acfffe758a5f709d7494019dd
2026-09-07 12:53:57 +00:00
jif
f3f53ee949 Wait for thread idle before rollback in model-switching tests (#43456)
## Why

`TurnComplete` arrives before the active turn is cleared, so submitting a
rollback immediately can race with turn cleanup.

## What changed

Wait for the thread-idle callback with a 10-second timeout before rolling back
in the first-turn model-change and generated-image tests. Fail immediately on
an error event while waiting for `ThreadRolledBack`.

GitOrigin-RevId: c17b35d709b2c74361dd7933506ae192464ea4e8
2026-09-07 12:36:57 +00:00
jif
ce5c4133bd Route MCP elicitations through the shared approval decision path (#43447)
## What changed

- Use `decide_approval` for MCP elicitations, carrying the effective approval policy, reviewer, and synchronous-review requirement into the decision.
- Preserve unsupported form and URL elicitations for user review.
- Use `computer_use_review_required()` for review evidence, session policy, and turn metadata so model policy takes precedence over the legacy flag.
- Derive strict-review notifications from each assessment's review reason.

## Testing

Add coverage for model policy precedence, user and full-access modes, sensitive elicitations, independent code-mode and nested-tool policies, cached score reuse, and user review of unsupported elicitations.

GitOrigin-RevId: d0a9c40572dca7b3dbf876230d2162b72728084d
2026-09-07 12:04:27 +00:00
felixxia-oai
5b85aea979 Keep Guardian review evidence consistent and reject stale approvals (#43442)
## Why

Concurrent parent compaction can remove evidence between Guardian checkpoint selection and prompt construction. New user instructions or answers received during a review can also invalidate an approval based on earlier authorization.

## What changed

- With `GuardianThreadContext` enabled, use the same parent history snapshot for checkpoint selection and prompt evidence.
- Cancel completed allow decisions if the owning session's user-message revision or root authorization version changed during the review, even without cacheable review evidence.

## Testing

Add regression coverage for evidence preservation during concurrent compaction and aborted approvals after new user instructions or verified answers. Extend reviewer context rollover coverage to exercise `GuardianThreadContext`.

GitOrigin-RevId: 1c2c82197a27c0d3d45b6fe08d200a835d80cc30
2026-09-07 11:51:20 +00:00
jif
e1eb98461c Route approvals through the extension decision API (#43432)
## What changed

- Let approval extensions choose between cached approval, synchronous review, and a user prompt for tool and permission requests, while core enforces mandatory Guardian and fresh-review requirements.
- Carry an optional `review_reason` on Guardian assessment events and use it to trigger strict-review notifications, retaining the fallback for older events.
- Require synchronous review when cached evidence has an unusable encrypted parent compaction.

## Testing

Add regression coverage for manual prompts and cached approvals with non-UTF-8 working directories. Update approval contributors in existing tests to use the decision API.

GitOrigin-RevId: a4e66416070bdaa881daa41429c49021629f44c1
2026-09-07 11:07:28 +00:00
jif
7769bccbb2 Avoid WebSocket connection waits in Guardian v2 classification (#43408)
## Why

When no healthy pooled WebSocket is available, classification waits for a new connection to open and can stall on its handshake.

## What changed

- Use HTTP streaming when no healthy idle WebSocket is ready, and replenish the pool in the background with a five-minute cooldown after connection timeouts.
- Share concurrency limits and the sampling retry budget across both transports, and bound the wait for HTTP response headers.
- Cancel superseded requests while awaiting response headers and stop SSE polling when the consumer closes.

## Testing

Add coverage for HTTP fallback and recovery after cooldown, shared transport capacity, stalled response headers, and cancellation before headers or during body draining. Update sampler and extension tests to cover fallback after socket expiry, authentication changes, and transient failures.

GitOrigin-RevId: 0b23ccc1bfb2dfdbc8d2791d097706cd4dd44f39
2026-09-07 09:24:03 +00:00
riley-oai
555b82afa9 Add opt-in MCP user-verification transport (#43352)
## Why

Device-authenticated verification needs an app response outside automated approval and review. Previously, MCP user-verification requests were always cancelled.

## What changed

- Add typed `openai/userVerification` elicitations carrying a title, description, and challenge through core and app-server.
- Route verification to one connection enabled by trusted host activation. Restrict responses to that owner, exclude requests from replay, and cancel on disconnect or authentication changes, including account switches away and back.
- Return proofs in `content`, discard response metadata, and cancel malformed acceptances. Suppress verification response logging and analytics, and send only a generic verification notice to realtime.
- Keep the mode experimental and exclude it from stable schema exports. Capability advertisement remains disabled, and the TUI cancels verification requests.

## Testing

Add coverage for owner isolation, disconnect and authentication races, proof response handling, automated-review bypass, inactive-host cancellation, stable schema filtering, and realtime payload exclusion. Update the MCP integration test to verify that an activated request holds the tool until the client responds.

GitOrigin-RevId: c8c7b6691a3f7756682bbcca9def1df0d1feb906
2026-09-07 04:33:22 +00:00
riley-oai
3cd6004dc4 Add capability-gated MCP user-verification handling (#43289)
## What changed

- Handle `openai/userVerification` requests through `openai/elicitation/create` when the client advertises `userVerification` support.
- Validate request fields, size limits, and base64url encoding. Require a correctly shaped, bounded proof for acceptance; cancel invalid acceptance responses and discard proof material on decline or cancellation.
- Handle request and service cancellation, including cancellation received before request dispatch. Bound early-cancellation storage and cancel new verifications when capacity is exceeded.
- Keep verification inactive in Codex: cancel requests without prompting until the typed app-server and UI path is available.

## Testing

Add tests for request and proof validation, malformed modes, cancellation races and capacity limits, timeout-pause cleanup, and independent concurrent requests. Add integration coverage showing that verification does not prompt or prevent tool and turn completion before activation.

GitOrigin-RevId: 6313c1be40fae0b33cc3ce0f8fe025b4124ed2ef
2026-09-06 21:41:16 +00:00
pmccrary-oai
6af345407d Gate experimental context by model capability at session startup (#43147)
## Why

Experimental context activation previously checked the provider and account eligibility without checking model support. Child sessions also inherited token-budget activation from their parent, even when starting fresh with a different model.

## What changed

- Add `ModelInfo.supports_experimental_context`, defaulting to `false`, and enable it for the bundled `gpt-6-astra` model. Require this capability when activating experimental context.
- Snapshot configured token-budget preferences before startup activation. Restore them for fresh child sessions before applying their starting model's defaults, while history forks retain their parent's activation.
- Pass unresolved token-budget preferences to child sessions so they can use their own model's prompts.

## Testing

Extend coverage for unsupported models, model-switch guidance under explicit and experimental activation, and child configuration from both active and inactive parents. Verify that omitted capability metadata defaults to `false`.

GitOrigin-RevId: 02df9e171682267232fa923d5ea3f7af36527808
2026-09-06 02:28:38 +00:00
felixxia-oai
56a8470aa0 Record reasoning effort changes in conversation history behind a flag (#43110)
## What changed

Add the disabled-by-default `reasoning_effort_override` feature for OpenAI models with `use_responses_lite` enabled. Append a trusted `configuration_update` after accepted input when no effort is established in surviving history or the resolved effort changes. Preserve the existing history prefix and continue sending the request-level reasoning effort.

Share effort normalization through `ModelInfo::resolve_reasoning_effort` so requests and history updates resolve `ultra` consistently and translate `persistent` to `disabled`. Exclude other custom effort values from history updates, and compare only against harness-authored configuration items.

## Testing

Add integration coverage for effort transitions, deduplication, history prefix and cache-key preservation, alias normalization, and feature/provider/model gating. Add unit coverage for model-specific `ultra` resolution, fallbacks, and `persistent` translation.

GitOrigin-RevId: c3fe7050058076454d8ea20054a618bca9d48c7c
2026-09-05 21:56:43 +00:00
felixxia-oai
e4ce83419b Move Guardian thread context into guardianv2 configuration (#43104)
## What changed

Replace `features.guardian_thread_context` with `features.guardianv2.thread_context` and update the configuration schema. The setting controls thread-owned context for synchronous and asynchronous Guardian, defaults to `false`, and remains independent of `features.guardianv2.enabled`.

## Testing

Update configuration tests to cover the nested setting, profile overrides, and enabling thread context while Guardian v2 is disabled. Migrate Guardian approval, history, and async scorer tests to the new configuration key.

GitOrigin-RevId: 54a91555eb68001e0adedc8a07bdbc5ea2273f9b
2026-09-05 21:28:11 +00:00
Alex Daley
32351a7b1a Keep refreshed MCP tool catalogs with their clients (#43031)
## Why

Refreshed Apps catalogs need to survive connection reuse. Catalog revisions scoped to the connection set can lose refreshed tools during reconciliation and invalidate prepared calls for unrelated servers.

## What changed

- Store tools, revisions, and refresh coordination on each MCP client, and key cached bindings by client identity and revision.
- Preserve existing binding snapshots while rejecting stale calls before preparation. Wait for active calls to finish before publishing a refreshed catalog.
- Add `CodexThread::refresh_codex_apps_tools` to reconcile the runtime and return the refreshed client's raw Apps inventory alongside tool names eligible under that runtime's generic MCP policy. Keep hidden and disabled tools in the inventory for callers to apply app-specific policy.

## Testing

Add regression coverage for refreshed catalogs surviving client reuse, unrelated calls remaining valid, binding cache invalidation, and refresh snapshots retaining the client's own inventory when another client wins the shared-cache race. Update stale-call and preparation tests to use client-owned catalogs.

GitOrigin-RevId: f2308c81f7474eb31f3380c091c977030123cda2
2026-09-05 15:04:46 +00:00
jif
dee21ec1bc Replace Guardian tickets with parent response IDs (#43002)
## What changed

Capture the ID from `response.created` and pass it as `parent_response_id` in Guardian review and classifier request metadata. Clear the current response ID before sampling retries so tool reviews cannot inherit a failed response's ID.

Request Guardian credits with `guardian_credits_requested` on eligible parent requests. Remove the ticket protocol, transport attachment, and ticket-specific body redaction. Keep ordinary app-server client `parent_response_id` values inside `x-codex-turn-metadata` rather than promoting them to Guardian request metadata.

## Testing

Update coverage for HTTP fallback, WebSocket review reuse, missing response IDs, classifier transport retries, and code-mode yield/resume attribution. Extend app-server tests to verify client metadata placement over HTTP and WebSocket.

GitOrigin-RevId: c1665e56382ecec8d260fc2ca0ecd5e20b0b2391
2026-09-05 13:02:49 +00:00
rgaucher-oai
2bd71f96d4 Refresh session hooks after external plugin updates (#42990)
## Why

Plugin updates made by another process do not notify a loaded session's hook runtime, leaving it with stale hooks.

## What changed

Compare the current plugin hook sources and load warnings with those retained by the hook runtime during turn construction. Refresh hooks when either differs so existing sessions pick up external plugin updates.

## Testing

Add an app-server regression test that updates the shared plugin store without notifying the server and verifies that successive turns in the same thread run the installed hooks across an upgrade and a rollback.

GitOrigin-RevId: d3a2653ac4c069d9d8a02f30e21e4506d76a091c
2026-09-05 12:08:18 +00:00