By Tomás Herrera, NBT
Both coding agents can look things up online: a library's changelog, an error message, the current API of a package released after the model was trained. That's useful. It's also a channel you should control. A web page is untrusted input that lands straight in the agent's context, and on some projects (client work, regulated code, an air-gapped build box) you want the agent offline or limited to a short list of sites.
Codex and Claude Code handle this very differently. Codex treats web search as one setting with several modes. Claude Code treats search and fetching pages as two separate tools governed by permission rules. Here's how each works, with config you can copy, and the gotcha they share.
The short version
| Codex | Claude Code | |
|---|---|---|
| What the agent gets | A web search tool | Two tools: WebSearch and WebFetch |
| Default | web_search = "cached": results from an OpenAI-maintained index, no live access | Both tools ask for approval (WebFetch skips the prompt for a built-in list of documentation sites) |
| Turn it off | web_search = "disabled" | Deny rules for WebSearch and WebFetch |
| Limit to some sites | allowed_domains under [tools.web_search] | WebFetch(domain:...) allow rules |
Does it cover curl in the shell? | No, that's the sandbox's network setting | No, that's Bash rules and the sandbox |
Codex: one setting, four modes
In ~/.codex/config.toml (or a project-level config), the top-level web_search key picks the mode. The Codex config reference lists four values:
-
"cached", the default. Searches go to an index OpenAI maintains, without the agent reaching the live web. -
"indexed". External access is allowed only when gated by the search index. -
"live". Unrestricted live retrieval. -
"disabled". Removes the tool.
One catch: if you run with --yolo or another full-access sandbox setting, the default becomes "live". So "I never touched it" means different things depending on how you start Codex.
To switch it off for a sensitive project:
web_search = "disabled" To keep it on but narrow it, use the [tools.web_search] table. Its object form accepts allowed domains, a search context size and an approximate location:
web_search = "live" [tools.web_search] context_size = "low" allowed_domains = ["docs.python.org", "developer.mozilla.org", "github.com"] If you have older configs, you may see features.web_search, features.web_search_cached or features.web_search_request. The reference marks all three as deprecated legacy toggles. Replace them with the top-level web_search key.
Claude Code: two tools, permission rules
Claude Code splits the job:
- WebSearch runs a search and returns results.
- WebFetch downloads a specific URL and reads it.
By default both need your approval. If you pick "Yes, and don't ask again," Claude Code saves a rule to .claude/settings.local.json in the repository: per domain for WebFetch, for the whole repository for WebSearch. WebFetch is pre-approved for a built-in set of documentation domains, so it may read some docs pages without asking.
You control both with permission rules in .claude/settings.json. To take the agent fully offline for a project:
{ "permissions": { "deny": ["WebSearch", "WebFetch"] } } A bare WebFetch deny removes the tool entirely, so the model doesn't even try.
To allow fetching only from a few sites, without prompts:
{ "permissions": { "allow": [ "WebFetch(domain:docs.python.org)", "WebFetch(domain:*.github.com)" ], "deny": ["WebSearch"] } } The rule details, from the permissions docs:
-
domain:matches the hostname, case-insensitive. -
WebFetch(domain:example.com)matches onlyexample.com, not subdomains. AddWebFetch(domain:*.example.com)for those. That form matches any depth of subdomain but notexample.comitself, so you often want both. - A
*in the middle only matches one label:example.*matchesexample.orgbut notexample.evil.com. - Wildcards in WebFetch rules need Claude Code v2.1.172 or later.
With only those allow rules, fetches to other domains still prompt you, so nothing outside the list happens without your say-so. Resist adding a catch-all WebFetch(domain:*) deny to "block the rest": a deny rule wins over an allow rule, so it would block your allowed sites too.
The gotcha they share: the shell is a separate door
This is the part people miss with both tools. Turning off web search does nothing about curl.
- Codex: The config reference says that search-domain filters are separate from the network rules for sandboxed commands, and that network settings for commands don't restrict hosted tools like web search. Two different controls. For shell commands, the workspace-write sandbox has its own switch:
sandbox_mode = "workspace-write" [sandbox_workspace_write] network_access = false - Claude Code: The permissions page is blunt about it: "using WebFetch alone doesn't prevent network access. If Bash is allowed, Claude can still use
curl,wget, or other tools to reach any URL." You can add deny rules forBash(curl *)and similar, but the docs warn that a deny rule doesn't catch the same program by full path or insidesh -c. When the restriction really has to hold, pair the rules with the sandbox's network allowlist.
So "offline" in practice means two settings in each tool: one for the search/fetch tool, one for commands.
Step-by-step: one project, both tools, offline
Say a client asks that nothing from their repo talks to the internet during agent sessions. Here's what I set:
- Codex, in the project's config:
web_search = "disabled" sandbox_mode = "workspace-write" [sandbox_workspace_write] network_access = false - Claude Code, in
.claude/settings.json:
{ "permissions": { "deny": ["WebSearch", "WebFetch", "Bash(curl *)", "Bash(wget *)"] } } Plus sandboxing turned on with an empty network allowlist, on systems where Claude Code supports it.
Test it. Ask each agent to "look up the latest version of requests on PyPI." Codex should say it has no search tool. Claude Code should report the tool is unavailable or denied. Then ask each to "run
curl https://pypi.org." It should fail or be blocked, not succeed.Write it down in AGENTS.md and CLAUDE.md: "No web access in this repo. Dependency docs are in /docs/vendor." Give the agents an offline place to look, or they'll keep asking.
Which model do I prefer?
Codex's single key is quicker to reason about, and the cached default is a sensible middle ground: fresh-ish information without the agent fetching arbitrary pages. Claude Code's split is more granular. Allowing fetches from three documentation sites while blocking search entirely is easy, and approvals are remembered per domain per repo. Neither is safer by default once you account for the shell. Both need the second setting.
For the wider comparison beyond web access, from pricing to sandboxing to session handling, see this Codex vs Claude Code breakdown, which also covers Copilot CLI.
