@deepseek-ai/dsh-lazy-tools
CodeBuddy-style deferred tool loading for DeepSeek Harness: keep tool schemas out of the model context until the model loads them on demand via tool_search / defer_execute_tool.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:studyzy/dsh-lazy-tools说明文档
阅读完整 README ↗dsh-lazy-tools
为 DeepSeek Harness 提供的 CodeBuddy 风格延迟工具加载插件。
一个 tool_search + defer_execute_tool 覆盖层,让工具 schema 在真正需要之前
不会进入模型上下文。
减少 token 消耗 · 缩小上下文窗口 · 保持工具可发现
它是做什么的
大多数编码 Agent 会把每一个可用工具的 JSON Schema 都塞进提示词——
包括模型最终根本不会用到的工具。dsh-lazy-tools 颠覆了这个模型:工具
默认被延迟(deferred),只有当模型主动请求时才进入上下文。
被延迟的工具会从模型可见的工具集中剔除,因此它们的 schema(乃至名字)
永远不会进入模型上下文。模型通过 tool_search 按需发现它们,激活后
即可直接调用。
这是一个纯粹的暴露控制层:
- 它不拥有、也不实现任何工具。
- 被延迟的工具是全局注册表里的工具(包括 MCP 等第三方工具);本插件只持有
它们的
name/description/parameters用于发现。 - 它不代理执行——
tool_search/defer_execute_tool只负责激活,激活后 模型直接调用该工具本身。
因为完全实现在 agent 层,它适用于任何模型与任何提供商(DeepSeek、
OpenAI、Anthropic、Gemini……),不依赖提供商原生的延迟工具协议(如
Anthropic tool_reference 或 OpenAI 的 deferred-tool input items)。
特性
- 🔍 按需发现 —
tool_search通过精确工具名(tool_names)或关键词 (queries,中英文均可)查找工具,命中即激活。 - ⚡ 懒激活 — 命中的工具加入该 agent 的可见集合,下一轮模型请求即可 直接调用。
- ⚡ 按名激活 —
defer_execute_tool按精确工具名直接激活一个已知工具。 - 🧭 无侵入 — 在
agent.ctx上通过ctx.tools.restrict()过滤可见工具, 与父/子代理的既有限制天然取交集,绝不放宽其他策略。 - 🎛️ 灵活配置 — CodeBuddy 风格
Defer(...)/NoDefer(...)模式,支持*通配符与全局deferToolLoading开关。 - 🛡️ 自保守卫 —
tool_search与defer_execute_tool注册在 agent 自身作用域, 永不被延迟,Defer(*)无法把系统锁死。
安装
从 GitHub 仓库安装为外部 bundle:
dsh plugin --profile
add git:github.com/studyzy/dsh-lazy-tools
也可以先
git clone到本地,再从本地目录安装。该 bundle 通过cordis.patch.yml注入一个名为lazy-tools的插件。
配置
配置写在 profile 的 中该插件的 字段下,使用 CodeBuddy 风格语法: