The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(web): cover the openai-native swap, document the backend
lyswty39ef4d5a77d7
diff --git a/tests/agent/transports/test_codex_transport.py b/tests/agent/transports/test_codex_transport.pyindex a9a5cb6bab5..47a3e9274a6 100644--- a/tests/agent/transports/test_codex_transport.py+++ b/tests/agent/transports/test_codex_transport.py@@ -995,6 +995,89 @@ class TestCodexBuildKwargs:for t in tools)+ # --- OpenAI Codex native web-search swap ---+ # The Codex Responses endpoint exposes the same server-executed+ # ``web_search`` built-in as xAI, so selecting the ``openai-native``+ # backend performs the same 1:1 swap. Unlike xAI there is no alias path:+ # an unselected or non-Codex request keeps the client-side function, so a+ # custom OpenAI-compatible endpoint never receives a tool it cannot host.++ def test_openai_native_swaps_client_web_search_for_builtin(self, transport, monkeypatch):+ """Selecting ``openai-native`` replaces the client ``web_search``+ function with the provider-executed built-in. ``web_extract`` is a+ separate capability and must survive — native search covers search only.+ """+ import agent.transports.codex as codex_mod++ monkeypatch.setattr(codex_mod, "_openai_prefers_native_web_search", lambda: True)+ kw = transport.build_kwargs(+ model="gpt-5.6-sol",+ messages=[{"role": "user", "content": "Find current prices."}],+ tools=[+ {"type": "function", "function": {+ "name": "read_file", "description": "Read a file.",+ "parameters": {"type": "object",+ "properties": {"path": {"type": "string"}}}}},+ {"type": "function", "function": {+ "name": "web_search", "description": "Search the web.",+ "parameters": {"type": "object",+ "properties": {"query": {"type": "string"}}}}},+ {"type": "function", "function": {+ "name": "web_extract", "description": "Extract a page.",+ "parameters": {"type": "object",+ "properties": {"url": {"type": "string"}}}}},+ ],+ is_codex_backend=True,+ )+ tools = kw.get("tools", [])+ assert any(t.get("type") == "web_search" for t in tools), tools+ names = [t.get("name") for t in tools if t.get("type") == "function"]+ assert "web_search" not in names+ assert "read_file" in names+ assert "web_extract" in names++ def test_openai_native_not_selected_keeps_client_web_search(self, transport, monkeypatch):+ """A Codex turn that has not selected ``openai-native`` keeps Hermes+ dispatch — the built-in must never be granted additively."""+ import agent.transports.codex as codex_mod++ monkeypatch.setattr(codex_mod, "_openai_prefers_native_web_search", lambda: False)+ kw = transport.build_kwargs(+ model="gpt-5.6-sol",+ messages=[{"role": "user", "content": "Find current prices."}],+ tools=[{"type": "function", "function": {+ "name": "web_search", "description": "Search the web.",+ "parameters": {"type": "object",+ "properties": {"query": {"type": "string"}}}}}],+ is_codex_backend=True,+ )+ tools = kw.get("tools", [])+ assert not any(t.get("type") == "web_search" for t in tools), tools+ names = [t.get("name") for t in tools if t.get("type") == "function"]+ assert "web_search" in names++ def test_openai_native_ignored_on_non_codex_transport(self, transport, monkeypatch):+ """The provider-executed built-in only exists on+ ``chatgpt.com/backend-api/codex``. A custom OpenAI-compatible endpoint+ must keep the client tool even when the search backend says native.+ """+ import agent.transports.codex as codex_mod++ monkeypatch.setattr(codex_mod, "_openai_prefers_native_web_search", lambda: True)+ kw = transport.build_kwargs(+ model="gpt-5.6-sol",+ messages=[{"role": "user", "content": "Find current prices."}],+ tools=[{"type": "function", "function": {+ "name": "web_search", "description": "Search the web.",+ "parameters": {"type": "object",+ "properties": {"query": {"type": "string"}}}}}],+ is_codex_backend=False,+ )+ tools = kw.get("tools", [])+ assert not any(t.get("type") == "web_search" for t in tools), tools+ names = [t.get("name") for t in tools if t.get("type") == "function"]+ assert "web_search" in names+# --- Grok reasoning-effort capability allowlist ---# api.x.ai 400s with "Model X does not support parameter reasoningEffort"# on grok-4 / grok-4-fast / grok-3 / grok-code-fast / grok-4.20-0309-*.diff --git a/website/docs/user-guide/features/web-search.md b/website/docs/user-guide/features/web-search.mdindex 6fdd7254d45..37f458932e8 100644--- a/website/docs/user-guide/features/web-search.md+++ b/website/docs/user-guide/features/web-search.md@@ -28,8 +28,9 @@ Both are configured through a single backend selection. Providers are chosen via| **Perplexity** | `PERPLEXITY_API_KEY` | ✔ | ✔ (query-relevant snippets) | Paid (per-request Search API pricing) || **Keenable** | `KEENABLE_API_KEY` (optional) | ✔ | ✔ | ✔ Keyless ring member · paid with key || **xAI (Grok)** | `XAI_API_KEY` or `hermes auth add xai-oauth` | ✔ | — | Paid (SuperGrok or per-token) |+| **OpenAI Native (Codex)** | `hermes auth --provider openai-codex` | ✔ | — | Requires a ChatGPT/Codex subscription |-Brave Search, DDGS, and xAI are **search-only** — pair any of them with Firecrawl/Tavily/Perplexity/Keenable/Exa/Parallel when you also need `web_extract`. DDGS uses the [`ddgs` Python package](https://pypi.org/project/ddgs/) under the hood; if it isn't already installed, run `pip install ddgs` (or let Hermes lazy-install it on first use). xAI runs Grok's server-side `web_search` tool on the Responses API — results are LLM-generated rather than index-backed, so titles, descriptions, and URL choice are all model output (see the [trust-model caveat](#xai-grok) below).+Brave Search, DDGS, xAI, and OpenAI Native are **search-only** — pair any of them with Firecrawl/Tavily/Perplexity/Keenable/Exa/Parallel when you also need `web_extract`. DDGS uses the [`ddgs` Python package](https://pypi.org/project/ddgs/) under the hood; if it isn't already installed, run `pip install ddgs` (or let Hermes lazy-install it on first use). xAI runs Grok's server-side `web_search` tool on the Responses API — results are LLM-generated rather than index-backed, so titles, descriptions, and URL choice are all model output (see the [trust-model caveat](#xai-grok) below). OpenAI Native declares the same kind of provider-executed tool on the Codex Responses endpoint (see [below](#openai-native)).**Per-capability split:** you can use different providers for search and extract independently — for example SearXNG (free) for search and Firecrawl for extract. See [Per-capability configuration](#per-capability-configuration) below.@@ -375,6 +376,24 @@ web:Unlike index-backed providers (Brave, Tavily, Exa) which return verbatim search-engine results, xAI is an LLM choosing which URLs to surface and writing the titles and descriptions itself. The *content* of the query influences the output, so a maliciously crafted query (e.g. injected via untrusted upstream input the agent picked up) can in principle steer Grok into emitting attacker-chosen URLs. Treat returned URLs the same way you'd treat any model-generated link — validate before fetching, especially if the query came from untrusted input.:::+### OpenAI Native (Codex Responses) {#openai-native}++Declares OpenAI's provider-executed `web_search` tool on the Codex Responses endpoint (ChatGPT/Codex subscriptions). The model drives search server-side and folds the results into its own answer — Hermes never runs a client-side search in this mode.++```yaml+# ~/.hermes/config.yaml+web:+ search_backend: "openai-native"+```++Requirements and scope:++- **Credentials**: an openai-codex OAuth login (`hermes auth --provider openai-codex`). This backend has no API key of its own; without a login it is simply unavailable.+- **Transport**: only the Codex Responses endpoint exposes the built-in. On any other transport — a custom OpenAI-compatible `base_url`, or a non-OpenAI model — the client-side `web_search` function is left untouched, because the endpoint cannot be relied on to host the tool. Point `web.search_backend` at an ordinary provider for those.+- **Search only**: the built-in covers search, not extraction. Pair it with Firecrawl (or another extract-capable backend) through `web.extract_backend` when you also need `web_extract`.++**One tool either way.** Selecting this backend swaps the client-side `web_search` function for the built-in 1:1 — it is not an additive grant. A session whose toolset has no `web_search` never gets server-side search injected.+---## Configuration