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.
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
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
Internal Logic
- 1. Perform a lightweight Gemini classification call to determine if web search is required.
- If web search is NOT required → answer directly via Gemini without tools.
- If web search IS required → call Gemini with
google_search tool enabled. - 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.
- Always return valid structured JSON.
The agent must not describe fallback logic to the user.
Input
Call the script with a single JSON argument.
Required
Optional (forwarded to Tavily if fallback occurs)
- - INLINECODE2
- INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
- INLINECODE9
- INLINECODE10
- additional Tavily-compatible parameters
Environment Requirements
Required:
- - INLINECODE11
- INLINECODE12
Optional:
- -
GEMINI_MODEL (default: gemini-2.5-flash-lite)
CODEBLOCK0
Output Schema (Unified)
The tool always returns JSON in this format:
CODEBLOCK1
If both providers fail:
CODEBLOCK2
Post-Processing Requirement
After generating the final answer for the user, append:
Searched with:
Where <provider> matches the returned JSON:
If no web search was used:
Searched with: none
gemini-tavily-search
目的
使用弹性多提供商策略提供可靠、最新的网络信息:
Gemini(主要,可选的 google_search 基础功能)
→ 自动回退 → Tavily
代理始终接收标准化 JSON 输出,永远不会收到原始提供商错误。
激活条件
仅当以下情况时使用此技能:
- - 问题涉及当前或近期信息
- 新闻、事件、实时比分、财经更新
- 时间敏感数据
- 近期可能发生变化的事实
- 需要对照权威来源进行验证
- 模型的训练数据中可能没有最新信息
不应激活的情况
在以下情况下不要使用此技能:
- - 问题是稳定的常识性知识
- 不会改变的历史事实
- 概念性解释
- 代码相关任务
- 本地文件操作
- 上下文中已有可用文档
- 其他更具体的技能更适合
内部逻辑
- 1. 执行轻量级 Gemini 分类调用,判断是否需要网络搜索。
- 如果不需要网络搜索 → 直接通过 Gemini 回答,无需使用工具。
- 如果需要网络搜索 → 调用启用了 google_search 工具的 Gemini。
- 如果 Gemini 因任何原因失败(超时、配额错误、HTTP 错误、无效 JSON、API 错误对象、格式错误的响应):
- 自动执行 Tavily 回退。
- 5. 将提供商输出标准化为统一 JSON 架构。
- 始终返回有效的结构化 JSON。
代理不得向用户描述回退逻辑。
输入
使用单个 JSON 参数调用脚本。
必需参数
可选参数(如果发生回退,则转发给 Tavily)
- - searchdepth
- topic
- maxresults
- timerange
- startdate
- enddate
- includedomains
- exclude_domains
- country
- 其他 Tavily 兼容参数
环境要求
必需:
- - TAVILYAPIKEY
- GEMINIAPIKEY
可选:
- - GEMINI_MODEL(默认值:gemini-2.5-flash-lite)
json
{
env: {
GEMINI_MODEL: gemini-2.5-flash-lite,
GEMINIAPIKEY: your-gemini-key,
TAVILYAPIKEY: your-tavily-key
}
}
输出架构(统一格式)
该工具始终以以下格式返回 JSON:
json
{
provider: gemini | tavily,
answer: 文本或 null,
results: [
{
title: 来源标题,
url: https://example.com,
snippet: 相关摘要
}
],
fallback: true | false
}
如果两个提供商均失败:
json
{
provider: tavily,
answer: null,
results: [],
fallback: true,
error: tavily_failed
}
后处理要求
在生成最终用户回答后,追加:
搜索来源:
其中 与返回的 JSON 匹配:
如果未使用网络搜索:
搜索来源:无