Commit Graph

350 Commits

Author SHA1 Message Date
jif
e741cd9ace Consolidate Guardian extensions into codex-guardian-v2 (#39474)
## What changed

- Move the Guardian thread lifecycle contributor and subagent-spawn context into `codex-guardian-v2`.
- Install the lifecycle contributor and asynchronous risk scorer through a single extension entry point.
- Remove the redundant `codex-guardian` crate and group the existing scorer implementation under `async_scorer`.

GitOrigin-RevId: 97141190c843e588b8c09c9ccd3fe00e1fae39a4
2026-08-19 11:59:23 +00:00
sayan-oai
fde2156057 Enforce environment MCP policies (#39335)
## What changed

- Add environment-provided MCP restrictions for configured and plugin-provided servers.
- Disable attachment-scoped servers while their environment configuration is pending, failed, or unselected, while preserving selected-plugin access and the controller-owned Apps server.
- Apply the resolved policy to runtime startup, model tool exposure, telemetry, OAuth flows, and skill dependency installation.

## Testing

- Cover policy filtering for configured and plugin servers, environment state transitions, Apps ownership, and managed OAuth rejection.

GitOrigin-RevId: 7ca5d4dda14068e758497f88835d5cba685e159e
2026-08-19 01:26:16 +00:00
jif
8ae72a9314 Evict guardian transcript entries in cacheable chunks (#39315)
## Why

Selecting only the newest entries changes the retained transcript prefix whenever a new entry arrives, reducing cache stability.

## What changed

- Replay non-user transcript entries through a bounded buffer and evict half of the applicable pool when an entry or token limit overflows.
- Keep message and tool token budgets independent, and reject entries that cannot fit without evicting retained evidence.
- Preserve user-message selection and emit retained entries in transcript order.

## Testing

Added coverage for stable tool prefixes, message-budget overflow, rejected messages, and chunked entry-count eviction.

GitOrigin-RevId: e6181f5a229a6de06c7ef5db21a5c74980a53e97
2026-08-18 23:43:31 +00:00
rphilizaire-openai
280d56b1d8 Attribute executor skill invocations to plugins (#39309)
## What changed

- Carry selected plugin identities from MCP discovery into per-turn extension data, limited to capability roots that are ready for the turn.
- Annotate executor skill catalog entries with the matching plugin ID and `user` scope.
- Include that attribution in `skill_invocation` analytics for both explicit and implicit executor skill invocations.

## Testing

- Extend the executor skills app-server test to verify plugin ID, skill scope, and invocation type for explicit and implicit analytics events.

GitOrigin-RevId: 9345600ae29bcb8eb894fffd2d6f7b05f22ebf74
2026-08-18 22:53:31 +00:00
felixxia-oai
c97bd2dcb5 Fail closed on Guardian V2 risk scoring errors (#39307)
## What changed

- Treat configuration, action serialization, thread lookup, and classification errors as elevated risk instead of retaining a prior low-risk result.
- Track asynchronous scoring failures separately from completed scores so approval review falls back to strict review when the latest tool call could not be scored.
- Preserve newer classification results when recording a fail-closed score.

## Testing

- Add coverage for each failure path and for ordering fail-closed scores with concurrent classifications.

GitOrigin-RevId: 7012f078a24031848f2943354a206866286ad9f4
2026-08-18 22:47:54 +00:00
felixxia-oai
e51a91b2f4 Keep Guardian v2 risk scores in memory (#39304)
## What changed

- Stop writing Guardian v2 security risk scores to rollout history.
- Treat resumed and forked threads as having no previous Guardian score, so their
  first tool approval is classified and reviewed normally.
- Remove the now-unused `codex-history` dependency from the Guardian v2
  extension.

## Testing

- Update app-server coverage for new, resumed, and forked threads to wait for
  classification completion and verify the expected approval reviews.

GitOrigin-RevId: 74d9caa903a1ff9d38e577b4697b5f8970f11ebb
2026-08-18 22:37:50 +00:00
felixxia-oai
b473c4e6ab Record Guardian v2 classification token usage (#39303)
## What changed

- Pass session-attributed extension metrics to the Guardian v2 sampler.
- Record `codex.guardian_v2.classification.token_usage` histograms for total, input, cached input, cache-write input, non-cached input, output, and reasoning output tokens.
- Preserve token accounting when streamed JSON produces an early score by recording usage from the terminal response in the background.

## Testing

- Cover token metrics through the Guardian v2 extension and the sampler's early-score path.

GitOrigin-RevId: 04fadc07f3b9cbe83f9fa3737536860b5cf5b4be
2026-08-18 22:33:28 +00:00
olliem-oai
846a16852f Improve Guardian v2 risk classification (#39264)
## What changed

- Replace the minimal default classifier prompt with predictive security-review guidance covering authorization, action risk, untrusted evidence, and browser or computer use.
- Trigger full Guardian review at an `action_risk` score of `0.5` or higher for the new default prompt, while retaining the `0.8` calibration for custom and model-provided prompts unless they specify a threshold.
- Render security policy configuration into prompt templates before enforcing the classifier instruction token limit. Prompts without the policy placeholder retain the existing append-and-truncate behavior.

## Testing

- Cover default, custom, and model-provided prompt thresholds and precedence.
- Verify policy substitution, truncation, sampling requests, and full review at the threshold boundary.

GitOrigin-RevId: 7aad9e2d8c9fbea453dc52147a3d0a46bf191aec
2026-08-18 19:12:30 +00:00
Dylan Hurd
8193c56a59 Give Guardian classifier connections distinct thread identities (#39246)
## Why

Guardian sampling uses a pool of WebSockets, while the bridge routes each
connection by thread ID. Each socket therefore needs its own identity instead
of reusing the source thread ID across the pool.

## What changed

- Generate a classifier thread ID for every pooled connection and use it for
  request, window, and subagent attribution.
- Preserve the originating thread ID in turn metadata alongside the Guardian
  classifier request kind.
- Build request metadata after leasing a connection so retries use the identity
  of the socket that carries the request.

## Testing

- Cover unique identities across pooled and replacement connections.
- Verify classifier attribution metadata for extension requests and retries.

GitOrigin-RevId: 1c36207125157ff05cab9487a2fa37bf85e5fdd8
2026-08-18 18:08:17 +00:00
felixxia-oai
e683c3118b Record Guardian v2 classification metrics (#39241)
## What changed

- Emit a `codex.guardian_v2.classification` counter for each classification.
- Record classification latency in `codex.guardian_v2.classification.duration_ms`.
- Tag both metrics with `success`, `failure`, or `superseded` outcomes.

## Testing

- Verify metrics for successful classification and fail-closed handling.

GitOrigin-RevId: 021702f3b26565d6da5708d2b8f1f8881942a441
2026-08-18 17:48:35 +00:00
jif
9b9b614b02 Include node_repl screenshots in Guardian v2 reviews (#39227)
## Why

`node_repl` screenshots are nested tool results and do not appear in the parent
conversation history, so Guardian v2 transcript image collection could miss
them.

## What changed

- Allow Guardian v2 to enable bounded, thread-scoped `node_repl` image capture
  when transcript images are configured.
- Add retained `node_repl` screenshots to review requests when transcript
  sources include tool outputs, while deduplicating images and keeping them out
  of the parent turn input.

## Testing

- Add an integration test covering screenshot capture without the synchronous
  Guardian transcript feature flags and verifying that screenshots stay out of
  the parent request.

GitOrigin-RevId: 5f70c5f2e80389aa8b2a286c3b7f9b1104865486
2026-08-18 16:38:52 +00:00
Dylan Hurd
e7e13c68e2 Add Guardian v2 approval review metrics (#39224)
## What changed

- Pass metrics bound to the active turn's model to approval-review contributors.
- Add counter support to `ExtensionMetrics` while preserving host session attribution.
- Record Guardian v2 tool-call score lag and count stale-score fallbacks with the `score_lag` reason.

## Testing

- Cover counter forwarding and session metadata tags.
- Verify Guardian v2 metric samples for current and stale scores.

GitOrigin-RevId: 0ec34736d29d2e37ed217a27e773b4f6230ae38a
2026-08-18 16:27:54 +00:00
Dylan Hurd
76ceaddb29 Reconnect Guardian sampling WebSockets after auth changes (#39220)
## Why

Guardian sampling WebSockets authenticate when the connection is opened. Reusing
a pooled connection after credentials change can therefore keep using the old
authorization.

## What changed

- Track authentication changes on each pooled sampling connection.
- Discard stale connections after an auth change and reject connections whose
  authentication changes while the handshake is in progress.

## Testing

- Verify the sampler reconnects with the refreshed bearer token instead of
  reusing its existing connection.
- Verify the installed Guardian extension reconnects after an external auth
  refresh.

GitOrigin-RevId: 6d2e7df776fd21c78be0928f71162f5419a8b8f0
2026-08-18 16:00:39 +00:00
Shijie Rao
f5e9d66851 Notify clients when Guardian requires strict review (#39157)
## What changed

- Add the experimental `autoApprovalReview/strictReviewRequired` app-server notification with the review's `threadId`, `turnId`, and `startedAtMs`.
- Emit it when Guardian v2 leaves an approval review in progress because the action risk is elevated or its score is stale.
- Export the notification through the Rust, TypeScript, and JSON schema surfaces and route it to the associated thread.

## Testing

- Cover strict-review reason tracking for elevated and stale risk scores.
- Verify that high-risk approval routing emits one notification whose identifiers and timestamp match the review-started event.

GitOrigin-RevId: e65352894520bfb756c75b2c95e2e149f9767bb2
2026-08-18 06:48:12 +00:00
willwang-openai
fc6268ad38 Read plugin authentication state from AuthManager (#39087)
## What changed

- Give `PluginsManager` a shared `AuthManager` instead of a separately mutable authentication-mode snapshot.
- Read the current authentication mode and credentials from that shared manager for plugin discovery, startup tasks, CLI commands, MCP setup, and external-agent migration.
- Update test helpers and coverage to exercise plugin projections and curated marketplace selection as authentication changes.

GitOrigin-RevId: 600c94de5130eda2da5727e1a0b4d39083fefc56
2026-08-17 22:26:27 +00:00
jif
8ef139667f Apply user MCP policy to selected executor plugins (#39079)
## What changed

- Resolve MCP server policy directly from the effective user configuration for selected executor-plugin roots.
- Apply server enablement, tool allow/deny lists, and default and per-tool approval modes while preserving stricter plugin-declared restrictions.
- Cover policy merging and opaque selected-root IDs in the executor-plugin MCP integration tests.

GitOrigin-RevId: dce3021969ba71e642de52312449cab6277515c3
2026-08-17 20:55:04 +00:00
Andrew Wilkes
682f57254f Persist generated images through turn executors (#39072)
## Why

Image generation did not save its result when the extension host did not provide a host-local save root.

## What changed

- Save generated images under the turn environment's `generated_images` directory through its sandboxed filesystem executor when no host save root is configured.
- Limit executor-written images to 32 MiB, reject symlinked output directories and existing destinations, and continue returning the image if persistence fails.
- Include the saved workspace path in the tool output hint while preserving host-managed persistence when a save root is available.

## Testing

- Extend the granted-turn-permissions integration test to verify the image and path hint are written to the turn workspace without creating a host-local artifact.

GitOrigin-RevId: 3d24381a75fe4595641b5250e19fac8ed473b2cd
2026-08-17 20:32:41 +00:00
felixxia-oai
d24507a59b Remove skill model delegation support (#39068)
## What changed

- Stop parsing and exposing the `model` field from skill frontmatter.
- Remove the skill model delegation types and instruction generation.

GitOrigin-RevId: 01198c68c095da5062e8abec417cc3539099d9d5
2026-08-17 20:19:04 +00:00
Eric Traut
eeb82a156d Dispatch queued messages written by other processes (#39034)
## Why

Durable thread queues can be updated through another SQLite connection, but loaded idle threads need to notice those updates before they can dispatch the new messages.

## What changed

- Track a durable revision for each thread queue, including backfilling existing queues and updating revisions on inserts, updates, and deletes.
- Poll SQLite's data version and query revisions to find changed queues for loaded threads.
- Wake idle threads with pending external messages, discover queued work when threads are loaded or resumed, and retry each thread independently so one blocked queue does not stall others.

## Testing

- Cover cross-runtime queue writes, edits, independent dispatch, wake retries, and resumed threads.
- Cover migration backfills and revision tracking for queue updates and deletes.

GitOrigin-RevId: 906d902bbf6a760be206a1b2c08fd71427b63c46
2026-08-17 17:19:46 +00:00
jif
21cfd369ef Add task context to shadow skill selection (#39008)
## Why

Short continuation prompts such as `continue` do not contain enough context for
skill selection on their own.

## What changed

- Add the `task_context_fusion_v1` shadow selector, combining the current request
  with up to two prior substantive requests and recently relevant skills.
- Record explicit skill intent and successful skill invocations for future turns,
  while excluding same-turn observations from predictions.
- Bound retained requests, augmented queries, and skill history, including safe
  truncation at UTF-8 character boundaries.

## Testing

Add unit and extension tests for continuation prompts, explicit intent, turn
isolation, cold thread state, bounded history, and unchanged control selectors.

GitOrigin-RevId: 72eca3f0d64620a0d24e95d5675f126ac982f8c7
2026-08-17 13:29:57 +00:00
jif
def7ed5572 Wait for Guardian score progress in approval tests (#39007)
## Why

Guardian stores a `SecurityRiskScore` before advancing its scored-tool-call
counter. Waiting only for the score can therefore let the test continue while
the asynchronous sampler is still updating its progress state.

## What changed

Wait for `latest_scored_tool_call` to advance before exercising Guardian v2
approval decisions, and reuse the same progress tracker for the subsequent
assertions.

GitOrigin-RevId: 3d92c9a3ccf52f4f43a2454aac60d2479258c1c8
2026-08-17 13:26:19 +00:00
jif
8e89e98cf6 Ignore stale Guardian tool risk scores (#39001)
## What changed

- Track the latest tool call and latest scored tool call for each Guardian v2 thread.
- Skip approval review when the score lags by more than `max_tool_call_lag` tool calls.
- Add `max_tool_call_lag` to the Guardian v2 configuration and schema, with a default of three.

## Testing

- Cover approval review at, above, and after recovering from the configured lag limit.
- Cover deserialization of `max_tool_call_lag`.

GitOrigin-RevId: fd870e143d95ee76491180e2aed742717248ff78
2026-08-17 13:06:15 +00:00
jif
4885eb6c52 Retry transient Guardian sampling failures (#38997)
## Why

Guardian sampling can encounter temporary connection or service failures while
opening a WebSocket, starting a request, or consuming its response stream.

## What changed

- Retry transient transport, streaming, rate-limit, and server failures up to
  two times across the full sampling flow.
- Recover from unauthorized responses through the configured auth manager and
  discard pooled connections that may contain stale credentials.
- Allow sampler initialization to continue when its initial WebSocket prewarm
  fails, so the first sample can establish a fresh connection.

## Testing

Added coverage for recovery after prewarm failures and `503` responses, and for
stopping once the transient retry budget is exhausted.

GitOrigin-RevId: af74c2df95c4241184ca641ef4418db6aa4ab695
2026-08-17 12:45:50 +00:00
jif
ea10ae7d0f Evaluate recent and character-routed skill selection (#38993)
## What changed

- Add shadow selectors that fuse recently invoked skills with character routing-card matches using reciprocal rank fusion.
- Add a second variant that also incorporates weighted lexical matches.
- Record both variants in the existing shadow-selection experiment, capped at 50 candidates.

## Testing

- Cover cold starts, duplicate removal, short exact matches, deterministic ranking, result limits, and truncation metadata.
- Extend the skills integration test to verify both selectors recover a skill invoked on an earlier turn.

GitOrigin-RevId: 4ff9e91da8cb49ecbce54ab8e760820616e1a1d3
2026-08-17 12:13:20 +00:00
felixxia-oai
8bf50439f2 Source Guardian v2 defaults from the model catalog (#38990)
## What changed

- Add optional `guardian_v2` model-message defaults for classifier instructions,
  review thresholds, reasoning effort, transcript selection and limits, and
  action and compaction token limits.
- Apply those defaults when Guardian v2 samples a tool call, while preserving
  explicit `[features.guardianv2]` settings over catalog values.
- Preserve the new catalog configuration when applying model overrides.

## Testing

- Cover model-catalog serialization and model override behavior.
- Verify that sampling uses catalog defaults while retaining local overrides.

GitOrigin-RevId: 4ae9ec235c647acbca05a20b7c4b87a4e1331161
2026-08-17 11:44:56 +00:00
jif
37cf6c84c0 Include images in Guardian v2 transcripts (#38987)
## What changed

- Add the `features.guardianv2.transcript.include_images` opt-in setting.
- Include recent images from user and assistant messages and configured tool outputs in Guardian v2 sampling requests.
- Bound image context to the four most recent images and 8 MiB total, and omit image detail hints when constructing the sampling request.

## Testing

- Cover configuration parsing and image forwarding from messages and tool outputs.

GitOrigin-RevId: b0ae6b6182535fd084ea103ed01dc3c803d7d1f7
2026-08-17 10:56:13 +00:00
felixxia-oai
53aa7bb1aa Bound Guardian v2 parent compaction context (#38980)
## What changed

- Add `max_parent_compaction_tokens`, defaulting to 25,000 tokens, to the Guardian v2 feature configuration.
- Reuse the latest encrypted parent compaction only when its complete serialized item fits within the configured limit.
- Fail closed with the maximum action-risk score when the latest encrypted compaction is oversized, instead of sampling with older context.

## Testing

- Cover exact-boundary and oversized compaction items, including oversized passthrough metadata.
- Verify that an oversized latest compaction bypasses sampling and prevents approval.

GitOrigin-RevId: 0b308e7bec0f41d46433dfdf656948cee5cba667
2026-08-17 10:18:24 +00:00
jif
632e35ce8d Add a configurable skill catalog token budget (#38978)
## What changed

- Add `[skills].max_context_tokens` to override the token budget used to render the available-skills catalog.
- Require a positive value and cap configured budgets at 10,000 tokens.
- Preserve the existing default of 2% of the model context window when the option is unset.

## Testing

- Cover configuration parsing, override behavior, the 10,000-token cap, and catalog rendering within the configured budget.

GitOrigin-RevId: f29ddcb57fc2d800c0006d03e1c33cbe3ab6272d
2026-08-17 10:01:59 +00:00
felixxia-oai
baab1705c6 Make Guardian v2 risk classification configurable (#38628)
## What changed

- Allow `features.guardianv2` to remain a boolean toggle or specify classifier instructions, the review threshold, reasoning effort, and action and instruction token limits.
- Add transcript controls for included sources, per-entry and total token budgets, and the number of recent non-user entries.
- Validate configured ranges and relationships, expose them in the generated config schema, and apply the resolved settings throughout Guardian v2 classification and approval review.

## Testing

- Cover boolean compatibility, configuration parsing and boundaries, config-manager rejection, and the resulting classifier request and approval decision.

GitOrigin-RevId: dc018b53b782e2d6b4d6a795cca4945130a71678
2026-08-14 19:11:41 +00:00
felixxia-oai
14a6813fa8 Apply Guardian policies to v2 risk classification (#38618)
## What changed

- Include the resolved Guardian security policy in the v2 classifier's developer instructions.
- Prefer an explicit `guardian_policy_config`, then the reviewer model's catalog policy, and finally the bundled policy.
- Limit the combined classifier instructions and policy to 10,000 tokens.

## Testing

- Cover configured and catalog policies, policy truncation, and the bundled-policy fallback.

GitOrigin-RevId: 1b84d70081dd924e214636b4b470d57a63d7cb88
2026-08-14 18:21:22 +00:00
jif
f535950eaa Skip stale Guardian risk score persistence (#38612)
## Why

Concurrent Guardian samples can finish out of order. A stale result rejected by
the thread's latest-score update could still be appended to the rollout.

## What changed

Return without persisting a risk score when `insert_if` rejects it as older than
the score already stored on the thread.

GitOrigin-RevId: 7b2c895742753a19dfe48fd7f8ecd912d3cd3af6
2026-08-14 17:41:34 +00:00
jif
742edd6c16 Prioritize new Guardian classifications under load (#38596)
## What changed

- Expand the Guardian sampling pool from 8 to 16 WebSocket connections.
- When the pool is full, supersede the oldest request that has already produced a score before replacing an unfinished classification. Treat superseded classifications as a no-op in the extension.
- Stop response WebSocket work when its event consumer is dropped, including while waiting for the connection lock or draining a completed sample.
- Allow retries across both initially warmed connections for retryable stream failures.

## Testing

- Add a concurrent sampler test that fills the pool and verifies scored drains are replaced before an unfinished classification.

GitOrigin-RevId: 9e4df7b01516094726ff3e11878f8ca742d21b03
2026-08-14 15:55:01 +00:00
jif
23094236ac Let extensions resolve approval reviews before Guardian (#38592)
## What changed

- Give approval review contributors the first opportunity to resolve an action when automatic review is not required for the model.
- Return an extension's decision directly and fall back to Guardian when no extension claims the review.
- Update Guardian V2 to approve actions below its risk threshold through the review contributor API, and remove the extension approval-policy API.

## Testing

- Verify that an extension approval bypasses both the Guardian model call and the user approval prompt.
- Cover Guardian V2 review decisions for low-risk, high-risk, and disabled threads.

GitOrigin-RevId: 5be56941143aff6f358b75b5f8101b7c047147ae
2026-08-14 15:24:10 +00:00
felixxia-oai
5bc8da6d78 Bound Guardian V2 tool actions before risk classification (#38586)
## Why

Oversized tool arguments could make Guardian V2's model-visible action unbounded.

## What changed

- Cap serialized actions at 10,000 tokens while preserving the trusted tool name and `call_id`.
- Truncate nested string values evenly across the available budget.
- Omit lower-priority fields when the JSON structure alone exceeds the limit, while retaining useful action fields when they fit.

## Testing

Add coverage for oversized nested strings, arrays, and object keys, including spoofed identity fields and omission-marker collisions.

GitOrigin-RevId: 13f7dc93da3761db18a34087225196318a3b8098
2026-08-14 14:33:39 +00:00
jif
2a452d7dc1 Keep the latest Guardian risk score during concurrent sampling (#38580)
## Why

Concurrent Guardian samples can finish out of order, allowing an older sample to
replace the thread's newer in-memory security risk score.

## What changed

- Record when each `SecurityRiskScore` sample starts while preserving compatibility
  with records that have no timestamp.
- Add `ExtensionData::insert_if` so checking and replacing a typed attachment happen
  under the same lock.
- Update Guardian V2 to replace the thread's risk score only when the completed sample
  is newer than the stored one.

## Testing

- Verify concurrent conditional inserts retain the newest value.
- Verify Guardian-generated risk scores include a sampling timestamp.

GitOrigin-RevId: 6543a4e5497da4c623331050789e91613f931c4b
2026-08-14 13:44:51 +00:00
jif
1c4f42863c Require automatic review for high-risk Guardian v2 actions (#38569)
## What changed

- Add a thread-scoped extension API for requesting automatic review, resolving
  multiple contributors to the strongest requirement.
- Have Guardian v2 request automatic review when it is enabled and the latest
  `action_risk` score is at least `0.8`.
- Honor extension review requirements across tool approvals, MCP elicitation,
  and remote execution while preserving host configuration and managed-policy
  constraints.

## Testing

- Cover contributor registration and requirement resolution.
- Verify Guardian v2 requests review at the threshold, returns to the default
  below it, and does not affect threads where the extension is disabled.
- Exercise extension-requested strict review with a remote model override.

GitOrigin-RevId: 6329fc23585d5cc7173c39bb9952c3109ec3884b
2026-08-14 12:37:13 +00:00
felixxia-oai
d40dfcc3c7 Run tool start callbacks after pre-tool hooks (#38568)
## What changed

- Invoke `ToolLifecycleContributor::on_tool_start` only after pre-tool hooks
  have finalized the invocation.
- Pass hook-rewritten arguments and the post-hook conversation snapshot to the
  callback.
- Skip the start callback when a hook denies execution or supplies input that
  cannot be applied.

## Testing

Add lifecycle tests covering rewritten input, hook-added context, denied tool
calls, and invalid rewritten input.

GitOrigin-RevId: 936efaf4a8c35321f9982ff2a33bb8bece1ebf39
2026-08-14 12:21:08 +00:00
jif
aa905bb962 Store security risk scores as a snapshot (#38567)
## What changed

- Replace the single `category` and `score` fields in `SecurityRiskScore` with a
  deterministic map of category names to scores.
- Validate the full Guardian V2 classifier response before storing it as one
  thread extension value and, for non-ephemeral threads, one rollout item.
- Cover serialization and rollout loading with snapshots containing multiple
  score categories.

GitOrigin-RevId: 24525de691f96bd34ccfe04acab2f01aca309837
2026-08-14 12:16:51 +00:00
felixxia-oai
08c48e3700 Reuse compatible parent compactions in Guardian V2 (#38564)
## Why

Guardian V2 classification requests should retain compacted conversation context only when the parent and classifier model configurations can share the encrypted compaction.

## What changed

- Resolve the classifier model's compaction compatibility hash when initializing its sampler.
- Add the latest encrypted parent compaction to classification input when both models have the same non-empty compatibility hash.
- Ignore missing, empty, or unidentified compactions, and omit parent context when compatibility cannot be established.

## Testing

- Cover latest-compaction selection and invalid compaction data.
- Cover matching, mismatched, missing, empty, and changed compatibility hashes.

GitOrigin-RevId: f0fcb09fd028cd2f397fdbc3d541b4bc464b0beb
2026-08-14 11:55:10 +00:00
felixxia-oai
486df09a00 Improve Guardian transcript context selection (#38558)
## What changed

- Replace the single byte limit with token-derived per-entry and separate message and tool transcript budgets.
- Preserve the first and latest user messages, then fill the remaining budgets with recent user, assistant, and tool context while limiting retained non-user entries.
- Truncate oversized entries in the middle without splitting UTF-8 characters, and report the approximate omitted token count.
- Exclude reasoning from the default transcript sources while retaining support when it is explicitly configured.

## Testing

- Cover oversized message and tool-result truncation, user-message retention, separate tool budgeting, configured reasoning, and the resulting Guardian sampling request.

GitOrigin-RevId: aaeaa5fb5d902b5a1581a8a819bf34724bde794b
2026-08-14 11:17:50 +00:00
felixxia-oai
db5b4a4cfb Preserve Guardian transcript boundaries in sampling input (#38555)
## What changed

- Represent Guardian sampling input as an ordered list of text entries.
- Send each transcript entry and approval-request delimiter as a separate input
  content item while preserving the existing transcript byte limit.

## Testing

- Update transcript and sampler tests to verify entry boundaries, multi-item
  request serialization, and bounded transcript behavior.

GitOrigin-RevId: 433e2e6ca18ce9288025715f5956295bfe852e98
2026-08-14 11:02:01 +00:00
jif
a44f266a4a Initialize Guardian V2 samplers per thread (#38553)
## What changed

- Register Guardian V2 for thread startup as well as tool-call lifecycle events.
- When `guardianv2` is enabled, create and store a thread-local Luna sampler using the thread's model provider, authentication policy, session metadata, originator, and service tier.
- Emit a warning if sampler initialization fails, and skip tool classification when the thread has no sampler.

## Testing

- Update the extension test to enable `guardianv2`, run thread startup, and verify tool-call sampling through the initialized connection.

GitOrigin-RevId: 5ab732e85c9827495c67f57117eb5be450a7f90e
2026-08-14 10:58:56 +00:00
jif
8630bb3cae Record Guardian V2 risk scores on threads (#38540)
## What changed

- Parse and validate the structured risk scores returned for each classified tool call.
- Publish each score through thread extension data and persist it in rollout history for non-ephemeral threads.
- Report parsing, thread lookup, validation, and persistence failures through the extension warning sink.

## Testing

- Extend the Guardian V2 tool-classification test to verify that the sampled `action_risk` score is available from thread extension data and written to rollout history.

GitOrigin-RevId: 46614fe0d686736dfb1f09398c6fcd848c7d8b2c
2026-08-14 09:27:41 +00:00
Dylan Hurd
4eff3b788b Configure Guardian sampling for responses lite (#38527)
## What changed

- Opt Guardian V2 Luna sampler WebSocket connections into responses lite.
- Send `reasoning.context` as `all_turns` on sampling requests.

## Testing

- Extend sampler and extension tests to verify the connection header and reasoning context.

GitOrigin-RevId: 4b0263c01b8259ed5268c222dcf7559912baba8c
2026-08-14 08:16:23 +00:00
sayan-oai
fdbab67c66 Carry environment config in turn selections (#38521)
## What changed

- Add `EnvironmentConfigState` to `TurnEnvironmentSelection` so each environment attachment can inherit thread configuration or carry ready configuration for its login-shell policy and selected capability roots.
- Apply ready configuration during thread creation and thread-settings updates while reusing the existing environment connection.
- Validate selection configuration before applying settings, rejecting unsupported pending state and invalid capability roots.

## Testing

- Cover attachment-scoped capability roots, ready configuration at thread startup and turn updates, and rejection of invalid selections without changing existing settings.

GitOrigin-RevId: 86cf8f2148fdaa746ea0dd12890ab7b1577d7587
2026-08-14 07:52:38 +00:00
felixxia-oai
3711943d11 Parse model annotations from skill frontmatter (#38467)
## What changed

- Add an optional `model` field to parsed and loaded skill metadata.
- Recognize `model: luna` while ignoring unsupported model values without
  preventing the rest of the skill metadata from loading.

## Testing

- Cover supported, absent, unsupported, and repaired frontmatter model values.

GitOrigin-RevId: 376b65555e81d29a5eae93cc4c2633aacf7cd7c8
2026-08-14 00:54:45 +00:00
efrazer-oai
9341b38310 Add experimental thread queue APIs to app server (#38456)
## What changed

- Add experimental `thread/queue/add`, `list`, `update`, `delete`, `reorder`, and `start` requests for persistent queued user submissions.
- Automatically dispatch queued submissions in FIFO order after completed or failed turns, while leaving the queue paused after interruption.
- Emit `thread/queue/changed` notifications and expose paginated queue contents with stable submission and client message IDs.
- Export the new protocol types through the generated JSON Schema and TypeScript bindings.

## Testing

- Add app-server integration coverage for capability gating, CRUD, pagination, capacity limits, notifications, automatic dispatch, cold-thread resume, interruption, and explicit queue starts.

GitOrigin-RevId: 89caf5577192199bda77cf6c372a59d26cdd910e
2026-08-13 23:38:02 +00:00
willwang-openai
1da59ad257 Support per-server MCP OAuth callback ports (#38448)
## What changed

- Add `oauth.callback_port` to MCP server configuration and preserve it when
  serializing configuration edits.
- Accept `oauth.callbackPort` from plugin MCP declarations and skill dependency
  metadata.
- Prefer the server-specific callback port over `mcp_oauth_callback_port` for
  CLI login, app-server, plugin installation, executor, and skill dependency
  OAuth flows.

## Testing

- Cover configuration parsing, serialization, and fallback behavior.
- Verify plugin, executor, and skill OAuth registrations use their configured
  callback ports instead of the global port.

GitOrigin-RevId: 7f65e5e7869358307e49779f1b75e8672b607736
2026-08-13 22:42:12 +00:00
felixxia-oai
53eaa297e5 Give Guardian V2 full tool action context (#38441)
## Why

Guardian V2 needs the requested action and its conversation context to assess
risk; a tool name and call ID alone do not describe what the tool will do.

## What changed

- Expose the original, pre-hook `ToolPayload` to tool lifecycle contributors.
- Build Guardian V2 classifier input from the bounded conversation transcript
  and a structured planned-action object containing the tool name and arguments.
- Warn and skip classification if the planned action cannot be serialized.

## Testing

- Verify lifecycle contributors receive tool arguments.
- Verify Guardian V2 sends transcript history and planned-action JSON to the
  classifier.

GitOrigin-RevId: 28266ef7c1d2267ba705fcfbd9be4ef48e64e104
2026-08-13 21:49:32 +00:00
willwang-openai
f898ebcafd Route curated plugin catalogs by authentication mode (#38429)
## Why

The model provider does not reliably identify which curated plugin catalog is
available. ChatGPT authentication can be used with a custom provider, while an
unauthenticated session should use the API-compatible catalog regardless of its
provider.

## What changed

- Select the ChatGPT curated catalog only for authentication modes that use the
  Codex backend; use the API curated catalog for API-key and unauthenticated
  sessions.
- Initialize standalone plugin managers with the current authentication mode
  across CLI, app-server, MCP, and external-agent migration paths.
- Preserve authentication mode while detecting and importing migrated plugins.

## Testing

- Cover catalog and skill routing across ChatGPT, API-key, unauthenticated,
  Bedrock, and custom-provider configurations.
- Verify authenticated plugin migration uses the ChatGPT curated marketplace.

GitOrigin-RevId: 660a339ee8891c33aad961078d3a979242a6a166
2026-08-13 20:20:01 +00:00