Commit Graph
6474 Commits
Author SHA1 Message Date
Benjamin Carlsson 9a5a78925d Add a Cloud environment picker for new TUI conversations (#61974)
## What changed

- Open a searchable picker with `Ctrl+X E` to choose a saved personal or workspace environment, or use Default with the current GitHub project when available.
- Show the selected environment above the composer and expose `tui.keymap.global.choose_cloud_environment` for custom bindings.
- Preserve the composer draft and staged model, reasoning effort, and service tier when changing environments. Remember the saved environment when cycling through a local host and back to the same Cloud backend.

## Testing

Add coverage for picker search and selection, dismissal without losing the draft, keyboard routing, environment label truncation, staged settings on the first turn, and saved-environment reuse after host switching.

GitOrigin-RevId: ac9036fd46b252286852df4d792418a3330bae73
2026-11-17 05:52:43 +00:00
cassirer-openai c826ca1286 Preserve accepted tool outputs and local resets in rollout traces (#61973)
## Why

Accepted tool outputs may never appear in a later inference request, and request preparation can strip their history IDs. Replay needs to retain these outputs and match them to later snapshots, including trimmed results and outputs with identical wire bodies.

## What changed

- Capture accepted function and custom tool outputs, preserving their acceptance order, identity, and tool provenance during replay.
- Record stripped tool output IDs alongside inference requests so replay can restore identity without changing the captured wire payload. Reuse accepted items and adopt their first model-visible snapshot bodies.
- Record compaction checkpoints for local context-window resets using the selected input and frozen installed history, including goal edits retained during installation.
- Exclude `configuration_update` items from normalized conversation history.

## Testing

Add replay coverage for outputs accepted without subsequent inference, trimmed results, identical outputs with distinct IDs, and acceptance before or after a request snapshot. Extend checkpoint coverage to verify that retained goal edits are captured and later edits do not alter the checkpoint.

GitOrigin-RevId: 70f737782f5000812f389a4e01b9f9690e39549f
2026-11-17 05:35:07 +00:00
Benjamin Carlsson 39b5903898 Set explicit image detail in the restored-history prewarm test (#61969)
Construct the injected image as a `ResponseInputItem::Message` with
`ImageDetail::High` in the restored-history prewarm scenario.

GitOrigin-RevId: 6a414d2c52cb4d2195e6721365c97677c49c956e
2026-11-17 05:17:42 +00:00
Adam Perry @ OpenAI d8d840d32a Capture local attachments before queuing turn input (#61962)
## Why

Queued input can outlive its local attachment files. Reading those files only when rendering a model message can lose media submitted while turn admission is pending.

## What changed

- Introduce `ResolvedUserInput` to carry captured image bytes, audio data URLs, or read errors through session queues and agent input.
- Resolve client attachments on the submitting host before queuing, using a blocking task for local file reads.
- Render messages from captured payloads while preserving original paths and text spans for display, along with image position mappings.

## Testing

Add coverage for rendering and serialization after source files are removed, steered audio retained during pending admission, and local audio errors and display content.

GitOrigin-RevId: 4bbb6bda44167439a8cfdae15d3c476a7b1d336b
2026-11-17 04:08:00 +00:00
bkotsopoulos 65a4450886 Prewarm restored file images on cold resume (#61959)
## Why

Cold resumes warm only base instructions, leaving historical file images out of the WebSocket warm-up.

## What changed

- Add the disabled-by-default `restored_history_prewarm` feature flag.
- Start the WebSocket handshake while history loads, then build the warm-up from restored settings and history when it contains file images.
- Retain the socket and normalized-image cache but discard the image warm-up response ID, so generation resends the full current history and subsequent turns continue from the real response.
- Keep base warm-up for history without file images and defer image preparation to generation when the handshake falls back to HTTP.

## Testing

Add request-history tests and snapshots covering text-only history, interrupted and injected images, resuming with a vision model after image omission, and HTTP fallback without duplicate image resolution.

GitOrigin-RevId: 9a828f44ef0952f7335b5a8c0f7844a069f90d80
2026-11-17 03:48:25 +00:00
rhan-oai 44834c58fa Support turn-scoped exhaustion in host usage accounting (#61958)
## What changed

- Add `UsageAccountingDecision::ExhaustedForTurn` so hosts can fail the current response with `SessionBudgetExceeded` while leaving later turns and peer threads eligible.
- Preserve completed response output and token usage before reporting exhaustion, and track posted charges to avoid accounting twice.
- When steering or mailbox preemption stops a stream, wait for accounting of any completion already observed before starting a follow-up request, and propagate budget errors.

## Testing

Add coverage for preserving output and usage on turn exhaustion, successfully starting a later turn, and reporting turn exhaustion during steering.

GitOrigin-RevId: e673bf30775f27a057fdc39d8429b74ff22121db
2026-11-17 03:28:51 +00:00
Eric Traut 1443c64c62 Add undo and redo to the non-Vim prompt composer (#61954)
## What changed

- Add configurable `composer.undo` and `composer.redo` actions to the keymap picker. Default undo shortcuts are `Alt+Z` on Unix, `Ctrl+Z` on Windows, and `F7`, with `Super+Z` also available on macOS. Add `Shift` to redo.
- Group contiguous typing and consecutive Backspaces into separate undo steps, and keep detected paste bursts separate from preceding typing. Restore complete drafts, including attachments and large pastes.
- Make startup draft transfers undoable, preserve editing history across Vim mode changes, and clear history when a submitted draft is consumed. Track edits while disconnected so new input invalidates redo.

## Testing

Add regression coverage for grouped edits, paste detection and selection replacement, clipboard images, startup draft transfers, disconnected editing, and keybinding conflicts.

GitOrigin-RevId: 46cadf3c69320367dc972e47e0e8b3d3aac3c4ec
2026-11-17 03:15:14 +00:00
Adam Perry @ OpenAI 5b3d2c7fce Extract user input preparation into codex-user-input (#61949)
## What changed

Move local attachment snapshotting and conversion from `UserInput` to model request content out of `codex-protocol` into a dedicated `codex-user-input` crate. Update core, the TUI, and the queue extension to use the new crate, replacing the `ResponseInputItem` conversion methods with `from_user_input`.

Move the associated attachment and message conversion tests alongside the implementation, preserving coverage for image positions, media labels, serialization, and error placeholders.

GitOrigin-RevId: 77d0f94a4cd4c2edc008b9e2e63a989995aab058
2026-11-17 02:43:52 +00:00
Ankush Gupta 0637230e89 Include enclosing tool context in nested Guardian approvals (#61946)
## Why

A nested MCP approval can arrive while its enclosing tool invocation is still running. Follow-up Guardian reviews may use a transcript delta that no longer includes that invocation, leaving out the context in which the nested action was requested.

## What changed

- Add the disabled-by-default `guardian_nested_approval_context` feature to include the host-verified enclosing tool name and arguments in synchronous nested approval requests, while preserving the nested action as the action under review.
- Match the enclosing invocation by call ID and omit ambiguous or unavailable evidence. Exclude Node REPL JavaScript preflight requests.
- Admit enclosing-call context only when it fits the remaining fixed or elastic budget, without displacing ordinary transcript evidence or screenshots.

## Testing

Add MCP elicitation coverage and a request-history snapshot for independent nested reviews and transcript deltas. Add tests for call-ID matching, budget-based omission, and screenshot priority.

GitOrigin-RevId: 9c44a0e8f29f84f84a5322b8362f910f2c91ac55
2026-11-17 02:31:45 +00:00
rhan-oai 34c7cbb454 Allow host-started forks to inherit the root session ID (#61945)
## Why

Host-started forks rejected `InheritedSessionId`, preventing hosts from assigning the root session ID to forked children as they already could for fresh children.

## What changed

Accept `InheritedSessionId` for new or forked threads started directly by the host. Resumed threads continue to use persisted session IDs, and native children continue to use their controller's session ID.

## Testing

Extend hosted-child tests to cover prepared forks, verify that inherited session IDs persist across resume while thread IDs remain distinct, and check that explicit session inheritance is rejected for resumed threads and native children.

GitOrigin-RevId: 90fd24a25e4e927c48395dfae7186bb7fd0e537e
2026-11-17 02:15:09 +00:00
viyatb-oai c656014177 Centralize exec-server launches in WrappedSandboxCommand (#61942)
## What changed

- Move process spawning and Windows token session preparation into `codex-sandboxing`. Keep filesystem overrides, proxy enforcement, and the restricting SID with the prepared command, and reject conversion to a plain command request when a Windows session launcher is required.
- Route shell snapshot capture and replay through the prepared command. Limit script replacement to the submitted shell invocation while preserving its sandbox, environment, and proxy.
- Pass borrowed launch facts to sandbox integrity checks, and distinguish explicitly supplied runtime readable paths from automatic proxy CA bundle discovery.

## Testing

Extend coverage for Windows TEMP permissions and managed proxy routing with empty workspace roots, native launch and prewarm input validation, and proxy availability after the process leader exits while a descendant holds stdout open.

GitOrigin-RevId: fe2bdb9e44f4fb273295fbde66b44bf01f0b7fbc
2026-11-17 02:02:21 +00:00
Chris Dong 1d97869412 Route turn-start client metadata through a dedicated helper (#61941)
## What changed

Add `apply_start_responsesapi_client_metadata` and use it in both turn-start paths. The helper delegates to `update_responsesapi_client_metadata`, preserving existing metadata behavior.

GitOrigin-RevId: 6eb677592492bec5847257ef7162d4002834570d
2026-11-17 02:01:50 +00:00
ningyi-oai cc356fd384 Preserve partial Git metadata when worktree status is slow (#61939)
## Why

Memory requests have a one-second Git metadata deadline. Waiting for all Git lookups together discards an already observed HEAD or remote URL when the worktree scan exceeds that deadline. Shared status scans can also describe a different HEAD from the independent lookup.

## What changed

- Publish HEAD, verified remote URLs, and worktree status incrementally, retaining available metadata at the memory request deadline.
- Read HEAD and change status together using Git porcelain v2, and reject status observations that conflict with an independently observed HEAD.
- Run a positive-only change probe over up to four recently modified root directories during memory extraction preparation. Use a completed probe only when full status is unknown and its HEAD matches the request metadata, without waiting for it before sending the request.

## Testing

Add coverage for partial metadata at the deadline, delayed lookups, stale and unborn HEAD observations, positive-only probes, shared scans, and porcelain parsing. Extend remote credential redaction coverage to partial clones.

GitOrigin-RevId: e7b7c250bfc0e23fb8962fcd5cd5febd7c69e2bd
2026-11-17 01:59:51 +00:00
jif f8e58064fc Preserve remote compaction summaries when interrupting child agents (#61916)
## Why

Child agents configured to interrupt at item boundaries should retain the summary when interrupted during remote compaction. An interrupt during post-turn compaction should also preserve the answer already completed.

## What changed

- Keep sampling interrupt registration active through summary installation, then honor the pending interrupt without running post-compaction hooks.
- Deliver an already completed answer when post-turn compaction is interrupted.
- Keep queued follow-ups for a new turn instead of continuing the interrupted turn.

## Testing

Add a streaming scenario test and context snapshot covering interrupts during mid-turn and post-turn remote compaction. Verify that resumed requests retain the summaries, the completed answer is delivered, and each queued follow-up starts a separate turn.

GitOrigin-RevId: 939eb8b3ed24dbdbff10c9f62226e38a0198fd6f
2026-11-16 23:58:12 +00:00
viyatb-oai c9df641eac Preserve native sandbox executable paths and PTY dispatch names (#61910)
## Why

Sandbox helpers with non-UTF-8 paths can lose their exact executable path when converted into command requests. PTY launches with a custom `argv[0]` can also try to execute the dispatch name instead of the configured program.

## What changed

- Carry native executable paths through sandbox requests, local execution, shell snapshots, and sandbox integrity checks.
- Use native Unix PTY spawning when `argv[0]` differs from the executable, preserving the dispatch name and controlling terminal setup.
- Preserve PTY executable lookup through the child environment's `PATH` and fallback to its home directory when the requested working directory is missing.

## Testing

Add regression coverage for non-UTF-8 sandbox helper paths, PTY dispatch names, child `HOME`/`PATH` lookup, controlling terminals, and exit-code preservation.

GitOrigin-RevId: 6a2af0486220d98195f5d67fde2597e3c4515e11
2026-11-16 23:26:42 +00:00
jif cff061fca9 Add opt-in item-boundary interrupts for subagents (#61909)
## What changed

Add the multi-agent v2 setting `interrupt_at_item_boundary`, disabled by default. When enabled, `interrupt_agent` lets a subagent finish and retain its current output item while cancelling tools immediately. Later output items are discarded, and retained tool calls that have not run receive an aborted result.

Wait for the interrupted turn's terminal event before starting follow-up input, and prevent idle contributors from restarting the interrupted child.

## Testing

Add streaming tests for retaining an assistant message or tool call, discarding later output, and preserving history and follow-up input when the child resumes. Update configuration and interrupt-routing tests.

GitOrigin-RevId: 8b2b9b1383bfb4eefea7369a40012bebc5fff07b
2026-11-16 23:26:07 +00:00
sayan-oai ce7079b506 Add opt-in UTC dates to environment context (#61897)
## What changed

Add the disabled-by-default `utc_environment_date` feature to compute the model-visible environment date in UTC and render it as `<current_date_utc>`. Preserve local dates when the feature is disabled.

Track the date's time basis in environment snapshots so switching to UTC emits an update even when the date is unchanged. Use the matching date tag when reporting an unavailable clock.

## Testing

Extend coverage for UTC midnight rollover, unchanged dates within a day, legacy snapshot refresh, and date removal and recovery. Update local and remote compaction snapshots to exercise the UTC date tag.

GitOrigin-RevId: 6e983d05ca2914629c9f8575e2efe3ed274a2f77
2026-11-16 22:27:05 +00:00
cassirer-openai ef6ce8100a Bound rollout trace capture with configurable storage limits (#61896)
## What changed

- Add `rollout_trace.max_payload_bytes` and `rollout_trace.max_bytes`, defaulting to 64 MiB per body or separated value and 256 MiB per bundle. Root and child threads share the bundle budget.
- Record explicit truncations and omissions when limits are reached, reserve space for later events, and stop at the last complete event if the event log fills.
- Reuse identical prepared-prompt items and store inline images separately from message structure. Preserve exact JSON bytes for complete composite payloads and surviving content and links in partial captures.
- Let reducers handle partial payloads while retaining lifecycle information and reporting `closed_with_partial_payloads` for closed bundles with incomplete captures.

## Testing

Add coverage for payload reuse and byte-exact reconstruction, truncation, compressed bundle budgets, later events after omissions, readable prefixes after event-space exhaustion, and CLI capture-limit configuration and startup failures.

GitOrigin-RevId: be99a68da427414a7a12bf8209f232c1a0bbe545
2026-11-16 22:26:31 +00:00
RJ c0d47262f3 Acknowledge agent messages and clarify how to wake idle recipients (#61894)
## What changed

Return `Message accepted.` from the v2 `send_message` tool. For non-root recipients, also advise using `followup_task` when an idle agent should act immediately. Messages to the root agent receive only the acknowledgment.

## Testing

Assert the acknowledgment when a child messages the root agent, and update the idle-eviction follow-up snapshot to include the guidance for non-root recipients.

GitOrigin-RevId: bb0cf6039d9b693052a1747daa2e75fa25c13522
2026-11-16 22:07:07 +00:00
jif 3257e1b3eb Allow model metadata to control multi-agent tools in code mode (#61854)
## What changed

Add optional `multi_agent_tools_in_code_mode` model metadata to control whether native multi-agent tools follow the model's `tool_mode`. When `true`, expose them according to `Direct`, `CodeMode`, or `CodeModeOnly`; when `false`, keep them direct-only. When omitted, preserve the `multi_agent_v2.non_code_mode_only` runtime setting.

## Testing

Add coverage for metadata overrides and runtime fallback across all three tool modes, plus serialization and deserialization of absent, null, and boolean metadata values. Update the namespace-prefix integration scenario to enable code-mode tools through model metadata.

GitOrigin-RevId: be90f436066226bf9971cbd17f28c396341bb83a
2026-11-16 18:54:05 +00:00
viyatb-oai effad7568c Allow network policy to enable transparent TCP capture (#61851)
## What changed

- Add `transparent_tcp` to network configuration and managed requirements, defaulting to off. When enabled, route outbound TCP from managed Linux sandbox commands through the managed SOCKS5 proxy without requiring an executor startup flag.
- Propagate the setting through local and remote execution, require an enabled SOCKS5 proxy, and check the executor's `networkProxyTransparentTcp` capability before remote launches.
- Refresh the live proxy when switching between permission profiles with different network settings.

## Testing

Add coverage for configuration-driven sandbox capture, rejection of unsupported launch contexts, execution parameter propagation, and live permission profile changes.

GitOrigin-RevId: c4db87056de116f433a128806bef673802f35397
2026-11-16 18:19:16 +00:00
jif e5839cbc59 Preserve aggregate turn diffs across steering (#61820)
## Why

A steer can restart sampling within the same turn. Recreating the diff tracker loses earlier edits, and changing the working directory can change the meaning of relative diff paths.

## What changed

Keep the diff tracker for the lifetime of the turn and retain each environment's first display root. Refresh cached diff headers when new environments are added. Emit the final aggregate `TurnDiff` before `TurnComplete` instead of at sampling completion.

## Testing

Extend regression coverage for steering during the final flush, with and without additional patches and with a changed working directory. Check final diff ordering across continued sampling and header updates when adding an environment.

GitOrigin-RevId: fbd1ebef072d8486a324190c9125fc1446510802
2026-11-16 14:18:24 +00:00
felixxia-oai 0370e34fe8 Route Guardian housekeeping through its dedicated sampler (#61799)
## What changed

Use `HousekeeperSampler` for evidence routing instead of starting a separate review-session thread. The housekeeper now owns a tool-free model conversation, retains completed routing batches, and evicts whole batches under context-window pressure.

Commit sampled history only after all board writes succeed and the evidence cursor advances. Stop the worker after a routing error or an interrupted routing future. Cancel routing when the account changes while allowing accepted appends to finish before shutdown.

## Testing

Extend housekeeping integration coverage for retained history, whole-batch eviction, transient retries, retry exhaustion with `Retry-After`, HTTP fallback, credential renewal, command-token rotation, and shutdown waiting for accepted evidence appends.

GitOrigin-RevId: 316ab1b90529e2a5874e617855d38c41f232872a
2026-11-16 12:05:11 +00:00
felixxia-oai 9544f09e7b Wire Guardian V3 housekeeping into the app server (#61797)
## What changed

- Install Guardian V3 with a local message-board host when the server enables `features.guardianv3.enabled`, independently of thread overrides.
- Clear inherited user, thread, and project instructions from Guardian V3 private threads and skip repository instruction discovery.

## Testing

Add integration coverage for routing the first live message while the actor is still sampling, for both new and resumed threads. Verify that resumed history is skipped, `AGENTS.md` reaches only the actor, and thread overrides cannot enable or disable server-level housekeeping.

GitOrigin-RevId: 3f3ae1be404c9e17b73eea12c95f5a95c96052cf
2026-11-16 12:03:11 +00:00
felixxia-oai cd18053706 Add lifecycle-managed Guardian housekeeping (#61795)
## What changed

- Add an `install` entry point that registers thread and turn lifecycle hooks for Guardian housekeeping. Coalesce user-message and turn-end wakes into one worker per eligible root thread, flushing history before routing durable evidence in order.
- Run the housekeeper in an isolated, ephemeral model thread with no tools. Cancel and join its tracked tasks on root shutdown, waiting for accepted evidence appends to finish.
- Give each routing batch a 90-second deadline, make channel listing and updates cancellable, and redact model response content from JSON parsing errors.

## Testing

Extend housekeeping tests to cover stalled channel creation, redacted model errors, and shutdown waiting for an accepted evidence append without leaving a persisted housekeeper rollout.

GitOrigin-RevId: 519b539c0613c964bac7b18eb84e684f5e105640
2026-11-16 11:50:55 +00:00
ioanbudea-OAI 95946faafc Strengthen workspace-write configuration tests (#61785)
## What changed

- Exercise an explicit `PermissionProfile` in the additional writable roots test on non-Windows platforms, while preserving Windows coverage of the default read-only fallback.
- Assert that enabling memories preserves write access to the working directory on non-Windows platforms.

GitOrigin-RevId: ae25690a56825b47ca38e42fece1fdd7a42b48a4
2026-11-16 10:49:08 +00:00
zm-oai 5a6bbd29a4 Clarify shell-specific login guidance for exec_command (#61744)
## Why

The `login` description claimed a fixed default and described Unix shell flags for every shell. In PowerShell, disabling login startup skips profiles, which can make profile-defined commands unavailable.

## What changed

Describe omitted `login` values as inheriting the setting. When a turn environment reports PowerShell, explain that `login: false` skips profiles and advise keeping profiles enabled for commands that depend on them, including unattended commands.

## Testing

Add coverage for shell-specific descriptions, remote environment readiness, and exact normalization of PowerShell wording in portable tool snapshots. Update prompt-prefix compatibility checks and affected snapshots.

GitOrigin-RevId: f6cb29c6c32921241cbd1be0c31f985c5ae274f9
2026-11-16 04:54:23 +00:00
Charlie Marsh f1ebc7b372 Reuse matching thread inventories for lightweight MCP status pages (#61738)
## What changed

Reuse connected thread tool inventories for paginated `ToolsAndAuthOnly` status requests when registrations, client settings, permissions, environments, and authentication match. Restrict reuse to connections with fixed credentials; discover remaining servers separately and preserve enterprise-managed servers' admitted thread connections.

Bind status configuration to the same environment and permission inputs used by the thread runtime, and limit authentication-failure inspection to the requested servers.

## Testing

Extend status tests to cover fixed-credential reuse, fresh discovery for stored OAuth authority, full resource discovery, and inventories for dormant threads without starting their runtime connections. Verify that paginated lightweight results keep same-named servers in different environments separate.

GitOrigin-RevId: eaca6365fb2a739eaad76eefdc62ec9f796b1024
2026-11-16 03:40:21 +00:00
tongzhou wang 3b8bd2ee7e Add request IDs and attempt numbers to model request hooks (#61587)
## Why

Model request hooks need to correlate attempts belonging to the same generation across retries and model fallback.

## What changed

Add `request_id` and one-based `attempt_number` fields to `PreModelRequest` and `PostModelRequest` inputs and their generated schema. Keep the request ID stable across retries and increment the attempt number for each call to open a response stream.

## Testing

Extend hook tests to verify matching request IDs and increasing attempt numbers across retries. Extend the background compaction scenario to verify that its pre/post hooks share an ID distinct from the ordinary sampling request.

GitOrigin-RevId: 2d85ad6fd630505a89a712cebab6ca0f731610c9
2026-11-15 00:39:00 +00:00
tongzhou wang eaa25e1f43 Refactor rollout budget checks and turn completion state (#61583)
## What changed

- Centralize generation admission checks before request contributors run for HTTP and non-warmup WebSocket requests.
- Route pending input and inline compaction through dedicated budget checks, and centralize post-compaction budget handling.
- Preserve whether any checkpoint was installed when remote compaction combines a background candidate with foreground compaction.
- Track accepted final answers separately from trailing commentary and encapsulate the response state shared by stop and after-agent hooks.

## Testing

Update the plan-mode contributor test to verify that contributed commentary is tracked separately from final answers, and adapt stream-event assertions to the phase-aware assistant text representation.

GitOrigin-RevId: 43b663e92bfd24ec7e5a0778b711938f16a7fea4
2026-11-15 00:03:59 +00:00
tongzhou wang ce82e38b16 Gate new rollout work on shared budget exhaustion (#61582)
## Why

A budget can be exhausted while another thread waits to start work. New requests, tools, and automatic turns must observe that stop without discarding an already-consumed response whose cost exhausted the budget.

## What changed

- Share a work gate across the rollout tree while preserving native and host accounting ownership.
- Recheck the budget before HTTP and WebSocket requests, hook execution, tool dispatch, and compaction. Prevent automatic wakeups and late input from restarting stopped work, leaving pending input queued.
- Record response costs without rejecting the consumed response solely because its bill exhausts the budget, and stop new work when enforced accounting overflows.
- Expose a thread-registration receipt that remains committed after unload.

## Testing

Extend rollout-budget coverage to verify that accepted response text remains in history after exhaustion and that waiting tools observe the shared stop while completed tools retain their results.

GitOrigin-RevId: e583d657c6f29e374d374cdb014bf23fd6c28614
2026-11-15 00:03:23 +00:00
tongzhou wang 2e61e8ec4e Record neutral interruption markers for rollout budget stops (#61581)
## Why

Turns stopped by an exhausted rollout budget need a history marker without attributing the interruption to the user.

## What changed

- Record and flush a `<turn_aborted>` marker before the terminal event for `SessionBudgetExceeded`, respecting the interrupt-message setting.
- Use neutral guidance in a `developer` message for automatic budget stops.
- Centralize tool-start budget checks across parallel dispatch, tool handlers, and MCP handoff, retaining the check after tool-start observers finish waiting.
- Share interruption classification and history recording across turn and compaction paths.

## Testing

Extend the rollout-budget integration test to assert that both the budget-crossing turn and a later denied turn persist `developer` interruption markers.

GitOrigin-RevId: 2a49ac9824a4e95e4799f2d0f638f8c46889e8e8
2026-11-15 00:02:01 +00:00
tongzhou wang c8c3f70893 Account for synchronous MCP post-hook costs in rollout budgets (#61580)
## What changed

Allow successful synchronous `PostModelRequest` MCP hooks to return `extra_codex_rollout_budget_units` in `structuredContent`. Add these charges to rollout spending while preserving provider usage separately, including completed responses without token usage and incomplete responses with reported usage.

Validate prices as finite and nonnegative. Preserve valid sibling charges when another hook reports an invalid price, and surface accounting failures without retrying inference. Carry hook charges and overflow information through host accounting and enforce local budget limits.

## Testing

Extend coverage for hook-driven budget exhaustion, failed hooks, overflow, interrupted responses, and foreground and background compaction accounting.

GitOrigin-RevId: dc54ba53478d82848bcafb55ecef88215019d09f
2026-11-14 23:53:53 +00:00
tongzhou wang c8e4cbcd94 Support fractional rollout budgets and configurable context reminders (#61579)
## What changed

- Add a positive, finite `features.rollout_budget.limit_budget` allowance while retaining `limit_tokens` compatibility. Reject configurations that specify both.
- Preserve fractional balances in reminders and compare thresholds without rounding the balance down.
- Accumulate charges with compensated summation and allow spending exactly the allowance, including floating-point rounding tolerance for cases such as `0.1 + 0.2` against `0.3`.
- Add `reminder_at_context_start`, defaulting to `true`. Set it to `false` to suppress reminders at thread start and after compaction; combine it with an empty threshold list to disable budget reminders entirely.

## Testing

Extend configuration and rollout-budget tests to cover fractional allowances, legacy integer persistence, invalid limits, threshold-only reminders, and enforcement at decimal equality and after overspending.

GitOrigin-RevId: b8e7a2faa8d39e562bcae196364de419698bc67d
2026-11-14 23:53:23 +00:00
tongzhou wang f226c9ccfb Recheck rollout budgets before starting tool work (#61578)
## Why

A rollout budget can be exhausted while a tool call waits for an execution slot, approval, or a lifecycle callback. Checking only when scheduling the call can allow new work to start after the budget is exhausted.

## What changed

- Recheck the budget after acquiring an execution slot, immediately before starting a handler, and immediately before handing an MCP request to the server.
- Report refused calls as aborted in tool outputs, lifecycle callbacks, and dispatch traces, while allowing already-running work to complete.
- Track handler start time separately from dispatch waiting and preserve terminal outcomes when cancellation arrives during completion callbacks.

## Testing

Add regression coverage for queued calls and calls paused in start callbacks when the budget is exhausted. Verify MCP requests are blocked before handoff and retain successful results after handoff, and assert budget-stop state during remote compaction.

GitOrigin-RevId: 573730391452256592d3512f15929a2fbdf03c57
2026-11-14 23:52:50 +00:00
tongzhou wang 92c1a4dc2e Add response processing after completion and usage accounting (#61577)
## Why

Streaming can dispatch tools before a response finishes and its usage is accounted for. Allow callers to wait for completion and synchronous post-hooks so budget enforcement can block tools from the response that exhausts the budget.

## What changed

- Add `responses.process_mode = "after_complete_response"` to buffer response items and release them in order after completion, synchronous post-hooks, and usage accounting. Keep `streaming` as the default and deliver safety-buffering notifications immediately.
- Track whether response usage has already been charged to avoid duplicate accounting, including during compaction.
- Stop new tools across the agent tree when the rollout budget is exhausted. Coordinate steering with accounting and prevent buffered tool calls from dispatching after steering or cancellation.
- Bound buffered responses to 65,535 events and reject overflow.

## Testing

Add configuration coverage and extend integration tests for buffered output ordering, synchronous hooks, interrupted responses and resume, steering, invalid usage, and budget exhaustion preventing tool dispatch.

GitOrigin-RevId: bd06811cfd50cb701babe6353465c57dfed2a37a
2026-11-14 23:50:12 +00:00
tongzhou wang 81b995a6c9 Unify model request hook lifecycles across sampling and compaction (#61562)
## What changed

- Pair `PreModelRequest` and `PostModelRequest` hooks per sampling or compaction attempt, with distinct lifecycle IDs and cancellation reporting.
- Add `thread_id` and `kind` to hook inputs, distinguishing `sampling`, `foreground_compaction`, and `background_compaction`. Include the provider's `response_id` in post-hook inputs when available.
- Wait for synchronous post-hooks before releasing terminal response events, accounting for usage, or installing compaction results. Allow streaming output and tool execution to proceed before the hook finishes, and cancel synchronous post-hooks when their owning request is interrupted.
- Preserve incomplete-response, budget-exceeded, and hook-denied outcomes across sampling retries and compaction model fallback.

## Testing

Add coverage for streaming and tool ordering, interrupted post-hooks, per-attempt metadata, and foreground and background compaction accounting and installation ordering.

GitOrigin-RevId: 3e808c5b3bf2d5a6a326d9f5be5bbd0359b2d16e
2026-11-14 19:40:12 +00:00
goodman-oai 65a5410f72 Add trusted request-country metadata to Responses requests (#61535)
## What changed

- Add `RequestCountry` for host-supplied country codes. Normalize two-letter ASCII codes to uppercase, omit the field by default, and serialize explicit unknown (`XX`) as `null` to prevent fallback to request provenance.
- Carry `request_country` through thread defaults and captured step settings into Codex backend HTTP and WebSocket requests. Allow live country updates without enabling `step_model_switching`, and preserve WebSocket continuation reuse when the country changes.
- Propagate the captured country to subagents, reviews, and compaction requests.

## Testing

Add coverage for country validation and serialization, thread and live-turn update lifetimes, prewarm settings capture, agent inheritance and reloads, compaction and reviews, WebSocket country changes, and HTTP fallback.

GitOrigin-RevId: 787cd1fa7ba5d465a4eb64a92f13c79e93d9bca7
2026-11-14 15:44:38 +00:00
sayan-oai b1573f1024 Describe context and permissions per environment behind a feature flag (#61494)
## Why

Selected environments can have different filesystem and network permissions, but context previously described only the primary environment's rules.

## What changed

- Add the disabled-by-default `per_environment_context` feature.
- Group filesystem and network access under each environment ID, including when only one environment is selected. Label shared network requirements separately.
- Scope permission instructions and incremental updates to each environment. Withdraw stale descriptions and use labeled thread defaults when no environment is ready.
- Track approved command prefixes separately so new approvals do not require repeating unchanged permission instructions.

## Testing

Extend rendering and permission snapshots for scoped context, removed scopes, thread defaults, and format transitions. Update the active-turn scenario to cover two environments with different permissions, changing only the second environment's workspace and permissions and restoring its defaults on the next turn.

GitOrigin-RevId: c948089c12da7b15eee378d8c5a23a233d24502b
2026-11-14 09:43:57 +00:00
ningyi-oai 048431dcbe Harden Git remote collection and limit remote URL metadata (#61488)
## Why

Parsing `git remote -v` can mistake partial clone filter text for remote entries. Large remote URLs can also push turn metadata beyond the Responses API's 8,096-character limit.

## What changed

- Read fetch URLs from NUL-delimited Git configuration, sanitize credentials, and let Git resolve `insteadOf` rewrites and empty URL resets without contacting remotes.
- Resolve ambiguous URLs with bounded concurrency and a shared deadline, and expose an observer that publishes verified URLs as they become available.
- When turn metadata exceeds the limit, fit complete remote URLs into the remaining budget while preserving other metadata. Prioritize `origin`, then shorter entries; omit URLs rather than truncate repository identities. Apply this to both client metadata and compatibility headers.

## Testing

Add regression coverage for partial clone filter injection, URL rewrites and resets, malformed and non-UTF-8 configuration, `GIT_CONFIG` overrides, progressive updates, and long remote URLs. Add metadata tests for the exact size boundary, oversized remote omission, ASCII serialization, and preservation of other fields.

GitOrigin-RevId: 522ffe291db6113ca9856fc98309609c8abe4ac0
2026-11-14 08:26:47 +00:00
Zahan Malkani 5943d7acdf Persist timestamped realtime frames before acknowledging completion (#61473)
## What changed

- Record voice transcripts as `frame` items with a `voice_transcript` channel for eligible threads, while retaining legacy transcript support and the existing app-server live and mixed timeline representation.
- Assign first-observed timestamps that never move backward, retain them through completion, and restore the clock floor from history and compaction checkpoints.
- Flush realtime records before completion notifications, including file and initial directory durability barriers for local rollouts.
- Generate a distinct default session ID for each new call, use the call ID when attaching to an existing call, and derive opening record IDs from session IDs.
- Add protocol types for turn-input acceptance and session-end input receipts, excluding those receipts from live notifications and mixed timelines. Update generated schemas and SDK types.

## Testing

Add coverage for frame serialization and required voice payloads, clock rollback and checkpoint restoration, durability barrier failures and retries, per-call session IDs, and persisted transcript availability immediately after completion.

GitOrigin-RevId: 3f6632b517d563861aee085b723475b8945c391c
2026-11-14 06:14:36 +00:00
Ruslan Nigmatullin 336b19ab26 Move JSON byte counting into codex-utils-string (#61465)
Export `serialized_json_bytes` from `codex-utils-string` and update core callers to use the shared helper. Preserve byte counting without retaining the serialized output.

GitOrigin-RevId: 9c75b05592d3171b9a0d54517f8f3a4281fde987
2026-11-14 05:00:21 +00:00
Ruslan Nigmatullin ecf54824c6 Refactor session mail recording and compaction metadata capture (#61461)
## What changed

- Consume the optional delivery handle directly when recording inter-agent messages.
- Capture compaction resume metadata before constructing the `CompactedItem`.
- Move the existing inter-agent message rollout and resume test into `mail_publication_tests.rs`, preserving its assertions for turn IDs, timestamps, persisted metadata, and restored history.

GitOrigin-RevId: 761a837922377d5a72266d775622211e43fa87d3
2026-11-14 04:16:22 +00:00
Ruslan Nigmatullin c2c1ebba0a Add optional tool output rendering for context window hints (#61452)
## What changed

Add the token-budget setting `context_window_as_tool_output`, defaulting to `false`. When enabled, render agent identity, context window IDs, and associated hints as an `agent.thread_hint` tool output. Use the same format for agent identity updates in forked threads.

Preserve this setting when applying model token-budget defaults without treating it as an explicit budget override.

## Testing

Update fork scenario snapshots to cover tool output rendering, including a child agent's window hint after its inherited parent context and a prediction fork above the compaction threshold.

GitOrigin-RevId: e1a7089935bd0aed44ffd15f0ae3ec41a2607218
2026-11-14 02:55:41 +00:00
Anthony Tafoya d26406987e Add explicit cloud catalog refresh before turn admission (#61449)
## Why

Hosts need to refresh cloud plugin and skill catalogs without starting a turn or waiting for step preparation.

## What changed

- Add `CodexThread::refresh_cloud_plugins()` and a turn-independent extension callback that bypass cached catalog reuse and failure cooldowns.
- Run catalog contributors concurrently while serializing publication with step snapshot capture. Invalidate MCP resource caches before explicit discovery and schedule MCP reconciliation afterward.
- Accept complete and partial catalogs, report discovery errors, and keep failed or cancelled refreshes retryable.
- Allow hosts to gate cloud plugin discovery through effective configuration.

## Testing

Add coverage for discovery before turn admission, catalog replacement and reuse, immediate retry after failure, concurrent contributors, and cancellation-safe publication and invalidation.

GitOrigin-RevId: 83e847fcab6562581af2c9e831b1d2a310f2b270
2026-11-14 02:45:51 +00:00
Brent Traut 32cec881b7 Add thread ID inclusion filters to thread/list (#61446)
## Why

Clients reconciling saved thread IDs need to retrieve matching summaries within the current list filters, including threads beyond the first page of history.

## What changed

- Add `includedThreadIds` with up to 100 entries, applied before pagination alongside existing filters. Exclusions take precedence, and results retain the requested list sort.
- Treat omitted or null inclusions as unrestricted and an empty array as matching nothing. Reject invalid IDs and oversized arrays without truncating them.
- Use indexed metadata and primary-key lookups for local inclusion queries, without scanning rollouts for repairs. IDs absent from the index do not match.
- Update protocol schemas, generated bindings, and documentation, including guidance to verify server support before treating missing saved IDs as removals.

## Testing

Add coverage for saved IDs across project moves and archiving, pagination, exclusions, validation limits, and combinations with search, account, and relationship filters. Add a SQLite query-plan test for primary-key lookups across scopes.

GitOrigin-RevId: 90b02a12aee5716f872a9d5d6168d23cf86c6333
2026-11-14 02:23:37 +00:00
Charlie Marsh e9919f4b4e Add process-local launch directories for shared MCP servers (#61444)
## What changed

- Add hidden app-server options `--plugin-mcp-launch-cwd` and `--mcp-launch-cwd` for host-supplied local stdio server launch directories without writing them to shared configuration.
- Apply these directories when both `mcp_shared_repl_cwd` and `mcp_connection_sharing` are enabled. For configured servers, require a matching executable and preserve any explicit working directory.
- Attach thread-specific sandbox state to direct MCP tool calls for servers advertising support, stripping caller-supplied sandbox and launcher metadata first.

## Testing

Add regression tests for launch-directory feature toggling and executable matching, and for direct MCP calls using each thread's sandbox working directory despite forged caller metadata.

GitOrigin-RevId: d7f78ea92163ec0ee9311f68ef17e87a6694b13b
2026-11-14 01:54:53 +00:00
dob-oai 8afe928a76 Avoid starting dormant REPL servers for cleanup hooks (#61437)
## Why

Bundled `turn_ended` hooks can start an unused REPL server solely to clean it up, even though its deferred startup means there is no process to clean up.

## What changed

Allow bundled cleanup calls for `node_repl` and `cua_repl` to return an empty successful result when startup has never been requested. Limit this behavior to configured, unshared local stdio connections using the legacy MCP protocol. Other calls continue to wait for server startup.

## Testing

Add coverage for the connection eligibility checks and extend subagent hook tests to verify that bundled cleanup leaves unused REPL servers dormant while ordinary hooks can still start cached tools hidden from the model.

GitOrigin-RevId: 0a07772fccd670c53348ff7a702b4bee353e263c
2026-11-14 01:34:12 +00:00
Max Johnson 9ac8c3f8d7 Close abandoned tool dispatch traces as aborted (#61434)
## Why

Interrupting a turn while a tool awaits approval can leave its rollout trace execution marked as running without an end timestamp.

## What changed

Record an `Aborted` end event when a tool dispatch trace is dropped before producing a result. Make completion and failure methods consume the trace handle so each dispatch is closed once.

## Testing

Add coverage for dropping a pending dispatch and for interrupting a turn with a pending command approval, verifying that replay reports an aborted execution with an end timestamp.

GitOrigin-RevId: 63cf68312fcbff8c6b85a01a7713cf4460c9d795
2026-11-14 01:32:55 +00:00
Anthony Tafoya 6d919e65e2 Refresh cloud plugin and skill catalogs during step preparation (#61429)
## Why

Installing a plugin without connector tools must still refresh a cached cloud skill catalog so its skills are visible to the next inference.

## What changed

- Rely on step preparation for cloud plugin and skill discovery, removing their turn-start callbacks and the `requires_mcp_runtime` lifecycle hook.
- Request an MCP runtime refresh after every completed plugin install, including skills-only installs.

## Testing

Add regression coverage for skills becoming visible immediately after a connector-free install. Update lifecycle tests to cover discovery after MCP reconciliation, prewarm skipping discovery, cancellation allowing subsequent preparation, and reuse of unchanged connections. Use deterministic DNS lookups in network proxy authorization tests.

GitOrigin-RevId: 76036bd29253fb8987e606c3c28411c689590fc4
2026-11-14 01:11:17 +00:00