gemini-tavily-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

gemini-tavily-search

gemini-tavily-search

Purpose

用途

Provide reliable, up-to-date web information using a resilient multi-provider strategy:
Gemini (primary, optional google_search grounding)
→ automatic fallback → Tavily
The agent always receives normalized JSON output and never raw provider errors.
采用具备容错能力的多服务商策略,提供可靠、实时的网络信息:
Gemini(主服务商,可选google_search grounding)
→ 自动切换备选 → Tavily
Agent始终会收到标准化的JSON输出,不会收到原始的服务商错误信息。

Activation Criteria

激活条件

Use this skill ONLY when:
  • The question involves current or recent information
  • News, events, live scores, financial updates
  • Time-sensitive data
  • Facts that may have changed recently
  • Verification against authoritative sources is required
  • The model may not have the latest information in its training data
仅在以下情况下使用此Skill:
  • 问题涉及当前或近期信息
  • 新闻、事件、实时比分、金融更新
  • 时效性数据
  • 近期可能发生变化的事实
  • 需要通过权威来源验证的内容
  • 模型训练数据中不包含最新信息的情况

Do NOT Activate When

禁用场景

Do NOT use this skill when:
  • The question is stable general knowledge
  • Historical facts that do not change
  • Conceptual explanations
  • Code-related tasks
  • Local file operations
  • Documentation already available in context
  • Another more specific skill is better suited
在以下情况下请勿使用此Skill:
  • 问题属于稳定的常识性知识
  • 不会发生变化的历史事实
  • 概念性解释
  • 代码相关任务
  • 本地文件操作
  • 上下文已提供相关文档
  • 有更适合的特定Skill可用

Internal Logic (Do Not Expose to User)

内部逻辑(请勿向用户透露)

  1. Perform a lightweight Gemini classification call to determine if web search is required.
  2. If web search is NOT required → answer directly via Gemini without tools.
  3. If web search IS required → call Gemini with
    google_search
    tool enabled.
  4. If Gemini fails for ANY reason (timeout, quota error, HTTP error, invalid JSON, API error object, malformed response):
    • Automatically execute Tavily fallback.
  5. Normalize provider output into unified JSON schema.
  6. Never expose provider errors directly to the agent.
  7. Always return valid structured JSON.
The agent must not describe fallback logic to the user.
  1. 调用Gemini进行轻量级分类判断,确定是否需要进行网络搜索。
  2. 若无需网络搜索→直接通过Gemini回答,不使用工具。
  3. 若需要网络搜索→启用
    google_search
    工具调用Gemini。
  4. 若Gemini因任何原因失败(超时、配额错误、HTTP错误、无效JSON、API错误对象、格式错误的响应):
    • 自动执行Tavily备选方案。
  5. 将服务商输出标准化为统一的JSON格式。
  6. 切勿向Agent直接透露服务商错误信息。
  7. 始终返回有效的结构化JSON。
Agent不得向用户描述备选切换逻辑。

Input

输入

Call the script with a single JSON argument.
使用单个JSON参数调用该脚本。

Required

必填参数

  • query
    (string)
  • query
    (字符串)

Optional (forwarded to Tavily if fallback occurs)

可选参数(若触发备选则传递给Tavily)

  • search_depth
  • topic
  • max_results
  • time_range
  • start_date
  • end_date
  • include_domains
  • exclude_domains
  • country
  • additional Tavily-compatible parameters
  • search_depth
  • topic
  • max_results
  • time_range
  • start_date
  • end_date
  • include_domains
  • exclude_domains
  • country
  • 其他兼容Tavily的参数

Environment Requirements

环境要求

Required:
  • TAVILY_API_KEY
    (OAuth via MCP supported if not set)
  • GEMINI_API_KEY
Optional:
  • GEMINI_MODEL
    (default: gemini-2.5-flash-lite)
json
{
  "env": {
    "GEMINI_MODEL": "gemini-2.5-flash-lite",
    "GEMINI_API_KEY": "your-gemini-key",
    "TAVILY_API_KEY": "your-tavily-key"
  }
}
必填:
  • TAVILY_API_KEY
    (若未设置,支持通过MCP进行OAuth验证)
  • GEMINI_API_KEY
可选:
  • GEMINI_MODEL
    (默认值:gemini-2.5-flash-lite)
json
{
  "env": {
    "GEMINI_MODEL": "gemini-2.5-flash-lite",
    "GEMINI_API_KEY": "your-gemini-key",
    "TAVILY_API_KEY": "your-tavily-key"
  }
}

Output Schema (Unified)

输出格式(统一)

The tool always returns JSON in this format:
json
{
  "provider": "gemini | tavily",
  "answer": "text or null",
  "results": [
    {
      "title": "Source title",
      "url": "https://example.com",
      "snippet": "Relevant excerpt"
    }
  ],
  "fallback": true | false
}
If both providers fail:
json
{
  "provider": "tavily",
  "answer": null,
  "results": [],
  "fallback": true,
  "error": "tavily_failed"
}
该工具始终返回以下格式的JSON:
json
{
  "provider": "gemini | tavily",
  "answer": "text or null",
  "results": [
    {
      "title": "Source title",
      "url": "https://example.com",
      "snippet": "Relevant excerpt"
    }
  ],
  "fallback": true | false
}
若两个服务商均失败:
json
{
  "provider": "tavily",
  "answer": null,
  "results": [],
  "fallback": true,
  "error": "tavily_failed"
}

Post-Processing Requirement

后处理要求

After generating the final answer for the user, append:
Searched with: <provider>
Where
<provider>
matches the returned JSON:
  • "gemini"
  • "tavily"
If no web search was used:
Searched with: none
在为用户生成最终答案后,追加:
搜索来源: <provider>
其中
<provider>
与返回的JSON一致:
  • "gemini"
  • "tavily"
若未使用网络搜索:
搜索来源: none