Prompt Research

Gemini LangGraph Quickstart: Web Search Query Writer (Rationale Plus Queries, JSON)

Writes web search queries for a research question: one query by default, more only when the question has several aspects, capped at a set number, returned as JSON with a rationale and a query list.

  • 🤖 Gemini (works with any chat LLM)
  • 🗂️ Research

Last verified: write-up checked

Prompt by Google (google-gemini/gemini-fullstack-langgraph-quickstart) · Original source (opens in a new tab)

Gemini LangGraph Quickstart: Web Search Query Writer (Rationale Plus Queries, JSON) — prompt preview

The prompt

prompt
Your goal is to generate sophisticated and diverse web search queries. These queries are intended for an advanced automated web research tool capable of analyzing complex results, following links, and synthesizing information.

Instructions:
- Always prefer a single search query, only add another query if the original question requests multiple aspects or elements and one query is not enough.
- Each query should focus on one specific aspect of the original question.
- Don't produce more than {number_queries} queries.
- Queries should be diverse, if the topic is broad, generate more than 1 query.
- Don't generate multiple similar queries, 1 is enough.
- Query should ensure that the most current information is gathered. The current date is {current_date}.

Format:
- Format your response as a JSON object with ALL two of these exact keys:
   - "rationale": Brief explanation of why these queries are relevant
   - "query": A list of search queries

Example:

Topic: What revenue grew more last year apple stock or the number of people buying an iphone
```json
{
    "rationale": "To answer this comparative growth question accurately, we need specific data points on Apple's stock performance and iPhone sales metrics. These queries target the precise financial information needed: company revenue trends, product-specific unit sales figures, and stock price movement over the same fiscal period for direct comparison.",
    "query": ["Apple total revenue growth fiscal year 2024", "iPhone unit sales growth fiscal year 2024", "Apple stock price growth fiscal year 2024"],
}
```

Context: {research_topic}

What it is

Writes web search queries for a research question: one query by default, more only when the question has several aspects, capped at a set number, returned as JSON with a rationale and a query list. The example on this page is copied from the same source file; we did not run it. The prompt text comes from the gemini-fullstack-langgraph-quickstart repository (Apache License 2.0). Licence: https://github.com/google-gemini/gemini-fullstack-langgraph-quickstart/blob/main/LICENSE. Original author: Google (google-gemini/gemini-fullstack-langgraph-quickstart). Changes by FoxaMind: Python triple quotes removed and doubled braces turned back into single braces; {...} placeholders keep the source names.

Who it's for

  • Developers building research agents
  • Researchers who want focused search queries

يكتب استعلامات بحث على الويب لسؤال بحثي: استعلام واحد افتراضياً وأكثر فقط إذا تعددت جوانب السؤال، بحد أقصى معيّن، ويعيدها بصيغة JSON مع تبرير وقائمة استعلامات.

Examples

Example inside the prompt

Prompt
prompt
Topic: What revenue grew more last year apple stock or the number of people buying an iphone
```json
{
    "rationale": "To answer this comparative growth question accurately, we need specific data points on Apple's stock performance and iPhone sales metrics. These queries target the precise financial information needed: company revenue trends, product-specific unit sales figures, and stock price movement over the same fiscal period for direct comparison.",
    "query": ["Apple total revenue growth fiscal year 2024", "iPhone unit sales growth fiscal year 2024", "Apple stock price growth fiscal year 2024"],
}
```

Expected output: The worked example in the source prompt: a topic and the JSON the model should return. Not run by us.

Tips

  • {number_queries}, {current_date} and {research_topic} are filled by the app.
  • The current date is passed in so that queries ask for the most recent information.
  • The example JSON in the source has a trailing comma after the query list; it is kept as in the source.