docs(sdk): custom-tools 'register_tool' example passes a factory function, which raises TypeError
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 62/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- documentation, python
调研方向
从 sdk/guides/custom-tools.mdx 开始,查看“Tool Registration”和“Factory Functions”小节以及 BashAndGrepToolSet 示例。然后检查 openhands-sdk/openhands/sdk/tool/registry.py,确认 register_tool 只接受 ToolDefinition 实例或其子类。同时审查 sdk/guides/agent-server/custom-tools.mdx 和 sdk/arch/tool-system.mdx 中是否存在相同模式。完成的标准是:每个示例都以受支持的形式注册工具,并且文档中不再将工厂函数传递给 register_tool。
由索引模型根据 Issue 内容生成。
描述
Problem
sdk/guides/custom-tools.mdx documents registering a factory function with register_tool():
# Register a factory function that creates multiple tools
register_tool("BashAndGrepToolSet", _make_bash_and_grep_tools)
But the current SDK signature only accepts a ToolDefinition instance or a ToolDefinition subclass:
# openhands-sdk/openhands/sdk/tool/registry.py
def register_tool(
name: str,
factory: ToolDefinition | type[ToolDefinition],
) -> None:
...
else:
raise TypeError(
"register_tool(...) only accepts: (1) a ToolDefinition instance with "
".executor, or (2) a ToolDefinition subclass with .create(**params)"
)
So the documented pattern raises at runtime:
TypeError: register_tool(...) only accepts: (1) a ToolDefinition instance with .executor,
or (2) a ToolDefinition subclass with .create(**params)
Where
sdk/guides/custom-tools.mdx— "Good to know → Tool Registration" and "Factory Functions" sections,
plus the fullBashAndGrepToolSetexample.- Likely also
sdk/guides/agent-server/custom-tools.mdxandsdk/arch/tool-system.mdx.
Suggested fix
- Register each
ToolDefinitionsubclass/instance individually (or loop over a list) instead of passing a
factory function. - If the "tool set" pattern is still desired, show it via
TaskToolSet/ToolSetrather than a raw factory.
Reported by
A user (Epsilon Software Inc) hit this following the docs; confirmed against openhands-sdk source.
This issue was created by an AI agent (OpenHands) on behalf of the maintainer.
- 主要语言
- MDX
- 星标
- 19
- 派生
- 104
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 80
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenHands/docs 的其他 Issue
-
docs: document FORGEJO_BASE_URL (self-hosted Forgejo host for the backend integration)可能已有人在做 @remote-controlled-man 于 18 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
Docs: Child Conversations incorrectly implies the child's result is returned to the parent可能已有人在做 @sahithib20 于 36 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
agent-in-progress
难度 3/5 1-2 天 新手友好度 65/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 90/100
ethereum/execution-apis#1017 ·
维护者通常 3 天内回复
-
[Docs] CONTRIBUTING points the Backend Remake milestone at a branch that does not exist可能已有人在做 @franpts2 今天认领。 未关闭docs
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 3 天内回复
-
postgresql-rules / queue-rules: implicit KEY SHARE before a parent key update, and job self-overlap未关闭
难度 2/5 1-3 小时 新手友好度 82/100
jonathanong/no-mistakes#3879 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pearu/agent-sandbox#451 ·
维护者通常 1 天内回复