Skip to content

Gemini CLI

Google’s Gemini CLI gets to the web through two tools, and the surprising part is that by default both run in Google’s cloud, not on the developer’s machine. google_web_search asks a Gemini model with Google Search grounding, so it reads Google’s index and never contacts your site, while web_fetch hands URLs to Gemini’s urlContext tool, which fetches them from Google infrastructure verified in code. In our Dec 2026 lab run, Gemini CLI 0.46.0 read a brand-new page through two requests from Google IPs (74.125.208.77 and 74.125.211.1) within 21 seconds, both with the User-Agent GoogleAgent-URLContext and Accept: */* measured in our lab. There’s also a local fallback fetch with its own Google-Gemini-CLI/1.0 User-Agent, but it only runs when the Google-side call errors or returns nothing at all.

Gemini CLI 0.46.0
Fetch toolweb_fetch, takes one prompt containing up to 20 URLs verified in code
Search toolgoogle_web_search, Gemini Flash with Google Search grounding verified in code
Who issues the request Google’s servers (urlContext); the developer’s machine only on fallback
User-AgentGoogleAgent-URLContext from Google IPs measured in our lab. Fallback: Mozilla/5.0 (compatible; Google-Gemini-CLI/1.0; +https://github.com/google-gemini/gemini-cli) verified in code
Accept header*/* on the primary path measured in our lab; none on fallback; text/markdown first in opt-in direct mode verified in code
JS rendering None on the local paths; unknown for Google’s fetcher
Content conversionGoogle-side for urlContext; html-to-text with links and images stripped on fallback verified in code
Size and truncation34 MB per URL on urlContext documented; 10 MB body and 250,000 chars on fallback verified in code
CachingurlContext reads Google’s internal index cache first, then fetches live documented
robots.txtVertex docs say urlContext honours it; the Gemini API docs are silent; the fallback never checks it verified in code
Permission model web_fetch asks for confirmation by policy; google_web_search is allowed as read-only; private and local hosts blocked

web_fetch takes a single prompt parameter and extracts URLs from it by splitting on whitespace and keeping tokens that contain :// and parse as http: or https: (tools/web-fetch.ts) verified in code. From there, the CLI de-duplicates the URLs, drops private and local hosts with a [Blocked Host] note, and applies a rate limit of 10 requests per hostname per 60 seconds. It then builds a wrapper prompt with <user_instructions> and <authorized_urls> sections and calls generateContent on the web-fetch model alias, which resolves to gemini-3-flash-preview with tools:[{urlContext:{}}].

Gemini CLI: web_fetch in our labGemini CLIGemini APIYour site1. parse URLs, block private hosts2. generateContent + urlContext3. index cache miss (new page)4. GET urlUA: GoogleAgent-URLContext, 74.125.208.775. GET url again74.125.211.1, within 21 s6. 200 text/html7. answer + groundingMetadata8. insert [n] markers, Sources list

Gemini CLI: web_fetch in our lab

  1. Gemini CLI
    parse URLs, block private hosts
  2. Gemini CLI→Gemini API
    generateContent + urlContext
  3. Gemini API
    index cache miss (new page)
  4. Gemini API→Your site
    GET url

    UA: GoogleAgent-URLContext, 74.125.208.77

  5. Gemini API→Your site
    GET url again

    74.125.211.1, within 21 s

  6. Your site→Gemini API
    200 text/html
  7. Gemini API→Gemini CLI
    answer + groundingMetadata
  8. Gemini CLI
    insert [n] markers, Sources list
Our Dec 2026 lab run. Google fetched the page twice from two US IPs within 21 seconds; the CLI itself sent nothing to our origin.

Google’s URL context docs describe two-stage retrieval: the tool tries an internal index cache first and fetches live only when the URL is not indexed documented. Our lab page was new, so it took the live path. A page Google has already indexed may produce no request at all when a Gemini CLI user fetches it, and that’s a big difference from agents that always fetch from the developer’s machine inferred. For reference, the documented limits are 34 MB per URL and 20 URLs per request, with support for HTML, JSON, text, CSV, RTF, common image formats and PDF; paywalled content, YouTube, Google Workspace files and localhost are unsupported.

The GoogleAgent-URLContext string was previously reported only by a third-party directory based on robots.txt scans. As far as I know, our lab is the first log evidence tying it to Gemini CLI’s web_fetch, and Netlify classified the request with netlify-agent-category: other instead of as an AI agent measured in our lab. Google’s user-triggered fetchers page documents a Google-Agent fetcher but doesn’t name urlContext.

The CLI falls back to a local fetch in exactly two cases: the generateContent call throws, or the response has empty text and empty groundingChunks verified in code. Here’s the catch: the CLI never reads urlContextMetadata or urlRetrievalStatus, so if Google’s fetcher is blocked by a WAF but the model writes “I could not access the page”, the CLI treats that as success and the local fetch never runs. That means blocking Google’s cloud ranges can turn into a polite non-answer instead of a local retry inferred.

The fallback path sends a single header, User-Agent: Mozilla/5.0 (compatible; Google-Gemini-CLI/1.0; +https://github.com/google-gemini/gemini-cli), with the version hard-coded as 1.0 verified in code. It uses a 10-second timeout, follows redirects, caps the body at 10 MB, and converts HTML with html-to-text using selectors that ignore link targets and skip images. The result is truncated to 250,000 characters (shared across URLs) and summarised by a web-fetch-fallback model call, with no robots.txt check and no JavaScript execution along the way.

One detail from the source deserves a live check, because the description and the code disagree. The Gemini 3 tool description says GitHub blob URLs “are automatically converted to raw versions”, but convertGithubUrlToRaw is called only on the fallback, in the confirmation dialog and in experimental mode, never on the primary urlContext path verified in code. So the user may see a raw URL in the confirmation dialog while Google goes off and fetches the original blob page.

An opt-in experimental.directWebFetch setting (default false) replaces all of this with a local fetch of one {url} that sends Accept: text/markdown, text/plain;q=0.9, application/json;q=0.9, text/html;q=0.8, application/pdf;q=0.7, video/*;q=0.7, */*;q=0.5, returns markdown and text bodies verbatim, and keeps links when converting HTML verified in code. If Google makes this the default, markdown content negotiation starts to matter for Gemini CLI, but today it doesn’t.

Gemini CLI: search and fetch pathsDeveloper machineGoogle cloudGoogle indexYour siteGemini CLIgoogle_web_searchGemini FlashgoogleSearch toolGoogle Searchgrounding chunksGemini CLIweb_fetchurlContextcache, then livedocs.example.comGoogleAgent-URLContextLocal fallbackon error onlydocs.example.comGoogle-Gemini-CLI/1.01 query2 search3 URLs4 GET from Google IP5 if call fails6 GET from dev IP
Gemini CLI: search and fetch pathsDeveloper machineGoogle cloudGoogle indexYour siteGemini CLIgoogle_web_searchGemini FlashgoogleSearch toolGoogle Searchgrounding chunksGemini CLIweb_fetchurlContextcache, then livedocs.example.comGoogleAgent-URLContextLocal fallbackon error onlydocs.example.comGoogle-Gemini-CLI/1.0123456
  1. Gemini CLI → Gemini Flashquery
  2. Gemini Flash → Google Searchsearch
  3. Gemini CLI → urlContextURLs
  4. urlContext → docs.example.comGET from Google IP
  5. Gemini CLI → Local fallbackif call fails
  6. Local fallback → docs.example.comGET from dev IP
Search reads Google's index; web_fetch is served by Google's fetcher (live only on a cache miss); the local fallback runs only when the Google call fails outright.

google_web_search sends one generateContent call with the model alias web-search, which resolves to gemini-3-flash-preview plus tools:[{googleSearch:{}}], and the user message is nothing but the query string the agent wrote (tools/web-search.ts) verified in code. The CLI itself doesn’t rewrite the query, but Google’s grounding docs say the model “automatically generates one or multiple search queries”, so the query that hits Google’s index is the Flash model’s rewrite of the agent’s query documented.

The CLI reads groundingChunks (title and URI) and groundingSupports from the response, inserts [n] markers at each support’s byte offset, and appends a Sources: list verified in code. It ignores webSearchQueries, so the user never sees the exact queries Google ran. The tool description for the Gemini 3 model family is also explicit about chaining search into fetch:

Performs a grounded Google Search to find information across the internet.
Returns a synthesized answer with citations (e.g., [1]) and source URIs. Best
for finding up-to-date documentation, troubleshooting obscure errors, or broad
research. Use this when you don't have a specific URL. If a search result
requires deeper analysis, follow up by using 'web_fetch' on the provided URI.

That text lives in tools/definitions/model-family-sets/gemini-3.ts. Grounding normally returns source URIs as vertexaisearch.cloud.google.com/grounding-api-redirect/... redirectors with the real domain only in the title, which would make a follow-up web_fetch start with a hop through Google inferred; the repo contains no vertexaisearch string, so I’d want a live check before relying on this.

Shell commands run under the CLI’s optional sandbox (docker, podman, sandbox-exec, runsc or lxc), and macOS Seatbelt profiles include permissive-open by default plus closed and proxied variants verified in code. The sandbox constrains shell tools only; the model API calls and web_fetch run in the host CLI process, so the sandbox’s network policy doesn’t affect them unless the whole CLI re-runs inside a container inferred. Proxy settings from HTTPS_PROXY and related variables, or --proxy, apply to the local fallback but not to Google-side urlContext fetches.

The browser agent has its own allowedDomains setting, defaulting to github.com, *.google.com and localhost, which doesn’t apply to web_fetch verified in code. MCP servers are one more path in; see documentation MCP servers.

Full cross-agent strings are on User-Agents and log signatures.

Gemini CLI pathSignature at your originEvidence
google_web_searchNothing; Google’s index is readverified in code
web_fetch, cache hitPossibly nothingdocumented
web_fetch, cache missGoogleAgent-URLContext, Accept: */*, Google IPs such as 74.125.208.77, often two requests seconds apart; Netlify category othermeasured in our lab
web_fetch fallbackMozilla/5.0 (compatible; Google-Gemini-CLI/1.0; +https://github.com/google-gemini/gemini-cli), no Accept, developer’s IPverified in code
directWebFetch (opt-in)Same UA, Accept: text/markdown, ..., developer’s IPverified in code
robots.txtNo robots.txt request observed in our lab, but our robots.txt was served from CDN and not loggedmeasured in our lab (limitation)

For Gemini CLI, Google’s index is the main surface you’re optimising for. Search reads only the index, and web_fetch reads the index cache before it fetches live, so standard Google SEO and crawlability decide most of what a Gemini CLI user sees inferred.

That makes bot protection that challenges Google’s cloud IP ranges a direct risk. Our lab saw the live fetch arrive from 74.125.x.x addresses, and the CLI’s fallback does not trigger when Google’s model writes any text at all, so a WAF block can silently become an answer from the model’s priors. I think allowlisting GoogleAgent-URLContext or the relevant Google ranges is worth testing.

You should also expect duplicate requests: the two fetches within 21 seconds in our lab are probably a retry or a redundant fetch on Google’s side, which matters if you count agent visits or rate-limit by IP.

Markdown negotiation, on the other hand, has no effect today, because the primary path sent Accept: */* and the fallback sends no Accept header. Server-rendered HTML with the key facts in the body text is what reaches the model, and on the fallback path links are stripped, so a fact that exists only as an anchor’s href is lost. You can compare this with other agents on the matrix.

Qwen Code started life as a fork of Gemini CLI, but at commit a6e65b4f (v0.29.2) its web tools have been rewritten and no longer resemble Google’s verified in code. Its web_search calls Alibaba’s DashScope Responses API with web_search and web_extractor tools against a small auxiliary model (default qwen3.8-flash), so pages are opened by DashScope’s servers, whose User-Agent and IPs are undocumented. The tool is on by default only for Qwen OAuth Plus or Pro and some ModelStudio plans, and off for OpenRouter, DeepSeek, ModelScope and local models, which means most third-party setups have no search at all (docs/developers/tools/web-search.md).

Qwen Code’s web_fetch is entirely local and takes a single url (tools/web-fetch.ts) verified in code. It sends User-Agent: QwenCode/<version> (<platform>; <arch>) and, by default, Accept: text/markdown, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1, so it asks for markdown first. It converts HTML with turndown and keeps links, follows redirects only within the same host (cross-host redirects return a “REDIRECT DETECTED” message), upgrades http to https, caps output at 100,000 characters and caches 32 entries for 15 minutes. It doesn’t check robots.txt, and to be clear, we didn’t run Qwen Code in our lab.

Gemini CLI web_fetch Qwen Code web_fetch
Who fetches Google servers (fallback: dev machine) Developer machine
User-Agent GoogleAgent-URLContext (fallback Google-Gemini-CLI/1.0) QwenCode/<ver> (<platform>; <arch>)
Accept */* text/markdown first
Links kept No on fallback Yes (turndown)
Limit 34 MB per URL; 250,000 chars on fallback 10 MB body; 100,000 chars

These map onto the shared test catalog.

  1. Cache versus live. Setup: a unique-token page with header logging. Fetch it with Gemini CLI, wait a week, and fetch it again. Expected signal: GoogleAgent-URLContext hits the first time; fewer or none once Google has indexed the page.
  2. robots.txt compliance. Log robots.txt requests at the origin rather than the CDN, then Disallow the page for Google-Extended, GoogleOther and * in turn. Expected signal: whether urlContext requests robots.txt and stops.
  3. Fallback signature. Break the primary path, for example with a proxy that returns errors for the Gemini API. Expected signal: a Google-Gemini-CLI/1.0 hit from the developer’s IP with no Accept header.
  4. Status-check gap. Return 403 to Google’s IP ranges only. Expected signal: the CLI reports that it could not retrieve the page and no fallback request arrives.
  5. GitHub blob URLs. Ask web_fetch for a github.com/.../blob/... URL. Expected signal: which URL Google’s fetcher requests, the blob page or raw.githubusercontent.com.
  6. Search source URIs. Run google_web_search for a query your site ranks for and inspect the Sources: URIs for vertexaisearch redirectors.
  • Google hasn’t documented GoogleAgent-URLContext or its IP ranges; our lab shows it exists but not which JSON range file covers it.
  • Vertex docs say urlContext honours robots.txt, but the Gemini API docs are silent and our lab could not log robots.txt requests.
  • We don’t know what causes the duplicate fetch from two Google IPs.
  • We don’t know whether directWebFetch will become the default, which would move fetching back to the developer’s machine and make markdown negotiation matter.

Last reviewed 2026-12-02 against Gemini CLI 0.46.0. This site is re-reviewed monthly; see maintenance.