codex icon indicating copy to clipboard operation
codex copied to clipboard

Auto Web Search on “Recency Intent” (natural-language trigger) in Codex CLI

Open santiago-acosta-finmaq opened this issue 3 months ago • 3 comments
trafficstars

What feature would you like to see?

Enable an Auto Web Search mode so that, when the user’s prompt implicitly or explicitly asks for recent/up-to-date information (e.g., “as of today”, “latest version”, “recent news”, “información reciente”), the agent automatically calls the built-in web.search tool and returns citations—without the user needing to run a special command.

Are you interested in implementing this feature?

No response

Additional information

Problem

Many coding tasks require fresh context (latest library APIs, breaking changes, CVEs, release notes). Today, users must remember to toggle web search manually, which adds friction and leads to stale or hallucinated answers.

Proposed behavior

  • New Auto mode for web search: the agent detects “recency intent” in natural language and performs a web search automatically, respecting approval policies.
  • Detection can be hybrid: lightweight rules + small classifier (or LLM tool-choice) to avoid unnecessary calls.

UX / API

CLI

# One-off auto mode
codex --model gpt-5 --enable-web --web-mode auto "Tell me the latest stable Next.js features and examples"

# Explicit off (manual only)
codex --model gpt-5 --enable-web --web-mode off "..."

TUI

/web auto     # auto-detect recency intent and search
/web on       # always allow web tool (agent decides when)
/web off      # disable web tool

Config (~/.codex/config.toml)

[web_search]
enabled   = true         # default false
mode      = "auto"       # "auto" | "on" | "off"
provider  = "bing"       # or "ddg" | "serpapi" | "custom"
max_results = 5
timeout_ms  = 12000
citations   = "inline"   # "inline" | "panel"
cache_ttl   = "24h"

# Safety
allowlist = ["docs.python.org", "pypi.org", "developer.mozilla.org"]
denylist  = []
respect_robots_txt = true

Approval flow

  • If approval_policy = "on-request", the first time auto-mode fires in a session:

    • Prompt: “The agent detected a request for recent info (‘’). Allow web search? [once/always/deny]”
  • Subsequent auto searches follow the chosen preference and are logged with URLs.

“Recency intent” detection (examples)

Should trigger:

  • “necesito información reciente sobre…”
  • as of today/today”, “what’s the latest version of…”
  • “release notes 2025”, “changes this week”, “new CVEs”, “recent deprecations”
  • “¿Cuál es el precio actual / CEO actual / estado hoy?”

Should not trigger:

  • “Explain Big-O of quicksort”
  • “Refactor this function”
  • “Write unit tests for this file”

Heuristics (initial pass):

  • Keyword match + date/time phrases
  • Entities that typically require freshness (prices, CEOs, versions, CVEs, “just announced”, “breaking change”)
  • Confidence threshold; only call web.search when ≥ threshold

Output & citations

  • Inline footnotes [1] linking to sources, and/or a Sources panel with {title, url, snippet}.
  • Clear “Web” badge in the message header when auto-search was used.

Minimal implementation plan

  1. Add web_mode setting: off | on | auto.

  2. Implement a recency intent detector:

    • Rule set (regex/keywords) + optional small model/classifier.
    • Confidence score surfaced in logs.
  3. Hook into agent tool-choice: if web_mode=auto and needs_recent=true, call web.search.

  4. Respect approval_policy; remember the user’s decision per session.

  5. Add caching + deduplication of identical queries (respect cache_ttl).

  6. Render citations (inline + panel) in TUI and export in transcripts.

  7. Telemetry (opt-in): count of auto triggers, denials, timeouts.

Privacy & safety

  • Off by default; explicit opt-in via flag/config.
  • Never send local file contents or secrets in queries (redaction pass).
  • Allowlist/denylist; respect robots.txt; clear network indicator in status bar.

Acceptance criteria

  • [ ] --web-mode auto triggers web search when prompts imply “recent info” and shows citations.
  • [ ] First auto-trigger in a session honors approval_policy with once/always/deny.
  • [ ] /web auto|on|off updates /status in the TUI.
  • [ ] Config + env vars override precedence works as documented.
  • [ ] No spurious web calls on clearly timeless prompts.
  • [ ] Errors/timeouts degrade gracefully with a visible notice.
  • [ ] Cache prevents duplicate calls within cache_ttl.

Alternatives considered

  • Require explicit /search web "<query>" each time (high friction).
  • Force users to write a custom tool (not discoverable; poor DX).

santiago-acosta-finmaq avatar Aug 21 '25 16:08 santiago-acosta-finmaq

Literally any web search tool at all would be a huge improvement.

I'm coming from Claude Code when I said "search the web for ..." and it came back saying it didn't have search capability I was shocked. It's a super basic need.

BenJackGill avatar Aug 31 '25 04:08 BenJackGill

@BenJackGill That exists, look at the --search flag added in 0.24.0:

  • https://github.com/openai/codex/releases/tag/rust-v0.24.0
    • Web search when using explicit --search option (https://github.com/openai/codex/pull/2371)

0xdevalias avatar Aug 31 '25 08:08 0xdevalias

Partially overlap with https://github.com/openai/codex/issues/3139

bhack avatar Sep 06 '25 13:09 bhack

I like the idea of the automatic context, this is similar to how GPT web worked early on. Alternatively, an option to enable search by toggle on/off per prompt along with a default on/off that is not hidden in config.toml.

bmccarthyco avatar Oct 28 '25 20:10 bmccarthyco