Skip to content

feat: add support for allowed_web_search_modes in requirements.toml#10964

Merged
bolinfest merged 1 commit intomainfrom
pr10964
Feb 7, 2026
Merged

feat: add support for allowed_web_search_modes in requirements.toml#10964
bolinfest merged 1 commit intomainfrom
pr10964

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Feb 7, 2026

This PR makes it possible to disable live web search via an enterprise config even if the user is running in --yolo mode (though cached web search will still be available). To do this, create /etc/codex/requirements.toml as follows:

# "live" is not allowed; "disabled" is allowed even though not listed explicitly.
allowed_web_search_modes = ["cached"]

Or set requirements_toml_base64 MDM as explained on https://developers.openai.com/codex/security/#locations.

Why

  • Enforce admin/MDM/requirements.toml constraints on web-search behavior, independent of user config and per-turn sandbox defaults.
  • Ensure per-turn config resolution and review-mode overrides never crash when constraints are present.

What

  • Add allowed_web_search_modes to requirements parsing and surface it in app-server v2 ConfigRequirements (allowedWebSearchModes), with fixtures updated.
  • Define a requirements allowlist type (WebSearchModeRequirement) and normalize semantics:
    • disabled is always implicitly allowed (even if not listed).
    • An empty list is treated as ["disabled"].
  • Make Config.web_search_mode a Constrained<WebSearchMode> and apply requirements via ConstrainedWithSource<WebSearchMode>.
  • Update per-turn resolution (resolve_web_search_mode_for_turn) to:
    • Prefer Live → Cached → Disabled when SandboxPolicy::DangerFullAccess is active (subject to requirements), unless the user preference is explicitly Disabled.
    • Otherwise, honor the user’s preferred mode, falling back to an allowed mode when necessary.
  • Update TUI /debug-config and app-server mapping to display normalized allowed_web_search_modes (including implicit disabled).
  • Fix web-search integration tests to assert cached behavior under SandboxPolicy::ReadOnly (since DangerFullAccess legitimately prefers live when allowed).

@bolinfest bolinfest requested a review from viyatb-oai February 7, 2026 02:02
@bolinfest bolinfest force-pushed the pr10964 branch 3 times, most recently from 8f93792 to d9a6866 Compare February 7, 2026 02:25
@bolinfest bolinfest marked this pull request as ready for review February 7, 2026 02:26
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9a6866735

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 412 to 425
let initial_mode = match modes.first().copied() {
Some(mode) => mode,
None => {
modes.push(WebSearchModeRequirement::Disabled);
WebSearchModeRequirement::Disabled
}
};
let mut accepted = modes.into_iter().collect::<std::collections::BTreeSet<_>>();
accepted.insert(WebSearchModeRequirement::Disabled);
let accepted_for_error: Vec<WebSearchMode> =
accepted.iter().copied().map(Into::into).collect();
let initial_value = Some(WebSearchMode::from(initial_mode));
let requirement_source_for_error = requirement_source.clone();
let constrained = Constrained::new(initial_value, move |candidate| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid fixing default to first allowlist entry

When allowed_web_search_modes is present, this code forces an initial value to the first entry and the validator rejects None, which makes the config look explicitly set even when the user never chose a mode. That bypasses the sandbox-based default selection in resolve_web_search_mode_for_turn, so an allowlist like ["cached", "live"] will always default to cached (or whatever is listed first), even in danger-full-access where the previous default was live. If the allowlist is meant to only constrain valid modes, this is a behavioral regression; consider allowing None and letting per-turn resolution pick the preferred allowed mode instead of treating list order as a forced default.

Useful? React with 👍 / 👎.

@bolinfest bolinfest force-pushed the pr10964 branch 2 times, most recently from b549a43 to d9b9a74 Compare February 7, 2026 02:57
Example:

```toml
# This means that "live" is not allowed; "disabled" is allowed even though not listed explicitly.
allowed_web_search_modes = ["cached"]
```

### Why
- Support admin/MDM/requirements.toml constraints over web-search behavior, independent of user config or sandbox defaults.
- Ensure per-turn config resolution and review-mode overrides can never crash when constraints are present.
- Note that `allowed_web_search_modes = ["cached"]` denies `"live"`, even if `--yolo` is used. See `resolve_web_search_mode_for_turn()`.

### What
- Add `allowed_web_search_modes` to requirements parsing and app-server v2 `ConfigRequirements` (`allowedWebSearchModes`), with schema/TS fixture updates.
- Introduce TOML-only `WebSearchModeRequirement` for requirements allowlists; accept `disabled|cached|live`, and treat an empty list as `[disabled]`.
- Convert the allowlist to a `ConstrainedWithSource<Option<WebSearchMode>>`, always permitting `Disabled` while enforcing membership for other values.
- Make `Config.web_search_mode` a constrained field, update call sites/tests, and surface constraint violations via warnings/fallback.
- Extend TUI `/debug-config` output to display `allowed_web_search_modes`.

### Safety
- Avoid `expect()` on constrained `web_search_mode` mutation in session per-turn config and review-thread setup; warn and keep the constrained value instead.
@bolinfest bolinfest enabled auto-merge (squash) February 7, 2026 05:44
@bolinfest bolinfest merged commit a118494 into main Feb 7, 2026
95 of 106 checks passed
@bolinfest bolinfest deleted the pr10964 branch February 7, 2026 05:55
@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants