用 Ollama 在 Claude Code 中启用子代理与联网搜索

难度:入门 · 来源:Ollama Blog · 采集于:2026-11-04

你将学到什么

  • 用一条命令让 Claude Code 跑在 Ollama 云模型上,无需 MCP 服务器和 API Key。
  • 如何触发子代理(subagent)把检索、代码探索、调研等任务并行拆开,避免主上下文被噪声塞满。
  • 如何让子代理配合内置联网搜索,拿到带时效性的结果并产出可执行结论。

前置条件

  • 本地已装好 Ollama 并在 Claude Code 中完成基础接入(原文指向 “Claude Code with Ollama” 基础设置一文)。
  • 可用的 Ollama 云模型账号;原文强调不需要配置 MCP servers 或 API keys。
  • 不需要额外配置搜索服务,联网搜索已内置在 Anthropic 兼容层中。

步骤

  1. 启动带云模型的 Claude Code。原文给出的入口命令如下,任何 Ollama 云上的模型都可替换进去:
ollama launch claude --model minimax-m2.5:cloud
  1. 让模型自己决定何时开子代理。原文提到部分模型会在需要时自然触发子代理,例如 minimax-m2.5、glm-5、kimi-k2.5;若模型没有主动触发,直接在提示词里要求它 use / spawn / create subagents 即可强制开启。

  2. 按任务类型下派子代理。原文示例提示词可直接改写使用:

spawn subagents to explore the auth flow, payment integration, and notification system
audit security issues, find performance bottlenecks, and check accessibility in parallel with subagents
create subagents to map the database queries, trace the API routes, and catalog error handling patterns
  1. 依赖内置联网搜索取实时信息。当模型需要最新资料时,由 Ollama 执行搜索并直接返回结果,不需要任何额外配置;子代理可以并行检索,再汇总成可执行结果:
research the postgres 18 release notes, audit our queries for deprecated patterns, and create migration tasks
create 3 research agents to research how our top 3 competitors price their API tiers, compare against our current pricing, and draft recommendations
  1. 选模型。原文推荐的云模型为 minimax-m2.5:cloud、glm-5:cloud、kimi-k2.5:cloud;需要接入更多集成可查 ollama launch,单独使用搜索能力可查 Web search API。

常见坑/注意事项

  • 并非所有模型都会自动开子代理:只有 minimax-m2.5、glm-5、kimi-k2.5 被原文点名为“自然触发”,其他模型需要显式提示 spawn/create subagents。
  • 子代理的价值在于各自独立上下文,适合把侧任务与主线编码分离;原文的说法是让长时段编码会话保持产出、侧任务不污染上下文。
  • 原文明确不需要 MCP 服务器与 API Key,遇到要求配密钥的旧教程不要照搬。

原文链接:https://ollama.com/blog/web-search-subagents-claude-code


原文:Subagents and web search in Claude Code February 16, 2026 Ollama now supports subagents and web search in Claude Code.(本文为采集智能体整理的导读,版权归原作者,请阅读原文获取完整内容)

← 用 Python zip() 做并行迭代:用法、不等长处理与 strict 校验用 Ollama 跑 Claude Code:Anthropic API 兼容上手 →
AI技术网博主

独立开发者,记录 AI、开发与效率工具。

查看主页

评论(1)

aijishu554432026-11-05 13:27
子代理适合拆独立任务,但不要让它们互相依赖 —— 并发执行时依赖关系很容易乱。让每个子代理只负责一个可独立验证的产出,主代理负责汇总和冲突处理。
登录后即可参与回复。立即登录 或 注册账号