Commit Graph
14569 Commits
Author SHA1 Message Date
Felipe Coury e6a7862259 Fix clipboard image paste in WSL terminals (#65362)
## Why

VS Code on Windows can interpret `Ctrl+Alt+V` as AltGr input before
Codex receives it. The Windows clipboard fallback also needs to work
when WSL does not import the Windows `PATH`.

## What changed

- Show `Alt+V` in the shortcut guide for WSL sessions in VS Code or when
  terminal detection is inconclusive. Let active bindings and chord
  prefixes take precedence over `Alt+V` and hide the hint when it
  conflicts in the composer.
- Read Windows clipboard images through WinForms, which supports both
  Windows PowerShell 5.1 and PowerShell 7. Try their standard Windows
  installation paths when lookup on `PATH` fails, within the same paste
  deadline.

## Testing

Cover shortcut selection, hint visibility, and `Alt+V` dispatch,
including submitting or queueing a draft when `composer.queue` is
bound to `Alt+V`.

GitOrigin-RevId: ad59ce6c5de65600aa01028f0d173c42a752beae
2026-12-03 00:13:35 +00:00
neerajrj-oai 39b9b74ef2 Allow parent-aware thread ID allocation for local child agents (#65359)
## What changed

Add `ThreadManager::with_child_thread_id_generator` so callers can
allocate a local child's thread ID using its parent's ID before the
spawn edge is saved. Use the regular thread ID generator when there is
no parent or no child-specific generator.

## Testing

Update the spawn publication tests to check that the callback receives
the parent ID and to force a collision by returning that ID, verifying
that the existing thread and graph are preserved.

GitOrigin-RevId: a074d5872b576e0464cd9c29ee67128767098ee2
2026-12-02 23:52:07 +00:00
Benjamin Carlsson 7aa5d4ea3a Deprecate --config and limit it to legacy keys (#65357)
## What changed

Mark `-c` and `--config` as deprecated in CLI help and direct users to
dedicated flags or `config.toml`. Check explicit overrides against a fixed
list of legacy keys before expanding dedicated flags. Reject unknown keys
even without `--strict-config`, including keys inside inline tables and
arrays of tables. The `app-server` subcommand skips the legacy-key check.

Preserve the meaning of positional `features.guardianv3.housekeeper`
overrides by mapping the legacy positions to named fields.

## Testing

Cover unknown nested keys and verify that `codex-exec resume` checks
overrides on both sides of the subcommand while preserving their order.
Test that a legacy positional housekeeper override still sets
`batch_timeout_ms`.

GitOrigin-RevId: ae13d976ad5e13068096c0f2548fdf0ab35535f3
2026-12-02 23:38:59 +00:00
yuhan-oai 3a6ecd7366 Record provider error subreasons in turn analytics (#65356)
## Why

Broad error categories make it hard to distinguish a model missing from
the accessible catalog, an unsupported request value, and a route rate
limit from other failures in the same categories.

## What changed

Carry three structured provider subreasons through `CodexErr` and record
them in `codex_error_subreason` only when they match the turn's terminal
failure.

- `model_not_in_accessible_catalog` for a matching HTTP 400 model-not-found error.
- `unsupported_value` for an HTTP 400 invalid-request error with that code.
- `route_rate_limit_exceeded` for a route-specific HTTP 429 that exhausts retries.

## Testing

Cover subreason mapping, including wrapped WebSocket invalid requests,
and verify that turn analytics omit subreasons for successful turns and
mismatched terminal errors. Exercise recovery from a route-specific
HTTP 429 using `Retry-After`.

GitOrigin-RevId: 02d82082334e775020850e1a52ba7baff401cff1
2026-12-02 23:28:28 +00:00
yansenzhou-oai 5b3615f1fe Use mcp as a --strict-config rejection example (#65355)
GitOrigin-RevId: 50862a09a12dfc475a380880eb1b213faffaead4
2026-12-02 23:26:21 +00:00
willwang-openai 40f961b069 Expose the managed local Codex policy to clients (#65353)
## What changed

Add the boolean `allow_local` requirement. Apply the `true` default
after merging requirements layers, and show explicit values with their
source in the TUI config diagnostics.

Report the effective value as `requirements.allowLocal` in
`configRequirements/read` and update the protocol schemas and generated
client types. Clients should assume `true` when there are no managed
requirements or an older server omits the field. A value of `false`
is informational at this stage.

## Testing

Cover layer precedence, source tracking, rejection of non-boolean values,
RPC responses for explicit and omitted settings, and decoding responses
from older servers.

GitOrigin-RevId: 6cd400cacdf8981e0cabad642019c634549e0074
2026-12-02 23:10:36 +00:00
felixxia-oai 411e0f6235 Trim Guardian evidence by serialized JSON size (#65352)
## Why

JSON escaping can make a shorter tool output field consume more of the
evidence byte budget than a longer field. Ranking by raw string length
can truncate the build log while preserving a quote-heavy field that
takes up more space.

## What changed

When a Guardian response item exceeds the evidence budget, trim its
text fields in descending order of serialized JSON byte size.

## Testing

Extend the inbox truncation test to verify that a quote-heavy tool
result field is truncated while the build log and error summary stay
intact.

GitOrigin-RevId: de78c768e54e0fb020205aa5be14a9b6b3e8c1c9
2026-12-02 22:57:17 +00:00
felixxia-oai d374369121 Deliver oversized Guardian inbox posts as truncated evidence (#65351)
## Why

A board post that exceeds the reviewer's tool output budget on its
own can fail inbox delivery. The reviewer still needs access to the
original because the omitted text may contain restrictions.

## What changed

Keep delivering whole posts in order when they fit on their own. For
a post that exceeds the budget, trim the largest text fields first to
preserve the structure of chat and tool records where possible. Fall
back to a text excerpt if the structured record still cannot fit.

Mark shortened notifications with `truncated: true` and include the
`message_id` so the reviewer can retrieve the original with
`guardian_board.read_post`.

## Testing

Add coverage for preserving smaller fields in oversized tool calls
and results, and for retrieving a deployment restriction omitted
from a shortened inbox notification.

GitOrigin-RevId: 4442c153bc401ea25ce465f52ed42deaea8b9106
2026-12-02 22:56:06 +00:00
dermanyang-oai 40c425a380 Support conversation-scoped MCP tool approvals (#65348)
## Why

An MCP tool approval remembered for a live session is lost when the
conversation resumes in a new session, so the user can be prompted again
for the same tool and linked account.

## What changed

Let hosts attach an `McpToolApprovalStore` to a persistent thread to save
and reuse eligible approvals for host-owned app tools. Each grant is
bound to the authenticated member, thread, and exact tool registration,
including its plugin, connector, and account link.

Reuse a grant only after permission hooks and reviewer policy have run,
and revalidate it before handing off the call. If saving a new grant
fails, stop the call before handoff.

## Testing

Add coverage for approval reuse after resume and compaction, isolation
across forks and member changes, hook and reviewer enforcement, and
failed saves.

GitOrigin-RevId: fd022c19e94e9ceafa97b1dd71478e05c477c36d
2026-12-02 22:40:57 +00:00
Dmitriy Kovalenko 04ea445ecd Overlap MCP refresh with executor capability discovery (#65343)
## Why

When an MCP refresh waits for host setup to finish before reading the
remote executor's MCP configuration, a capability cache miss can make
the two remote reads run back to back.

## What changed

Run host MCP setup alongside remote MCP server discovery. Start the
remote read during host setup and keep its timeout gated on host
completion. Carry the ready capability roots from host setup into the
published runtime.

## Testing

Extend the V1 and V2 overlap tests to hold replies until both requests
are in flight, then verify that the turn can call a tool from the newly
discovered MCP server and receive its result.

GitOrigin-RevId: 729eb6a85e8a8ce6e2549251de9873a0b064d9a7
2026-12-02 22:01:23 +00:00
Owen Lin cffa2fddad Omit the turn-aborted marker when a turn goes to sleep (#65341)
## Why

When a turn wakes after a planned sleep, a synthetic `<turn_aborted>`
message makes the previous turn look interrupted to the model.

## What changed

Skip the model-facing marker for `InterruptIfNoPendingInput`. Continue
flushing the rollout before emitting `TurnAborted` so clients can read
the latest history when they receive the event.

## Testing

Extend the abort lifecycle test to check that the wake-up request
contains the prior agent message and omits the `<turn_aborted>` marker.

GitOrigin-RevId: fd5deb7f926551fa15edd4bab7d83c81842e4270
2026-12-02 21:50:29 +00:00
Benjamin Carlsson 2b282f5c01 Consolidate retained TUI conversation state in BackendThreads (#65340)
## What changed

Move thread event channels and listeners, pending requests, realtime replay
buffers, and side-chat state into `BackendThreads`. Move the Agents overview's
cached thread metadata, unread state, and activity into `OverviewThreads`
within the same container. Keep workspace selection and rendering state in
`AgentsOverviewState`.

## Testing

Add regression tests that verify notification enqueueing returns promptly
when the active thread's channel is full and both notifications are delivered.
Also verify that an active thread receives a history batch without adding it
to the replay buffer.

GitOrigin-RevId: 3aba0d68f6f41ca89f378fe96b949e4a894203f4
2026-12-02 21:48:40 +00:00
felixxia-oai d57d72b3b7 Return Guardian channel summaries on first subscription (#65335)
## Why

Guardian reviewers need earlier user instructions to assess a pending
action. A channel subscription delivers future messages, so reviewers
previously had to look up earlier posts separately.

## What changed

- Keep `guardian_board.get_channels` focused on channel names. On a new
  subscription, `guardian_board.subscribe` returns the selected channel's
  cumulative summary when available and within the tool output budget.
- Guide reviewers to use clear summaries as evidence of earlier user
  grants and restrictions, give later original user instructions
  precedence, and consult original posts when a summary is missing,
  ambiguous, or conflicts with other evidence.

## Testing

Extend the Guardian housekeeping integration test to cover name-only
listings, summary delivery through Code Mode on the first subscription,
and delivery of a later original revocation before the next review.

GitOrigin-RevId: be6582f4497e2a053b1c3caa0cc81fc3ec6e5586
2026-12-02 21:24:47 +00:00
ioanbudea-OAI 56f63e4f1f Simplify local thread reads and rollout metadata resolution (#65332)
## What changed

Use a shared history attachment step for reads by thread ID and rollout
path, including the check that rejects full-history requests for
paginated threads. Keep session metadata reads on the rollout header
path, including when an archive move leaves SQLite pointing at the old
location.

## Testing

Extend the archive and unarchive test to exercise the public metadata
read with a stale SQLite path and invalid UTF-8 after the rollout header
in both legacy and paginated history modes.

GitOrigin-RevId: 9f0c9008069770a6cc14066c362a2d30c4fa2513
2026-12-02 21:01:13 +00:00
Alex Ionescu 7670578418 Report remote plugin archive verification in install telemetry (#65330)
## Why

Remote plugin install telemetry needs enough detail to distinguish archive
verification failures from other bundle errors and associate those failures
with a specific release when its ID is available.

## What changed

- Include the archive verification outcome in successful app-server install
  events. Classify verification failures by reason and attach the
  `plugin_release_id` when available. Use the catalog plugin ID for bundle
  events when it is available.
- Export `codex.plugins.archive_verification` through the configured
  OpenTelemetry logger during standalone CLI installs.

## Testing

App-server tests check successful and failed install analytics. A CLI
integration test checks that an archive verification failure exports the
expected event fields and leaves the plugin uninstalled.

GitOrigin-RevId: ea6cab1d04467d63f43fbd17e3d0a122fad15435
2026-12-02 20:34:56 +00:00
felixxia-oai 5592958044 Preserve attached Guardian reviewer sessions across retries (#65328)
## Why

A transient failure during an approval review could discard the attached
reviewer session and lose context the reviewer had already gathered.

## What changed

Use the Guardian retry policy when finishing an attached review. Honor
the review's session disposition for retryable failures and force
discard for non-retryable errors.

## Testing

Extend the prewarmed root reviewer test to simulate a server overload
after the reviewer subscribes to a channel. Verify that the retry
reconnects with the same reviewer thread ID and carries forward the
subscription result.

GitOrigin-RevId: 5a538e872f71714fee9bbd97ed775969a6893154
2026-12-02 20:19:42 +00:00
rhan-oai ea5f6b303c Recognize host-selected MCP handoffs in Guardian context (#65325)
## Why

Guardian uses native collaboration calls to identify which root-thread
context is relevant to a subagent. When an MCP server supplies those tools,
Guardian needs the server's registration to distinguish a handoff from an
unrelated call with the same name.

## What changed

Let the host opt in to handoff tracking for one local MCP plugin or extension
registration. Match the server name, source, and transport against the tool
registration used for routing. Persist the recipient of a matching direct
`spawn_agent`, `send_message`, or `followup_task` proposal so Guardian can
apply the handoff boundary when selecting context for that subagent.

Record a classification without a recipient for lookalike calls when needed
to prevent fallback to native name matching.

## Testing

Cover context filtering for the selected extension, calls without host
opt-in, and a configured MCP server using the native collaboration namespace.

GitOrigin-RevId: 40471f3cdfde88832c27c3a466e36723e42515d2
2026-12-02 20:09:58 +00:00
felixxia-oai 587c151188 Keep cumulative summaries in Guardian evidence channels (#65324)
## What changed

Ask the Guardian housekeeper to update each channel description from its prior
summary and newly routed evidence in source order. The summary captures relevant
activity, user intent, authorized actions and targets, conditions, exclusions, and
later corrections. The housekeeper attributes authorization to original user
instructions and distinguishes it from assistant proposals and tool reports.
Approval decisions remain with the reviewer.

Apply the same summary guidance with default and custom routing instructions.
Request updates only for new, missing, or changed descriptions, with each summary
limited by the prompt to 250 UTF-8 bytes and 40 words.

## Testing

Update the housekeeping fixture to carry forward staging approval alongside a
new restriction on publishing the release. Verify that the stored description
persists when a later routing response omits it.

GitOrigin-RevId: 72607fb370c18a9e2c570158bef70caa25be338c
2026-12-02 20:09:20 +00:00
felixxia-oai 0d36af2039 Guide Guardian to reuse topic channel names (#65323)
## What changed

Tell the Guardian v3 housekeeper to reuse the exact channel name when a
topic continues. For new channels, ask for a descriptive name that
identifies the topic and its project or target within 128 UTF-8 bytes.
Reflect the naming guidance in the routing schema.

## Testing

Update the recorded review request snapshot and adjust the housekeeping
test fixture so two of the three later evidence items still fit in the
model window with the longer prompt.

GitOrigin-RevId: 5beb4fc6c0ad496c22f3411ed3a8479e6bbbea6e
2026-12-02 20:08:40 +00:00
Ruslan Nigmatullin 923ced7a31 Expose pagination cursors in history and notes tool schemas (#65319)
## What changed

Add an optional `cursor` to requests that list history windows, history
items, or note files, and to requests that search history or note
contents. The schemas tell callers to repeat the same request with
`next_cursor` until the response omits it. In note search, a nested
`next_cursor` resumes matches within that file.

Update the bundled tool contract and model request snapshots to reflect
the schema changes.

GitOrigin-RevId: 0d5a76e0c8406320e320ed3347d656ff2b1b9aa4
2026-12-02 19:53:25 +00:00
jif 1bca83f820 Reuse Guardian v2 async history after large fresh reviews (#65318)
## Why

When a fresh async review already reaches the soft reset limit, adding
evidence can trigger another rebuild that replays the same large transcript
on every check.

## What changed

If a fresh review reports usage at or above
`async_classifier_conversation_token_limit`, allow projected input to grow
up to 20,000 tokens beyond that first report. Use the latest reported usage
to estimate each continuation while keeping the ceiling anchored to the
fresh review. The model's input limit still applies.

For this extra allowance, rebuild when reported usage is missing or the
next request would truncate elastic context or omit whole transcript
entries from the fixed window. A fresh review with elastic truncation
cannot start the allowance.

## Testing

Extend coverage for reuse across multiple reviews, resets at the growth
ceiling and model input limit, missing usage, and transcript evidence
recovered by rebuilding.

GitOrigin-RevId: 4c5c69a898b83e051241b06c324773a0b9e46ede
2026-12-02 19:40:40 +00:00
Alvin 0f5e7be1a7 Show workload identity account details in login status (#65317)
## Why

`codex login status` confirms that workload identity is active, but its
generic status line leaves users unable to tell which identity Codex is using.

## What changed

- For ChatGPT, show the principal ID, workspace ID, and account email when
  available.
- For API access, show the service account ID and project ID.

Read these details from cached authentication metadata and keep the generic
status line when account details are unavailable.

## Testing

Add output snapshots for ChatGPT identities with and without an email and
for API service accounts.

GitOrigin-RevId: a0fb2aafff4a52a2e890e324e939b132c59f5831
2026-12-02 19:25:53 +00:00
thomas f85a6e05eb Support explicitly declared hooks in Agent Plugins (#65316)
## Why

Codex skipped hooks in the Agent Plugin format even when the root
`plugin.json` explicitly declared them.

## What changed

- Discover hooks through the root manifest's `extensions.com.openai.hooks`
  declaration. File declarations must point to regular files inside the
  bundle without traversing symlinks.
- Apply the existing hook approval flow and give Agent Plugin hooks the same
  isolated `PLUGIN_DATA` directory as the plugin's stdio MCP servers.
- Include declared hooks in plugin details and capability detection without
  requiring a writable data directory. For remote catalog entries,
  `plugin/read` gets hook summaries from the matching installed bundle.

## Testing

Cover invalid hook paths and runtime data directory failures, verify that an
approved `PreToolUse` hook writes to isolated plugin data, and check remote
plugin reads with matching, different, and absent local bundles.

GitOrigin-RevId: 86311780865f7c598db22d873e88be2699750b75
2026-12-02 19:09:13 +00:00
Ben Romano ce1c27aa01 Link accepted steer requests to active turn spans (#65315)
## Why

A steer request can arrive in a separate trace from the turn it updates. Recording the turn ID on the input span leaves the relationship implicit in OpenTelemetry.

## What changed

Capture the context of `session_task.turn` when the task starts. When the active turn accepts steering input, add an OpenTelemetry link from the request's `op.dispatch.turn_input` span to the task span. The link is visible even when trace-level input spans are disabled.

## Testing

Extend the turn tracing integration test to check that both steering entry points link to the active task and that initial submissions and stale steer requests emit no link.

GitOrigin-RevId: 1daecd06d8db8a80c8112dff5c65a58142bda4d6
2026-12-02 18:54:34 +00:00
jif 55c21d760b Record input truncation in Guardian review reports (#65313)
## Why

Failed-review reports can include the reviewed thread's history, but they
don't show how much evidence the reviewer lost to input limits. That
makes it harder to tell whether missing context contributed to a denial.

## What changed

Add a `truncated` field to opt-in failed-review reports. It reports
bytes removed from the initial review input by evidence section,
distinguishing per-item caps from cuts made to fit the overall budget.
Carry those totals with the selected response through reconsideration,
including when the original denial is restored.

## Testing

Check that a denied review's report includes transcript bytes removed
by a per-item cap. Cover rendered JSON byte counts, deduplicated
instructions, and eviction of an already-capped tool result.

GitOrigin-RevId: 817ca54ca27969e52cac50f7ff93816c773fcc15
2026-12-02 18:40:51 +00:00
Steve Coffey a5d572b651 Record Guardian token usage on the requesting turn (#65312)
## Why

The requesting thread's rollout lacks per-response token usage for
Guardian work, including requests that consume tokens without producing
a usable result.

## What changed

Persist reported token usage from Guardian reviews, background review
compaction, and classifier requests in the requesting thread's rollout.
Each record identifies the requesting turn, response, and model, and
marks incomplete responses that report usage. These records stay
separate from the thread's cumulative token totals and are excluded from
forked history.

## Testing

Cover review attribution and unchanged parent token totals, compaction
that reports usage without a usable summary, and thread shutdown waiting
for an interrupted classifier's usage write.

GitOrigin-RevId: da5d3711cdb7c7aeab829d3537ef59b724c57171
2026-12-02 18:40:08 +00:00
malsamiri-oai 0e9c6552da Limit Computer Use cleanup notifications to turn metadata (#65311)
## Why

Computer Use helpers only need the thread and turn IDs to clean up
after a turn. The legacy `notify` payload also includes user messages
and the assistant's last message.

## What changed

Send recognized macOS and Windows Computer Use helpers a
`turn-ended` payload containing only the event type, `thread-id`,
and `turn-id`. Codex unwraps saved `--previous-notify` chains and
launches the user's notifier directly with its original arguments
and the full legacy payload, without waiting for cleanup to finish.

## Testing

Add tests for helper recognition, payload contents, and malformed
notifier chains. A Unix process test checks that the saved notifier
receives its payload while cleanup is still running.

GitOrigin-RevId: 1d5cea10b1c92e1828a23bb9eaeb8c008baa86c5
2026-12-02 18:38:45 +00:00
jif d67d903b61 Rebuild Guardian classifier history when the transcript profile changes (#65299)
## Why

A classifier catalog refresh can change which transcript entries count
toward the cursor while the parent model and conversation stay the same.
Reusing the old cursor can skip evidence that the new profile includes.

## What changed

Include the transcript's `ContextProfile` in the classifier conversation
reuse key so a profile change rebuilds history with the current profile.

## Testing

Add a regression test that enables `tool_outputs` after scoring with only
`tool_calls` and verifies that the next request includes both calls and
the newly included output in transcript order.

GitOrigin-RevId: 855f89b476c3c826b1e363e99d2f9605f8181a55
2026-12-02 16:59:20 +00:00
Tom Leach (@toml) 4e2490ec82 Introduce a request type for enqueueing thread messages (#65297)
## What changed

Use `EnqueueRequest` to pass the thread ID, turn input, and optional
Responses API client metadata through a single `enqueue_item` method.
Migrate the app server and queue service tests to this method, and
deprecate `enqueue` and `enqueue_with_metadata` while keeping them as
forwarding wrappers.

GitOrigin-RevId: 9a4e96ca5e7f30b0b6ac7f33ee6c10420df12dba
2026-12-02 16:46:59 +00:00
ioanbudea-OAI 01192c6e19 Enforce session ownership in V1 multi-agent tools (#65287)
## Why

V1 tools could use a thread ID to reach agents in another session. A
thread ID can also resolve to a different runtime after a thread is
unloaded and reloaded.

## What changed

- Check session ownership before sending input, interrupting, waiting on,
  closing, or resuming a V1 agent. Keep live operations bound to the
  runtime that passed the check.
- Check ownership in saved rollouts before resuming agents and their
  descendants. Follow the recorded parent chain for legacy rollouts that
  lack a session ID. Release the agent slot when closing a known ephemeral
  agent that has already been unloaded.
- Preserve failed `wait` calls in thread history and show the failure in
  the TUI without listing rejected targets as completed agents.

## Testing

Add regression coverage for cross-session input, close, and resume
requests, slot reuse after closing an unloaded ephemeral agent, legacy
session recovery, and failed wait history and display.

GitOrigin-RevId: 4712a53315d24d5658d746ed277738e00a4e2dac
2026-12-02 16:21:14 +00:00
jif 1396b2e0e7 Correlate Guardian failure reports with review and response IDs (#65276)
## Why

A turn can contain multiple Guardian reviews, and denial reconsideration
can produce multiple responses for one review. Thread and turn IDs alone
cannot identify which review and provider response produced the recorded
decision.

## What changed

Add `review_id`, `reviewer_request_id`, and `reviewer_response_id` to opt-in
Guardian failure reports when available. Keep the provider IDs with the
selected decision, including the original denial when reconsideration
fails and falls back to it.

## Testing

Extend tests to check the recorded IDs for initial and
reconsidered denials and verify that an invalid retry preserves the
original denial's IDs.

GitOrigin-RevId: 4bd906bfb9a80808cb3c2a8ac71c5354d4caad1f
2026-12-02 15:17:02 +00:00
jif 1df7f6d42b Freeze the clock in permission and skill history tests (#65262)
## Why

When a test spans midnight, the environment date can change between turns
and alter the request history.

## What changed

Use a shared fixed clock for the catalog permission-path model-switch
and repository skill grant history tests. The clock keeps the environment
date stable with time reminders disabled.

GitOrigin-RevId: 7c3ad23547cd9126c6115aeeea6806b32c04dd69
2026-12-02 14:09:46 +00:00
Ben Romano ba4148faaf Continue MCP callback traces into Guardian reviews (#65254)
## Why

When a Node REPL-backed MCP tool requests approval through an elicitation
callback, the trace loses the parent-child relationship between the callback
and the Guardian review.

## What changed

Parent the Guardian review span to the callback span when its
`traceparent` is well formed and its trace ID matches the active tool
invocation. Preserve the invocation's sampling flags and `tracestate`,
and strip both trace fields from the elicitation metadata before it
reaches approval handling or user prompts.

## Testing

Cover callback span parenting and trace propagation to Guardian inference,
including rejection of unrelated trace IDs and malformed headers. Verify
that form and URL prompts retain other metadata while dropping trace fields.

GitOrigin-RevId: 942b61a0da81b5d549c9f4813b28101bba622a26
2026-12-02 13:21:09 +00:00
jif 76d282ae2e Use reported token usage for Guardian v2 soft resets (#65244)
## Why

Conservative image token estimates can trigger a soft reset even when the
completed scoring conversation leaves room for new evidence.

## What changed

Store the reported context token count with each completed scoring conversation.
For the next soft reset decision, add the estimated tokens for new evidence to
that count. Fall back to estimating the retained history when the latest
completion has no usable usage. The hard input limit and metrics still use the
conservative full-request estimate.

## Testing

Cover history reuse after a low usage report, rebuilding after a higher report,
and fallback when usage is zero or missing. Check that a low reported count
cannot bypass the hard input limit.

GitOrigin-RevId: 42557d5b7272e651046e7c06226f757b59b9fa67
2026-12-02 12:22:39 +00:00
Dmitriy Kovalenko ac2a31a717 Prefetch Git attribution policy when a thread starts (#65241)
## Why

The first turn could spend up to five seconds waiting for the workspace
attribution setting. Starting the request during thread initialization
lets it overlap with MCP startup.

## What changed

Fetch the policy in the background for threads using Codex backend
authentication. Reuse the pending lookup on the first turn when it
matches the thread's current authentication generation, and cancel any
unclaimed lookup on thread shutdown.

Cache a disabled policy after a timeout until its retry deadline. Once
the deadline passes, the next lookup can fetch the setting again.

## Testing

The app-server test waits for the settings request before starting the
first turn. The extension test covers retry deadlines across turns for
both prefetched and cached policies.

GitOrigin-RevId: 6f66f6299b56affc6c95558c94381e476a5cc1d8
2026-12-02 11:46:51 +00:00
Felipe Coury 3a3b34c74a Refresh TUI colors on terminal theme changes and focus regain (#65238)
## Why

A terminal theme change could leave the composer using stale colors until
Codex returned from an external editor.

## What changed

On supported Unix terminals, enable live color reporting after startup
prompts have cleared and only when the terminal reports that the mode is
off. Refresh the default foreground and background on theme notifications
and when the terminal regains focus. Read color replies through the same
event stream as keyboard input and redraw when the colors change.

Release the subscription before handing the terminal to an external editor
and check whether it can be re-enabled when Codex resumes.

## Testing

PTY tests cover idle composer redraws, focus refresh without a theme
notification, existing subscriptions, and recovery after missing replies.
They also cover Escape, typing, and interrupt keys during color queries.

GitOrigin-RevId: 0f0d4b057fdc7c2d6813dc08ff284f47824db6b0
2026-12-02 11:39:41 +00:00
jif a5484adce0 Resolve approval reviewers from destination thread settings (#65237)
## Why

The TUI can resolve a fallback `approvals_reviewer` before the
destination app server applies the thread's provider and permissions.
Sending that fallback as an override can select the wrong reviewer.

## What changed

For fresh replacement sessions and startup with a selected profile,
send the reviewer when explicitly configured and otherwise let the
destination app server resolve it from the final thread settings.

## Testing

Cover reviewer selection for remote replacement sessions, profile
startup, and projectless sessions. Verify that embedded forks inheriting
saved permissions retain the saved reviewer.

GitOrigin-RevId: fc9b8f18b021d11e276888c6c6f78fc5db7c8846
2026-12-02 11:38:59 +00:00
jif 258cae0778 Default eligible OpenAI sessions to automatic approval review (#65236)
## What changed

When `approvals_reviewer` is unset, default to `auto_review` for sessions using the OpenAI model provider with `guardian_approval` enabled, effective workspace-write permissions, and an effective approval policy of `on-request` or `granular`. Otherwise default to `user`. Explicit reviewer settings still take precedence over the default, subject to configuration requirements.

When the TUI starts a replacement session on a remote app server, use the server's configured reviewer if the client has no explicit reviewer setting. Update the configuration and app-server schemas to document the new default.

## Testing

Cover reviewer eligibility and managed requirements in configuration tests, manual overrides and empty workspace roots in app-server thread-start tests, and remote reviewer precedence in the TUI replacement-session test.

GitOrigin-RevId: fd05687accddb8a3ab99df0486b93f3f595fef65
2026-12-02 11:38:20 +00:00
jif a7e4b42b4a Decouple local provider setup from codex-core (#65234)
## What changed

Have the TUI and `codex exec` pass the selected provider, optional model,
and HTTP client factory to shared OSS setup. Validate the provider's
`base_url` there and connect to Ollama or LM Studio using that URL and
factory. Return a configuration error when Ollama's URL is missing.

Remove the runtime dependency on `codex-core` from the OSS utilities
and both provider crates. Enable the existing Rustls key exchange
preference and vendored OpenSSL for musl builds directly in the provider
crates.

## Testing

Add coverage for the error returned by each provider when `base_url` is
missing. Extend the Ollama client reuse test to check readiness for an
explicitly selected, already installed model.

GitOrigin-RevId: 747ed51c6fcfa2a0ffc61ba5aa8ea4d033450241
2026-12-02 11:36:47 +00:00
jif 6b36f44a93 Describe exec-only tools in mixed Code Mode (#65223)
## Why

Mixed Code Mode can call MCP tools excluded from both direct and deferred
exposure, but the `exec` description omitted their signatures and server
instructions.

## What changed

Include exec-only tool declarations, shared MCP types, and namespace
instructions in the mixed-mode `exec` description. Cap this material at
64,000 bytes and point to `ALL_TOOLS` for declarations that do not fit.
Tools exposed directly continue to carry their own declarations.

## Testing

Extend integration coverage to verify that both Code Mode variants can
call MCP tools excluded from direct and deferred exposure. The mixed-mode
case checks that an oversized namespace is omitted from the description,
its tools remain callable through `ALL_TOOLS`, and a smaller namespace
still shows signatures and server instructions.

GitOrigin-RevId: 6ad4e68d85f6b2dfdafb8ccd55755d80651c0b6c
2026-12-02 10:51:12 +00:00
Felipe Coury fc8cd2442b Refresh TUI terminal colors after returning from an external editor (#65221)
## Why

The TUI caches the terminal's default colors at startup. If the terminal
switches from dark to light while an external editor is open, the composer
can still use the old background tint when Codex regains control.

## What changed

- On supported local Kitty, Ghostty, and Rex sessions, query the default
  foreground and background through the TUI input stream after returning
  from the editor. Redraw when the reported colors change.
- Drain pending terminal reports before opening the editor, suspending, or
  exiting. If the drain times out before an editor handoff or suspension,
  keep the TUI active, preserve input, and show an error.

## Testing

Add pseudo-terminal tests for the updated composer tint, stale Enter
handling on editor handoff, and draft preservation and report draining
after editor and suspend timeouts.

GitOrigin-RevId: 7f438a7df26d602bf975695c27a9f431432d16cf
2026-12-02 10:36:43 +00:00
Adam Perry @ OpenAI 065513215b Support model-facing IDs in environment context (#65218)
## Why

When an environment detaches after a session resumes, the context update
needs to mark it unavailable under the same ID the model saw earlier.

## What changed

Render environment entries with session-scoped aliases such as `env731`
when a mapping is supplied. Save the aliases and naming mode in snapshots
so removal updates can use the recorded names and the naming mode survives
when the last environment detaches. Keep registered IDs as snapshot keys
for compatibility with existing rollouts. The session still renders
registered names.

## Testing

Add regression tests for removing the last aliased environment after resume
and refreshing the context when a saved snapshot has inconsistent IDs.

GitOrigin-RevId: 730fe3d366a9e0bc3e5eb9c6139051901c4f5f96
2026-12-02 10:20:41 +00:00
Charlie Weems 1805912776 Add a configurable maximum width for TUI conversations (#65216)
## Why

On wide terminals, the transcript and prompt box can span more columns than
users want for comfortable reading and editing.

## What changed

Set `tui.max_conversation_width` in `config.toml` to cap the transcript and
prompt box in fullscreen and inline modes, including the startup composer.

```toml
[tui]
max_conversation_width = 80
```

The setting accepts values from 20 to 65,535 terminal columns. When unset,
the conversation uses the available width. Raw inline scrollback keeps native
terminal wrapping, and wrapped links in formatted history and command previews
retain their full destinations.

## Testing

Add regression coverage for config validation, startup and live layouts,
inline history reflow after a config reload, and links that wrap across rows.

GitOrigin-RevId: 91e1856776986fee3b540247c3fbfe5f083b297f
2026-12-02 10:19:11 +00:00
Anton Panasenko 07753325c6 Add WebSocket fallback for OAuth SSH tunnels (#65212)
## Why

Networks that block HTTP/3 and HTTP/2 `CONNECT` can prevent
`codex tcp-tunnel` from establishing an SSH connection.

## What changed

In the default `auto` mode, keep the TCP attempt available when HTTP/3
`CONNECT` is blocked. If HTTP/2 `CONNECT` returns 405, 501, or a 403 with
a `Server` header starting with `Zscaler/`, retry once over an HTTP/1.1
WebSocket. Use WebSocket directly when TLS negotiates HTTP/1.1. Ordinary
authentication and authorization rejections stop setup. The attempts
share the gateway, proxy route, TLS trust, and setup deadline.

Use `--transport websocket` to force WebSocket or `--transport connect`
to use only HTTP/3 and HTTP/2 `CONNECT`. Legacy JWT tunnels use
`CONNECT`.

Preserve independent EOF in both directions. When the remote side
finishes writing, close the output pipe to OpenSSH so it sees EOF
while upload can continue.

## Testing

Add TLS-backed tests for fallback after blocked `CONNECT` responses,
half-close in both directions, terminal gateway rejection, certificate
verification before credential loading, and redirect rejection.

GitOrigin-RevId: cfbbd81a3836da8d1f12bed61bb03c9dfb3674ce
2026-12-02 09:56:45 +00:00
Eric Traut aa433cb350 Show staged changes in /diff (#65211)
## Why

`/diff` skipped staged patches, so users could miss changes that would go into their next commit.

## What changed

Compare the index with `HEAD` and the working tree with the index. Show the staged patch under **Staged** and, when both are present, put the remaining patches under **Unstaged and untracked**. Keep Git operations local and show a warning alongside the working-tree patches if the staged comparison fails.

## Testing

Cover staged files before the first commit and a staged edit that is reversed in the working tree. The tests also cover the staged comparison warning, missing blobs without a fetch, and the refreshed sidebar rendering both sections.

GitOrigin-RevId: 2cb032d7766caf313363eb4c330abb3f6a95f017
2026-12-02 09:55:35 +00:00
arnavpatidar-OAI d62166e0c8 Require a client ID for config server OAuth discovery (#65200)
## Why

Config server OAuth discovery falls back to `codex` when no client ID
is configured. That can select the wrong client for the server.

## What changed

When discovery finds OAuth metadata but no client ID is configured,
return an error that points to `gateway.auth.client_id` and
`config_server.oauth.client_id` in `requirements.toml`.

## Testing

Cover missing client IDs both with and without discovery overrides, and
verify that an explicitly configured `codex` client ID still works.

GitOrigin-RevId: 26e7f7176dcc2ea6aa71bd3b0bc9b0dbf5bf7fbb
2026-12-02 08:36:59 +00:00
alexsong-oai 986dc881be Expose gateway spend in app-server account rate limits (#65193)
## Why

Clients need to show the spend and cap for the account behind a thread's
model provider. The existing ChatGPT usage read cannot provide those
figures for a gateway account.

## What changed

- Route `account/rateLimits/read` through the provider's configured
  `usage_url` using the provider's credentials. An optional `threadId`
  selects a loaded thread's provider for the account-wide read. Omitting it
  selects the default provider.
- Return `usageUnavailable` for a thread whose provider has neither a
  usage endpoint nor first-party authentication. Surface gateway errors
  without falling back to ChatGPT usage.
- Report monthly gateway spend in `individualLimit` as exact USD decimal
  strings, with `limit: "unlimited"` for uncapped accounts. Use
  `spendControlReached` for the gateway's cap status. Spend snapshots
  identify their unit as `usd` or `credit`, with omitted units defaulting
  to `credit` for compatibility.

## Testing

Add integration coverage for thread-specific provider selection, gateway
usage taking precedence over ChatGPT without fallback, and reuse of an
existing gateway OAuth session without interactive login.

GitOrigin-RevId: e6ec9d83eecc3084fcc98e72e2c031bd3e53a2cd
2026-12-02 07:59:18 +00:00
Benjamin Carlsson a3bca8a1b5 Validate thread identity across TUI backends (#65190)
## Why

Different backends can return the same thread ID. A Cloud environment
selection must apply to the draft on the backend that opened the picker.
When the TUI reads or resumes a specific thread, an unexpected server
response can otherwise attach history or apply settings to the wrong thread.

## What changed

- Match Cloud environment selections against both the backend and the draft
  thread ID.
- Reject mismatched thread IDs in read and resume flows before hydrating
  history or applying resume permission settings. Preserve subscription
  bookkeeping so a rejected resume can still be cleaned up.

## Testing

Add regression coverage for a thread start that reuses an ID from another
backend and a mismatched resume that preserves the active conversation,
composer draft, and approval override without sending a settings update.

GitOrigin-RevId: 603efe7aa37e510dacf91b58487a94469c7f183d
2026-12-02 07:29:37 +00:00
arnavpatidar-OAI 283fca1c98 Extend OAuth configuration for managed gateways (#65188)
## Why

Setting custom OAuth scopes or a client ID for a managed gateway required
hard-coding the authorization and token URLs, even when the server
published them through discovery.

## What changed

Omit both `authorization_url` and `token_url` in `[gateway.auth]` or
`[config_server.oauth]` to discover the endpoints while configuring
`client_id`, `scopes`, `resource`, `redirect_port`, or
`device_authorization_url`. An OAuth block that relies on discovery
produces an error if metadata is unavailable.

Managed gateways can also set `gateway.requires_openai_auth` and
`gateway.auth.delivery` for inference. For example, a gateway can use
`Authorization` for the OpenAI credential and receive its OAuth token
in `X-Gateway-Authorization`. Enrollment rejects configurations that
would send both credentials in `Authorization`.

## Testing

Add coverage for discovery overrides, missing discovery metadata,
invalid OAuth settings, and gateway token delivery.

GitOrigin-RevId: 84e0c219c9eb78d4be538e9131e15ab39fd597b9
2026-12-02 07:13:07 +00:00
Benjamin Carlsson 7f7a1aa16d Add Cloud voice signaling and protect realtime diagnostics (#65186)
## Why

HTTP and WebSocket diagnostics can record sensitive realtime data, including authorization headers, SDP offers, call IDs, and audio or transcript payloads.

## What changed

Add an account-bound app-server WebSocket for Codex Cloud voice signaling. The socket initializes without subscribing to the thread, so transcript and approval events stay on the native thread attachment. Estimate server time from the WebSocket upgrade's `Date` header so admission deadlines tolerate local clock skew.

Disable HTTP request and response logging for realtime call creation. Suppress raw WebSocket upgrade and realtime frame traces, filter sensitive Tungstenite diagnostics across TUI log sinks, and keep call details and event payloads out of debug output.

## Testing

Add coverage for denied Cloud voice endpoints and missing or invalid server dates. Exercise call creation and WebSocket exchanges with trace logging enabled to check that sensitive values stay out of the captured logs.

GitOrigin-RevId: d51a3cff7f5908685e2babbf675561cb8e57ba0e
2026-12-02 06:57:24 +00:00