零成本 AI 子代理,百万 token 长上下文
简介
将 Google Gemini 订阅转化为零成本 AI 子代理,替代 Claude API 完成文本分析、长上下文处理和中低复杂度编码任务,支持 100 万 token 上下文窗口与自主 agentic 编程。
原始描述
Use Google Gemini as a free sub-agent via a Google One / Gemini Advanced subscription (no API key or API credits needed). Use when: (1) delegating tasks that...
通过你的 Agent 添加
安装目录:gemini-sub-agent/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
gemini-sub-agent 是一种成本优化型技能,允许用户通过 Google One / Gemini Advanced 订阅(无需 API key 或积分)在 OpenClaw 工作流中调用 Gemini 作为子代理。
三大核心场景:
- 成本替代:用 Gemini 免费层替代 Claude Sonnet/Haiku 的付费 API 调用
- 长上下文处理:利用 100 万 token 窗口分析大型文档、代码库或报告
- 自主编码:通过
-yyolo 模式让 Gemini 自动读写文件、执行命令,处理 30-200 行的中等复杂度任务
技术实现:基于官方 gemini-cli 工具,通过 gcloud OAuth 完成认证(支持无浏览器 VPS 流程),缓存凭证自动刷新。封装 ask-gemini 命令行工具,支持管道输入(cat file | ask-gemini)和交互式提示。
显著优点
- 零边际成本:订阅用户无 API 用量焦虑,适合高频调用
- 超长上下文:1M token 窗口远超 Claude 200k,适合整本手册、大型代码库分析
- Agentic 能力:支持自主文件操作,可替代 Swift/Sonnet 完成中等复杂度任务
- 模型选择丰富:从 Gemini 2.5 Flash(轻量快速)到 3.1 Pro(旗舰推理)灵活切换
潜在局限与风险
局限
说明
无实时数据
无法访问网络,需配合 Grok 等工具完成搜索任务
复杂度天花板
复杂架构设计、深度调试建议升级至 Codex (Opus)
认证依赖
需维护 Google 订阅有效,OAuth 流程在部分环境较繁琐
上下文隔离
无法访问 OpenClaw 原生工具(web_search、Telegram 等)和主会话上下文
| 局限 | 说明 |
|---|---|
| 无实时数据 | 无法访问网络,需配合 Grok 等工具完成搜索任务 |
| 复杂度天花板 | 复杂架构设计、深度调试建议升级至 Codex (Opus) |
| 认证依赖 | 需维护 Google 订阅有效,OAuth 流程在部分环境较繁琐 |
| 上下文隔离 | 无法访问 OpenClaw 原生工具(web_search、Telegram 等)和主会话上下文 |
失败回退机制:同一任务 Gemini 失败两次 → 自动升级至 Swift (Sonnet) 或 Codex (Opus),并记录失败模式到 failures/hot_antipatterns.md。
适合人群
- 订阅用户:已有 Google One/Gemini Advanced 账户,希望最大化订阅价值
- 高频轻量用户:需要大量文本分析、摘要、中等规模代码生成,但 Claude API 成本敏感
- 长文档处理者:法律、学术、技术文档分析,需要超大上下文窗口
常规风险
- 订阅续费依赖:服务可用性与 Google 订阅状态绑定
- OAuth 安全风险:凭证缓存于本地,共享环境需额外隔离
- 质量漂移:Pro/Flash 模型输出质量差异大,复杂任务需人工校验降级策略
- 订阅续费依赖:服务可用性与 Google 订阅状态绑定
- OAuth 安全风险:凭证缓存于本地,共享环境需额外隔离
- 质量漂移:Pro/Flash 模型输出质量差异大,复杂任务需人工校验降级策略
技能正文
name: gemini-sub-agent
description: >
Use Google Gemini as a free sub-agent via a Google One / Gemini Advanced subscription (no API key or API credits needed).
Use when: (1) delegating tasks that would normally cost Sonnet/Haiku credits, (2) processing large documents or long-context tasks (1M token window),
(3) running agentic coding tasks autonomously, (4) any text analysis, summarization, or Q&A task.
Replaces paid cloud models for medium-complexity tasks.
NOT for: tasks needing OpenClaw-native tools (web_search, sessions_spawn, Telegram), real-time data, or tasks requiring OpenClaw context.
gemini-sub-agent
Use Google Gemini (via subscription, $0 API cost) as a sub-agent inside OpenClaw workflows.
Setup
Run once on a fresh machine:
bash skills/gemini-sub-agent/scripts/setup.sh
Then authenticate (headless VPS flow):
- On VPS:
gcloud auth application-default login --no-browser→ copy the--remote-bootstrapURL - On laptop:
gcloud auth application-default login --remote-bootstrap="<URL>"→ copy thelocalhost:8085output - Paste
localhost:8085output back into VPS prompt - Complete Gemini CLI OAuth:
GOOGLE_GENAI_USE_GCA=true gemini -p "hello"→ paste auth code
Credentials are cached indefinitely and auto-refresh.
Available Models
Model
Use for
gemini-3.1-pro-preview
Default — latest flagship, best reasoning
gemini-2.5-pro
Stable coding tasks, multi-file edits
gemini-3-flash-preview
Fast summaries, quick Q&A
gemini-3-pro-preview
Previous gen Pro, reliable fallback
gemini-2.5-flash
Lightweight fallback
Usage Patterns
1. Simple text task (exec)
ask-gemini "your prompt here"
ask-gemini -m gemini-2.5-pro "your prompt"
2. Pipe large content (long-context)
| Model | Use for |
|---|---|
gemini-3.1-pro-preview |
Default — latest flagship, best reasoning |
gemini-2.5-pro |
Stable coding tasks, multi-file edits |
gemini-3-flash-preview |
Fast summaries, quick Q&A |
gemini-3-pro-preview |
Previous gen Pro, reliable fallback |
gemini-2.5-flash |
Lightweight fallback |
1. Simple text task (exec)
ask-gemini "your prompt here"
ask-gemini -m gemini-2.5-pro "your prompt"
cat large_file.txt | ask-gemini "summarize this in 5 bullets"
cat report.md | ask-gemini "extract all action items"
3. Agentic coding (replaces Swift/Sonnet for 30-200 line tasks)
cd /path/to/project
GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "write a script that..."
cd /path/to/project
GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "write a script that..."
-y = yolo mode (auto-approves all file writes and shell commands). Gemini reads/writes files autonomously.
4. Pipe files directly into agentic session
cat existing_script.py | GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "refactor this to add error handling"
Routing Rules (when to use Gemini vs others)
Task
Use
Text, analysis, summarization
ask-gemini
Medium coding (30–200 lines)
Gemini agentic (-y) instead of Swift/Sonnet
Large file / long-context
ask-gemini (1M token window)
Web search / research
Research agent (Grok) — Gemini has no web access
Multi-agent orchestration
OpenClaw native (sessions_spawn)
Complex architecture / debugging
Codex (Opus) — escalate if Gemini fails twice
Escalation
cat existing_script.py | GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "refactor this to add error handling"
| Task | Use |
|---|---|
| Text, analysis, summarization | ask-gemini |
| Medium coding (30–200 lines) | Gemini agentic (-y) instead of Swift/Sonnet |
| Large file / long-context | ask-gemini (1M token window) |
| Web search / research | Research agent (Grok) — Gemini has no web access |
| Multi-agent orchestration | OpenClaw native (sessions_spawn) |
| Complex architecture / debugging | Codex (Opus) — escalate if Gemini fails twice |
Escalation
If Gemini returns wrong output twice on the same task → escalate to Swift (Sonnet) or Codex (Opus).
Log the failure in failures/hot_antipatterns.md with the task type.
Scripts
scripts/setup.sh — Full install: gemini-cli + gcloud + ask-gemini wrapper
scripts/ask-gemini — The wrapper script itself (copy to /usr/local/bin/)
scripts/setup.sh — Full install: gemini-cli + gcloud + ask-gemini wrapperscripts/ask-gemini — The wrapper script itself (copy to /usr/local/bin/)正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。