Commit Graph
3215 Commits
Author SHA1 Message Date
Bryan Ashley 65454c7b99 Add OpenTelemetry for subagent lifecycles (#62567)
## Why

Correlating a subagent's creation, turn attempts, and stop requests
helps explain what happened when those actions span workers.

## What changed

- Emit structured events and counters for successful spawns and accepted
  `close_agent` and `interrupt_agent` calls. Count accepted stops even
  when the target is already idle or unloaded.
- Track initial, follow-up, and resumed turn attempts for spawned
  subagents. Record each start and at most one outcome per attempt:
  completed, failed, interrupted, or suspended.
- Use thread, turn, and call IDs to correlate structured events while
  keeping those IDs out of metric labels.

## Testing

Add coverage for lifecycle counts, duplicate outcomes, stop handling,
and event correlation across workers. Improve the Windows elevated
sandbox test for an approved `git pull` by provisioning the sandbox
before the turn and reporting setup or launch failures with diagnostics.

GitOrigin-RevId: bc1190302e1dffbdd79c7ac984b6debe1dac4a65
2026-11-19 18:39:32 +00:00
Dylan Hurd 692292695b Fix timing races in core integration tests (#62564)
## Why

Steering can cancel a paused mock HTTP stream, realtime handoff and turn
events can arrive in either order, and streaming tools can run before the
response reports token usage. Tests that assume a fixed sequence can fail
depending on timing.

## What changed

- Pause the hooks test at assistant message completion so both queued prompts
  enter the same batch before the turn resumes.
- Track the handoff and turn events in one pass, waiting for the matching
  turn to complete on the unblocked path.
- Call `get_context_remaining` during the compaction fallback and assert
  zero remaining tokens using the preceding response's usage.

GitOrigin-RevId: ec8a108517c819d7087681e8e2c7b5b57f4b341e
2026-11-19 18:22:41 +00:00
tongzhou wang 65d69f25b4 Reject overflowing rollout budget charges before posting (#62559)
## Why

An overflowing hook total could send a partial charge to the host, and
an overflow in native accounting could leave the posted balance infinite.

## What changed

Reject overflowing hook totals before reporting usage. Check both the
combined provider and hook charge and the cumulative rollout balance
before posting, preserving the previous balance on overflow. Native
budgets with limit enforcement enabled still stop new work on overflow.

## Testing

Update the hook overflow integration case to verify that the response's
tool is blocked and the host receives no usage report.

GitOrigin-RevId: 2ac80a6aa1d857924a8807df7bb70c6b7c107cd2
2026-11-19 17:46:53 +00:00
Charlie Marsh ac784eb10e Enable MCP connection sharing by default (#62552)
## Why

Local stdio discovery needs to accommodate legacy servers that return an
empty response to `server/discover`, take longer to initialize than the
discovery watchdog allows, or require `initialize` as their first request.

## What changed

Mark `mcp_connection_sharing` stable and enable it by default. Treat an
empty discovery response as an unsupported method and let legacy
initialization use the configured startup timeout. Give legacy restarts
a fresh timeout and keep modern version retries within the original
deadline.

## Testing

Cover empty discovery responses, slow initialization on the original
connection, and restarts after ignored or rejected initialization.
Explicitly select legacy mode in tests that depend on legacy behavior.

GitOrigin-RevId: 04d87ddfe02fac8491f879ce420bf294dc725128
2026-11-19 16:56:55 +00:00
jif 0b248182be Respect app-server turn admission for agent mailbox wakes (#62537)
## Why

Automatic mailbox wakes can start new turns while the app-server is
draining or has paused turn admission. Native child results still need
to reach the parent during drain so they can survive a daemon restart.

## What changed

- Require a turn admission permit for ordinary automatic mailbox wakes
  and hold it through turn registration. Retry queued work when a
  temporary pause ends. Explicit follow-ups and native child results can
  still wake the parent during drain.
- Let `thread/inject_items` queue plain-text agent messages for native
  child threads when native tools are enabled. Injected mail follows the
  ordinary wake rules.
- Extract the remote app-server client, shared event and request types,
  and WebSocket compression into `codex-app-server-remote-client` so
  callers can use them without linking the app-server runtime.

## Testing

Cover delivery of queued mail when admission reopens, injection into
native child threads, and recovery of a child result after a daemon
restart.

GitOrigin-RevId: 4c5ceeca8829c2612cc2b6b74c03d0c7677a9244
2026-11-19 15:45:17 +00:00
tongzhou wang 27e16c08c3 Add built-in namespace guidance and budget tool description prefixes (#62534)
## Why

Namespace-wide guidance can repeat on every entry in flat Code Mode listings. The existing prefix limit covers only reachable `functions` tools, leaving indirect namespace guidance outside the budget.

## What changed

- Add `builtin_tool_namespaces` to put guidance on namespace headers in Code Mode prompts and tool search responses, including headers shared with client tools. The selector applies to namespaces with a registered built-in tool and is omitted from flat listings. Overlapping selectors must agree after trimming.
- Validate all four prefix maps together against the selected model's `description_prefix_budget_bytes`, which defaults to 512. Count each trimmed value once in UTF-8 bytes, including unused selectors. Exclude keys, paragraph separators, and rendered copies.

## Testing

Cover shared headers, flat listings, and conflicting selectors. Exercise the default budget boundary with multibyte text and verify that a model can raise the limit.

GitOrigin-RevId: 1570c23ea1dbad6041cc8e48d0dc2b77f92596c7
2026-11-19 15:31:33 +00:00
igorrybalka-oai 1826d80eca Expose Daybreak availability in model discovery (#62499)
## Why

Clients need to distinguish a caller who must enroll in Daybreak from a
model that does not support it. The list of accepted access programs
alone cannot express that distinction.

## What changed

Carry the server-resolved status for each caller and model from the
model catalog into `model/list` as `availableAccessPrograms.daybreakAvailability`.
Update the JSON schemas, TypeScript bindings, and Python SDK to expose
the field.

Rust decoders use `default` for missing or unrecognized statuses. The
Python SDK also defaults missing statuses and preserves new strings
from newer hosts.

## Testing

Cover catalog decoding, app-server response serialization, and Python
SDK round trips with known, missing, and future status values.

GitOrigin-RevId: c1e5ddef68fd19b25e583bb6996a93fd78ab9d18
2026-11-19 12:28:34 +00:00
ioanbudea-OAI b0ecad9cf9 Refresh managed Guardian policy across Codex threads (#62496)
## Why

A thread can start while managed Guardian policy is being refreshed. Startup
and refresh need to coordinate so the thread does not register with policy
that the refresh has already superseded.

## What changed

Let hosts provide a `GuardianPolicyLoader` to `ThreadManager` for startup
and on-demand refresh. Pause thread registration while a refresh loads and
publishes policy. If publication overtakes a thread's startup configuration,
reload Guardian policy before registering the thread.

Apply the published policy to live threads concurrently. Once published, the
updates continue even if the refresh caller is canceled. Return an error if
any live thread rejects the update.

## Testing

Add regression coverage for an idle thread receiving the update while
another thread holds its session lock, and for reporting a live thread's
rejection of invalid Guardian configuration.

GitOrigin-RevId: ca0cfa2a30f0d45c4ac5ded3400e0e18177ede1d
2026-11-19 12:07:28 +00:00
Channing Conger 336dc645fb Use gRPC for all code-mode host connections (#62476)
## What changed

Remove the legacy framed stdio protocol and its client and server.
Local Codex launches the standalone host with `--listen grpc+stdio://`,
which is also the host's default. The `stdio` and `stdio://` aliases
now select gRPC over stdio. The `features.code_mode_host_grpc` setting
is deprecated and ignored.

Carry execution trace context into gRPC tool callbacks and
notifications. Reject oversized execute requests before sending them
so an encoding failure does not appear as a connection reset.

## Testing

Exercise gRPC callback cancellation, trace context across overlapping
yielded cells, and isolation of tool preload failures between sessions.
Check that both values of the deprecated feature setting are ignored.

GitOrigin-RevId: f5faff3901dc60958627f677f50cfad834291b69
2026-11-19 09:37:29 +00:00
ssetty-oai 083bf59b6b Send authorized connector results over Responses WebSockets (#62474)
## Why

HTTP sampling can attach private connector result bodies, but Responses
WebSocket sampling leaves them out. WebSocket requests need the same
destination and account checks before sending those bodies.

## What changed

Apply the existing HTTP eligibility checks to each WebSocket attempt and
attach only result bodies that belong to the current account and match
the input being sent, including when that input is an incremental update.
Keep prewarm requests free of private result bodies. Update
`tungstenite` and `tokio-tungstenite` to keep sensitive payload bytes
out of frame diagnostics.

## Testing

Add regression coverage for connector results reaching the server while
staying out of request observers and client logs. Cover custom-provider
requests and retries across an account change with results from both
Code Mode `exec` and `wait`.

GitOrigin-RevId: df5ec8608e59bb3a0444fafd5268279e669ccb55
2026-11-19 09:36:18 +00:00
ningyi-oai 83f73a818c Defer Git worktree status until the turn starts (#62437)
## Why

A turn interrupted during setup can be discarded before it runs. Starting
the worktree scan during setup can spend time scanning for a turn that
will never send a model request.

## What changed

Collect `HEAD` and remote URLs in the background after turn setup, and
start the worktree status scan only after the turn is admitted to run.
Model requests use the latest available Git metadata while collection
continues, and later requests can include the worktree status once it
is available.

Use shared background Git root discovery for the memory extraction
change probe and pass the resolved root into the probe.

## Testing

Regression tests cover requests proceeding while status is blocked,
later requests carrying the updated `HEAD`, remote URL, and dirty
status, and an interrupted wake skipping the worktree scan.

GitOrigin-RevId: 00f465a5621d672d8b6d9063c384fb62e493c79f
2026-11-19 06:03:09 +00:00
Oliver Tepman c764c44a05 Let extensions attach metadata to MCP tool requests (#62435)
## What changed

Add `ToolLifecycleContributor::mcp_tool_request_meta` so an extension can
use thread and turn data and the captured tool registration to attach an
entry to the outgoing request's `_meta`. Codex rejects duplicate keys.
Expose the registering plugin's package ID in `McpToolContext` so
contributors can scope metadata to that plugin.

Export `PERSISTED_MCP_RESULT_MAX_BYTES`, the existing 64 KiB limit for
untruncated MCP results in durable history.

## Testing

Extend the multi-environment MCP scenario to check that only the call
for the selected plugin receives the metadata and that the result
callback sees the same plugin context.

GitOrigin-RevId: 25a2afc5402a5c9323de184313d614aede3692fb
2026-11-19 05:37:58 +00:00
ssetty-oai 524e15989b Expand connector result metadata coverage across auth configurations (#62434)
## What changed

Pass the resolved result-body destination into sampling, where its owner
is used to select retained bodies for the turn. Check that the capture
owner is current under the retention lock before converting an MCP
result and again before retaining its body.

## Testing

Extend the request-budget integration test for direct calls and Code Mode
to check when executed calls carry result metadata. Cover ungranted and
custom endpoints, independent model credentials, hosted Apps OAuth and
header overrides, and disabled result-body passthrough. Check that the
shared configuration preserves metadata on a subsequent turn.

GitOrigin-RevId: 8e5ac88ba323d10e0f3e696d4ae356d52bdf22a3
2026-11-19 05:26:15 +00:00
ssetty-oai b5d9f7116e Include nested Apps tool results in Code Mode sampling requests (#62423)
## Why

Result body capture covered direct Apps calls, leaving eligible calls made inside Code Mode without their result bodies in follow-up sampling metadata.

## What changed

Capture eligible nested MCP results and bind them to the originating `exec` or `wait` output for the current turn. Send `tool_result` and `tool_result_call_id` together when both fit the request budget. Keep the bodies out of conversation history and reclaim capture capacity when the output binding is lost.

Require analytics to be enabled and the provider to allow request metadata before starting turn-level capture. Check the call's credentials at dispatch and again when recording the result.

## Testing

Add coverage for yielded and finished outputs, late results, retries with replacement output items, capture budget recovery, and the request size boundary for sending the body and call ID together.

GitOrigin-RevId: 0983261ac39021099d14efa5c9a9acac47ac9269
2026-11-19 03:58:29 +00:00
ssetty-oai 770c38d0b1 Reject provider query parameters for connector result passthrough (#62421)
## Why

The Responses client checks the gateway URL and request headers before
allowing connector result bodies to be attached. Provider query parameters
can also change the request while leaving those checks satisfied.

## What changed

Require an empty provider query parameter map, or no map, when selecting
a connector result destination. Check the ChatGPT credential variants
directly and retain the current auth owner for thread grant verification.

## Testing

Extend the client setup test to check that a custom provider URL is
ineligible even with refreshed ChatGPT credentials. Extend the enterprise
MCP lifecycle test to check that the configured provider receives the
account bearer token and executed tool-call metadata. Allow HTTP client
tests to cache a direct system proxy decision as well as a proxied route.

GitOrigin-RevId: 1e7e77ec6e65263eaff658ba39943ec51230d332
2026-11-19 03:58:01 +00:00
Charlie Marsh fc483d4b4d Box the future returned by response item injection (#62420)
## Why

Callers of `CodexThread::inject_response_items` each compile a copy of
its concrete future, duplicating compilation work.

## What changed

Return a `BoxFuture` from `CodexThread::inject_response_items` so the
concrete future stays in the core crate. Raise the core integration
test crate's recursion limit to 256.

GitOrigin-RevId: 2ccb280c7887278fc8011c37df35df84c47b3e35
2026-11-19 03:56:40 +00:00
ssetty-oai d1d1ba0b83 Pass eligible connector results through to ChatGPT Responses (#62392)
## What changed

Add the off-by-default `features.connector_tool_result_passthrough` flag. For direct ChatGPT Apps calls, capture eligible text and structured content from the original MCP result before tool output processing. Attach the captured body to the matching executed-tool record on follow-up HTTP Responses requests to the ChatGPT Codex endpoint when the request uses the same authenticated account and turn.

Bound captured bodies in memory for the originating turn. Enabling passthrough alone scopes executed-tool metadata to calls with a captured result ID.

## Testing

Add coverage for same-turn HTTP delivery, omission on later turns or after an account change, and omission of shell-call metadata on HTTP and WebSocket requests when only passthrough is enabled.

GitOrigin-RevId: 410c81559bfc15022b896cf006cb631f3fd9454e
2026-11-19 01:27:01 +00:00
Joe Savona 2d58165651 Expose custom status lines in /experimental (#62387)
## Why

Custom status lines previously depended on a feature flag in the TUI
client's configuration. When the TUI connects to a separate app server,
that flag can differ from the setting in the server's active profile.

## What changed

Add **Custom status line** to `/experimental` as an opt-in feature. Save
the toggle on the connected app server, restart the TUI, then use
`/statusline` to choose a provider.

Read `tui_extensions_statusline` from the app server's effective
configuration at startup. Keep that value when switching conversations
or reloading local status line preferences, so toggling the feature
takes effect on the next TUI launch.

## Testing

Add a menu snapshot and regression coverage for saving the toggle in a
server profile while preserving the active provider across a thread
change.

GitOrigin-RevId: 4025c9771e560d6d7b1e6bd97236bffc44201556
2026-11-19 00:59:23 +00:00
richardopenai ab1ad9299b Skip the sandbox denial wait when unified exec output closes (#62382)
## Why

The sandbox denial check can spend 20 ms waiting for more output even
after the stream has closed and all denial context is available.

## What changed

Classify the buffered output immediately if the stream is already closed.
While the stream is open, wait up to 20 ms for new output or closure.
Register for the closure notification before rechecking the stream state
so closure during setup wakes the check.

## Testing

Paused-clock tests cover output closed before or during the check,
preservation of the timeout for open streams, and classification of
sandboxed and unsandboxed failures. The remote process-event suite adds
a direct sandbox denial case with a `process/closed` event.

GitOrigin-RevId: 1f3029055d70ff4cd63939564872fe5d37240a33
2026-11-18 23:42:25 +00:00
Charlie Marsh 637c429472 Enable lazy startup for stdio MCP servers by default (#62366)
## What changed

Mark `mcp_lazy_stdio_startup` stable and enable it by default. When a
tool catalog is already cached, Codex can expose tools from an optional
stdio MCP server and defer starting the server until the first tool
call. Required servers still establish a live connection at startup.

## Testing

Exercise lazy startup with the default configuration in the tool-cache
test and explicitly disable the feature for the eager-start control.
Update the code mode and working-directory tests to proceed without
waiting for an optional server when its catalog is cached.

GitOrigin-RevId: a65d83fd1a4c141dba3c10e68b138539aa0a44f0
2026-11-18 21:30:23 +00:00
jameswt-oai 1b80bd9412 Allow per-tool approval reviewers for Codex apps (#62360)
## Why

A connected account or app can choose an approval reviewer, but that
setting applies across its tools. Users may want to review calendar
event creation themselves while keeping automatic review for other tools.

## What changed

Set `approvals_reviewer` on an individual app tool in `config.toml`:

```toml
[apps.calendar.tools.calendar_create_event]
approvals_reviewer = "user"
```

Codex matches the tool by raw name first and falls back to its title.
The tool's reviewer takes precedence over the connected account, app,
app defaults, and session settings, subject to managed requirements.
This applies to tool-call approval prompts and MCP approval requests
that match a verified app tool invocation. The app-server
`config/read` response also exposes the per-tool setting.

## Testing

Extend coverage for reviewer precedence, tool title fallback, managed
review requirements, tool-call approval routing, strict MCP elicitation,
and app-server config reads.

GitOrigin-RevId: c92bd39b9e708dada9d314c19a446b4c580edf91
2026-11-18 20:42:18 +00:00
Charlie Marsh 513577302a Surface Responses stream errors as soon as they arrive (#62356)
## Why

If a provider keeps an SSE connection open after reporting a failure, Codex
can hit the idle timeout and lose the original error and its retry advice.

## What changed

End the SSE stream immediately on `response.failed` or a recognized
`error` event. Classify statusless quota, plan usage, invalid prompt, and
misalignment errors consistently across both event forms. Preserve
`Retry-After` for overload and capacity errors, preferring error-level
headers over event-level headers when both provide valid advice.

## Testing

Add SSE regression tests that hold the connection open and verify immediate
error delivery, terminal error handling, and retry delays. Extend WebSocket
coverage for statusless errors received before the close handshake.

GitOrigin-RevId: 69afd1d3b18ca3139e9b7ad98ae1481a432179f0
2026-11-18 20:28:44 +00:00
Charlie Marsh c5cff4335c Treat statusless bio and cyber policy errors as terminal (#62354)
## Why

When the Responses API sends a policy rejection in an `error` event
without an HTTP status, the SSE client can wait until its idle timeout
to report the failure.

## What changed

Recognize `bio_policy` and `cyber_policy` in the shared terminal error
parser so both SSE and WebSocket clients surface the corresponding
policy error. Preserve the provider's message and use a default when
it is missing or blank. End the SSE stream as soon as the error arrives.

## Testing

Add SSE tests for both error codes, including when the stream stays
open, and WebSocket cases that verify both errors surface without a
close handshake.

GitOrigin-RevId: 1b46b6557a39a61a1bb10bdd0d8ede48ecd6fa13
2026-11-18 20:17:25 +00:00
jif 9d8ca1df71 Preserve queued agent messages when a parent turn is interrupted (#62348)
## Why

A parent turn can acknowledge a child agent's final reply while a model
request is in flight. If the parent is interrupted before consuming the
queued reply, turn cleanup can discard it.

## What changed

Record queued agent messages in conversation history during interruption
and flush the rollout before emitting `TurnAborted`, even when the
interruption marker is disabled.

## Testing

Add a regression test that interrupts a parent while a child's final
reply is queued. The test checks that the reply is persisted when
`TurnAborted` arrives and appears exactly once in the next model request.

GitOrigin-RevId: 5bd828c4101942fa4fe7ba5040355a8244f02018
2026-11-18 19:39:41 +00:00
Alex Chang cc7a62e19c Report API spend limit errors by scope (#62329)
## Why

Generic quota errors hide whether the project or organization spend limit
blocked a request. Reporting the scope tells users which limit to check.

## What changed

Recognize API key, project, and organization spend limit errors across
HTTP, SSE, and WebSocket responses. Show a message that names the scope and
treat the error as non-retryable, even when the provider sends
`Retry-After`. Apply the existing usage-limit handling to goals and
compaction.

Expose distinct `CodexErrorInfo` values in the app-server protocol and
generated bindings so clients can identify the limit in live errors and
failed turn history.

## Testing

Extend the transport tests to cover all three scopes and verify that they
stop retries. Extend the app-server test to check that the error survives
`thread/read` and that a subsequent turn can succeed in the same thread.

GitOrigin-RevId: 03341f7a78daa7540e7baa519f1a29ec07e34509
2026-11-18 18:11:54 +00:00
richardopenai c1ed51ca2c Accept inbound Noise connections in remote exec-server (#62325)
## Why

Remote Noise executors previously connected outbound to a rendezvous relay. An inbound listener lets harnesses that can reach the executor connect directly while retaining registry-backed authorization.

## What changed

Use `--listen ws://IP:PORT` with `--remote` in Noise mode to accept inbound WebSockets. The listener serves RPCs over encrypted Noise streams after the registry authorizes the harness. It limits concurrent connections and handshake attempts, closes sockets that miss the first authorization deadline, and drains connections on shutdown.

Noise clients can attach optional admission headers from the connection bundle to `wss://` requests.

## Testing

The inbound integration test exercises a registry-authorized file read, rejection of a registry-denied harness, the absence of a plaintext RPC response, and connection closure on shutdown. Unit tests cover handshake limits and rejection of admission headers before dialing a plaintext WebSocket.

GitOrigin-RevId: b388672e49a3fe806e38f6db38825435ba25d27a
2026-11-18 17:55:49 +00:00
rhan-oai daa59ebd29 Keep authorization evidence local to agent forks (#62314)
## Why

A prepared agent fork needs its ancestor's conversation for context.
Treating that conversation as the child's own authorization evidence
can attribute the ancestor's messages and approvals to the child.

## What changed

Allow host-started prepared forks that reference stored history to
inherit the root session ID. Keep ancestor messages as conversation
context and exclude ancestor authorization evidence when starting or
resuming the fork and when reconstructing sender evidence from storage.
Preserve the inherited disabled-plugin settings and the child's own
authorization evidence.

## Testing

Cover prepared forks across startup and resume, including inherited
context, plugin settings, and child-local authorization. Verify that
live and stored sender evidence both contain only the child's messages.

GitOrigin-RevId: 5c5a6547d31fe78dfad3742efb8a41df539173c6
2026-11-18 16:37:03 +00:00
jif 5a6fb36a4d Route local MCP board notifications through response item injection (#62302)
## What changed

In opt-in local MCP mode, deliver board notifications through
`inject_response_items` when the recipient uses Multi-Agent V2 with native
tools enabled. Other deliveries continue to use `Op::InterAgentCommunication`.

## Testing

Extend the HTTP board scenario to check that the parent receives exactly one
`CHANNEL_POST` agent message with the worker as author, the parent as
recipient, and the expected post preview text.

GitOrigin-RevId: deaa1451619a94d9c70c771327892069325c5e60
2026-11-18 15:38:06 +00:00
Zahan Malkani bd00a8a42e Preserve pending realtime speech when a call ends (#62299)
## Why

A realtime call can end with completed speech that has yet to reach a
Codex turn. The next turn needs that context even if the call's transport
has already disconnected.

## What changed

- For V3 calls with realtime frame history enabled, save pending speech
  as context for the next turn. Restore it on thread reload and exclude
  it from the turn count used by rollback.
- Drain already received transcript events and settle pending handoffs
  before saving the call's closing marker. Report recovery required if
  shutdown cannot confirm that history was saved.
- Keep transport detach separate from ending a call. Reattaching restores
  saved pending speech, and an open call can be ended from persisted
  history after a reload. Use the call ID for TUI attachments so successive
  calls on one thread have distinct history.

## Testing

Add coverage for queued speech at hangup, reconnect and stop after
reload, retries after an uncertain write, and rollback across saved
session-end context.

GitOrigin-RevId: 657491f1d7e446a1a48e22189758810c8bdd82cb
2026-11-18 15:24:29 +00:00
jif bd3eaf7829 Route injected plaintext agent mail through the native mailbox (#62292)
## Why

Raw response injection bypasses the native mailbox wake policy, so
injected agent messages cannot wake a sleeping thread through that
policy.

## What changed

In native Multi-Agent v2, route batches consisting entirely of
single-text agent messages with valid agent paths through the mailbox
as queue-only mail. Hold a residency pin across the batch so capacity
eviction cannot interrupt delivery between submissions. Mixed batches,
multipart or encrypted messages, and configurations with native tools
disabled continue to use raw response injection.

Only preempt model sampling for pending mail when the matching turn
still accepts mailbox delivery.

## Testing

Extend coverage for waking live and reloaded sleeping threads,
delivering older queued mail before a new task, and retaining mail in
order when a batch exceeds the submission channel capacity and
eviction is attempted.

GitOrigin-RevId: 3df60d2a4a9e7b193ef298e01f31c565ad8a2785
2026-11-18 14:53:00 +00:00
jif df975851bf Use the system clock for in-memory MCP message boards (#62284)
## Why

The in-memory MCP backend depended on the runner's clock, so a runner
clock failure could prevent posting. The standalone SQLite backend
already uses the system clock.

## What changed

Read UTC time from the MCP backend's system clock after validating
caller membership. Apply this to both tree and agent-specific bindings.

## Testing

Update the HTTP integration scenario to make the runner clock fail and
verify that a child agent's post timestamp falls within the posting
window.

GitOrigin-RevId: bad5dec5a9be7246cf627b017897fbfe2c960cd1
2026-11-18 14:11:08 +00:00
ioanbudea-OAI a05444bbeb Refresh managed Guardian policy independently of MCP (#62276)
## Why

Managed approval requirements can change while an MCP runtime is still in use.
Later turns need to honor those changes without restarting MCP, while in-flight
MCP actions need to retain the mandatory review requirements of their issuing
turn.

## What changed

- Add `CodexThread::refresh_guardian_policy` to apply managed policy updates to
  an existing thread. MCP configuration refreshes preserve the active Guardian
  policy, including when a policy update lands while MCP configuration is loading.
- Resolve MCP tool and elicitation reviewers against the issuing turn's policy.
  Live requirements can still require Guardian review, and a live policy change
  cannot waive mandatory review captured by the turn.

## Testing

Extend coverage for overlapping Guardian and MCP refreshes and for an existing
MCP runtime that must prompt the user on the next turn after a policy update
allows only the `user` reviewer.

GitOrigin-RevId: 5a1649f917313f6fb152a206bc89986fe6345481
2026-11-18 13:08:51 +00:00
Zahan Malkani 29cb67623c Gate local realtime frame history on paginated storage (#62271)
## Why

Legacy rollout migration rewrites rolled-back history and can disrupt
the realtime stream. Enroll local threads once they use paginated history
so the stream stays intact.

## What changed

- Add the off-by-default `features.realtime_frames_local` flag for
  paginated local threads with a state database. Accept runtime updates
  through the app server and keep threads enrolled once they have a
  persisted canonical session start.
- Add thread-store APIs to recover a realtime session and look up the
  latest session ID from durable history. Route frame completion through
  a store seal so completion acknowledges durable writes.
- Add a local seal for accepted model input that writes source frames
  before the input and lets callers retry an uncertain flush without
  appending the input twice.

## Testing

Cover enrollment for legacy and paginated threads, continued enrollment
after disabling the flag, and retrying a local input seal after a failed
directory sync.

GitOrigin-RevId: 2012feeca3857da90f9b026f077b31a26d15191b
2026-11-18 12:55:14 +00:00
cazhang-oai ca21fe65d1 Tag Guardian review counts with turn origin (#62225)
## Why

Guardian review counts need a way to distinguish automation-triggered
turns from other turns, including when a subagent requests the review.

## What changed

Add a `turn_origin` tag to the `codex.guardian.review` counter based on
the trigger recorded when the turn started. Recognized automation
triggers map to `automation`, missing or empty triggers map to
`unknown`, and all other values map to `other`. This keeps the set of
metric labels bounded.

## Testing

Cover trigger classification for both allow and deny verdicts and
verify that a later user turn on the same thread is counted separately
from an automation turn in both main and subagent threads.

GitOrigin-RevId: 6a5808798df7d184203cea18e60a94a82d71f036
2026-11-18 08:20:26 +00:00
viyatb-oai bcff988bd1 Resolve Linux sandbox mode once before launching the helper (#62215)
## Why

Managed proxy routes require bubblewrap's network namespace even when
`features.use_legacy_landlock` is enabled. WSL1 compatibility checks and
helper arguments need to agree on the effective mode.

## What changed

Resolve bubblewrap or legacy Landlock once and use that mode for both the
WSL1 check and the `codex-linux-sandbox` arguments. Use Linux sandbox
naming for the shared launcher and CLI code, and preserve the published
analytics category for a missing helper executable.

## Testing

Unit tests exercise the production argument builder, including managed
network context serialization when legacy Landlock is requested. They
also cover which sandbox configurations WSL1 accepts and rejects.

GitOrigin-RevId: 619ab9d3eef965de6bc6cb13ff8a33132018abcf
2026-11-18 07:23:25 +00:00
Ruslan Nigmatullin 86d0e458e3 Prevent duplicate initial context when injection races the first turn (#62206)
## Why

A first user turn and a concurrent raw response-item injection can both
observe that the session has no reference context. Both can then append
the initial prompt prefix and persist a full world-state snapshot.

## What changed

Allow context preparation to run concurrently, then serialize publication
of the initial prefix and its checkpoints. If injection publishes first,
the user turn computes its context updates against the published baseline.
If the user turn publishes first, injection appends only the
caller-provided items.

## Testing

Add an integration test that forces the overlap in both preparation
orders. It checks the first request's world-state updates, verifies that
the follow-up request contains the initial instructions and injected
content once each, and checks that history contains one full snapshot.

GitOrigin-RevId: b66f9c6ccc5d42a2be0e852b4d83b78adbc9e5b2
2026-11-18 06:35:41 +00:00
viyatb-oai a4495dd5c9 Keep sandbox preparation with the command through launch (#62205)
## What changed

- Keep the prepared `SandboxExecRequest` intact in core and let
  `command/exec` borrow the prepared command for streaming. Windows
  restricted-token commands continue through the dedicated sandbox launcher.
- Move runtime read-path selection for exec-server commands and filesystem
  helpers into `SandboxManager`. It derives the paths from the executor's
  binaries and, for managed process launches, finds the generated proxy CA
  bundle in the command environment.

GitOrigin-RevId: 8c9d278496d84589bc4a7b7d0ed08cb1b8e6ba21
2026-11-18 06:22:36 +00:00
Dylan Hurd 3aaa23a437 Reduce overhead in CLI integration tests (#62153)
## Why

SSE-only mocks return 404 on WebSocket upgrades by default, causing
retries before the tests reach the HTTP stream. In parallel runs, each
CLI subprocess can also start a Tokio worker per host CPU.

## What changed

- Share an SSE mock that returns HTTP 426 on WebSocket upgrades to
  trigger immediate HTTP fallback. Reuse it in the fallback test.
- Set `TOKIO_WORKER_THREADS=2` for CLI subprocesses launched by the
  affected test helpers. Run streaming and resume cases that don't need
  the repository checkout in temporary working directories.
- Test promptless `codex exec fork` option validation without creating a
  source thread. In the successful promptless fork case, keep stdin
  open and rely on the test runner's timeout to catch a blocked read.

GitOrigin-RevId: 94c20d4b2fd7cc65bc0f2a1cd0318ac188f59f22
2026-11-18 01:48:42 +00:00
Owen Lin 06789c7618 Preserve web search provider ownership across thread resumes (#62144)
## Why

Search MCP and native web search produce provider-specific references.
Switching providers after a thread resumes can mix those references and
break follow-up calls that use them.

## What changed

Persist whether a thread has used Search MCP, native web search, or
neither. Restore that state from response history, including compacted
history, and use legacy attribution and fallback markers for older
threads. When resumed history lacks a search state or legacy attribution
checkpoint, withhold native fallback unless a legacy marker identifies
native search.

Require every Search MCP call to claim the thread's search provider
before execution, including calls retained by Code Mode.

## Testing

Cover resuming a thread with Search MCP references after discovery
becomes unavailable, both with a saved search state and with imported
history that lacks search checkpoints.

GitOrigin-RevId: 100d21c92b0bdbf737ec36c3474f0bc020df8efc
2026-11-18 00:45:07 +00:00
felixxia-oai c2595ad343 Add live evidence retrieval for Guardian v3 reviewers (#62133)
## Why

A captured board view limits evidence searches to the review's cutoff. A
verdict reviewer needs to be able to check for later evidence, including
restrictions or revocations, before deciding on an action.

## What changed

Add a live `guardian_board` binding that lets reviewers search and read
any Guardian evidence channel, including channels they do not follow.
Search also matches text inside JSON-encoded tool arguments.

Reviewers can list their own subscriptions with `subscribed_channels`
and subscribe or unsubscribe by channel. Subscriptions control delivery
of future evidence. Earlier posts are available through search and read
tools.

Let review setup and prewarming select guidance for the installed
retrieval tools. The live board guidance explains how to find original
user messages and assess their authority. Share the provider-scoped
reviewer header setup through the core Guardian review API.

## Testing

Cover searches beyond the captured cutoff and in unsubscribed channels,
paginated listing of the reviewer's own subscriptions, and channel-only
subscription changes in both live and captured views.

GitOrigin-RevId: c2e1c6c849346cd3d6e316bcf17e44260fcd4c8e
2026-11-17 23:47:24 +00:00
jif e73da8bd1b Preserve base and developer instructions in host child preparation (#62128)
## Why

Hosts preparing a child thread lacked the parent's effective base
instructions and the developer instructions a native subagent would inherit.
Hosts also need the base instruction provenance to preserve custom text
while letting model-owned instructions resolve for the child's model.

## What changed

Include effective base instruction text and provenance in
`PreparedChildContext`. Share developer instruction selection with native
subagent creation so host preparation uses the configured V2 subagent
override when present and falls back to the parent turn's developer
instructions otherwise.

## Testing

Add integration coverage that starts a child on a different model and
checks that custom base instructions persist, model-owned instructions
resolve for the child model, and the V2 override takes precedence over
the parent developer instructions.

GitOrigin-RevId: 0e151e343e58d995c8901a9ba819cb7f60d248f5
2026-11-17 23:31:58 +00:00
andrewgu-oai 4e51bfbacc Refresh tool hashes in core scenario snapshots (#62124)
## What changed

Update the expected hashes for tool lists and incremental tool declarations
across seven core scenario snapshots. The fixtures cover Code Mode, dynamic
tools, and MCP discovery and sharing.

GitOrigin-RevId: 8d69870b488dffc5a24afe0e1c8f522335b25105
2026-11-17 22:58:38 +00:00
Shuo 8dcd56d0cb Add external header auth for existing realtime calls (#62114)
## What changed

Add `RealtimeExistingCallAuth` to `RealtimeAttachmentOptions`, with model-provider authentication as the default. Embedding hosts can explicitly select `ExternalHeaders` for existing calls to use header-based credentials and the host's transport without adding model-provider headers or performing runtime agent registration.

Require an explicit, nonempty sideband URL and header-based authentication for this mode. Destination authorization remains the trusted host's responsibility, and application network policy still applies.

## Testing

Add integration coverage for external-header and model-provider authentication through event delivery, reconnect, and detach. Verify that model-provider credentials are excluded in external-header mode and that invalid authentication, missing URLs, and network policy denials reject the attachment before a WebSocket handshake.

GitOrigin-RevId: 2c915e1cf76a3563f58f751272db1ec50718d925
2026-11-17 22:00:20 +00:00
nvogt-oai 39a7b53fa4 Trust the bundled Memory session hook without saved hashes (#62112)
## Why

The bundled Memory hook needs to supply context at startup and after compaction without requiring saved hook trust.

## What changed

Recognize the exact bundled Memory `SessionStart` declaration as a built-in hook: the `^(startup|compact)$` matcher, `codex_apps` server, `codex_dream_memory.get_mec` tool, and empty input. Carry the expected app connector identity through discovery for dispatch checks, and hide this built-in hook from hook listings while preserving other plugin hooks.

## Testing

Add coverage for exact declaration matching, hook listings without an Apps connection, and a scenario snapshot verifying memory context injection at startup and after compaction without saved trust.

GitOrigin-RevId: edc0e8ffa955227328345f46afecc2a868c0be49
2026-11-17 21:40:36 +00:00
andrewgu-oai 6c0cee502d Add GPT-6.2 Sol and Astra to model catalogs (#62106)
## What changed

- Add `gpt-6.2-sol` and `gpt-6.2-astra` to the bundled, Amazon Bedrock, and Vertex catalogs, including Bedrock Runtime global and US cross-region variants.
- Make GPT-6.2 Sol the default catalog selection and refresh model ordering, descriptions, and bundled instructions.
- Increase the GPT-6.1 Sol context window to 500,000 tokens.
- Advertise the `ultrafast` service tier for GPT-6.2 Astra on Bedrock.
- Supply the same current model catalog to both executors in the prompt-prefix compatibility test so catalog updates do not cause prefix mismatches.

## Testing

Extend provider, app-server, and TUI coverage for catalog ordering, model fallback, Vertex requests, and GPT-6.2 Astra's Bedrock `ultrafast` selection and clearing behavior. Refresh model-picker and request snapshots.

GitOrigin-RevId: f28940e4a255fcdd88f7114873259bd1f3399812
2026-11-17 20:04:36 +00:00
Tom 7457b7268f Preserve trace context during WebSocket startup prewarm (#62103)
## What changed

- Inject the current span's W3C trace headers into WebSocket handshakes.
- Promote `startup_prewarm` to an info span and fall back to the current span when it is disabled, preserving trace context in the spawned task.

## Testing

Add a regression test for `traceparent` and `tracestate` propagation through the handshake, prewarm request, and subsequent turn on the same connection. Verify that prewarm uses the startup trace while the turn uses its own trace, with the prewarm span both enabled and filtered out.

GitOrigin-RevId: 1e196e132a1991206469060ab80a474857fa7909
2026-11-17 19:24:17 +00:00
RJ 6d40c0ac9b Clarify recovery guidance for stale Guardian authorization (#62099)
## What changed

Give `StaleAuthorization` failures specific guidance explaining that the action did not run and the failure is not a policy denial. Instruct the agent to retry once through Guardian if current instructions authorize the action, resolve unclear authorization before proceeding, and avoid bypassing approval or repeatedly retrying a failed review.

## Testing

Extend the authorization refresh tests to verify the blocked tool output includes this guidance when repeated authorization changes exhaust the review budget, for both approval and denial responses.

GitOrigin-RevId: f6fcbe46fdb5131f70ee905220a58c7331b543fd
2026-11-17 19:09:21 +00:00
adi-oai 0122b120cd Centralize app-server turn error conversion (#62096)
## What changed

Add a shared `From<ErrorEvent>` implementation for `TurnError` and reuse it in thread history, rollout projection, and live event handling. Preserve the existing field mappings and keep `additional_details` unset.

Parameterize the compaction replay test by error code and recoverability, retaining the existing `server_error` case, and document retry expectations for WebSocket closes.

GitOrigin-RevId: 3afcc23e9fdc314477febe6b4a4aeb680efafd5a
2026-11-17 18:56:05 +00:00
Adnan Hajar cb64621bf3 Normalize Bedrock Mantle commentary before replay (#62095)
## Why

Bedrock Mantle's reasoning prefix omits empty `annotations` on assistant commentary. Replayed commentary needs to preserve that form to keep the prefix stable.

## What changed

Add a provider hook to normalize completed output items before they enter model history. For Mantle, omit empty `annotations` from assistant commentary text while preserving nonempty annotations, final answers, and Bedrock Runtime output.

## Testing

Add regression coverage for Mantle and Runtime that checks commentary replay across a tool continuation and a subsequent turn, including reasoning and tool item ordering and preservation of final-answer content.

GitOrigin-RevId: ecd5b9b5dca8c24956a6379c9d0fb643e4427af3
2026-11-17 18:55:30 +00:00
surajs-oai e9a43d43c5 Return empty success output from v2 send_message (#62093)
## What changed

Remove the acknowledgment text and `followup_task` hint from successful v2
`send_message` responses, including messages sent to the root agent. The shared
messaging handler now returns empty text with the success flag set.

Update the idle eviction follow-up scenario snapshot to expect empty tool output.

GitOrigin-RevId: 9eab3ae7264e6ddf3db6ae40a34cc895d0954621
2026-11-17 18:44:30 +00:00