docs(sdk): custom-tools 'register_tool' example passes a factory function, which raises TypeError

オープン 初心者向け
#1,068 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
documentation, python
領域
documentation

調査の方向性

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 full BashAndGrepToolSet example.
  • Likely also sdk/guides/agent-server/custom-tools.mdx and sdk/arch/tool-system.mdx.
Suggested fix
  • Register each ToolDefinition subclass/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/ToolSet rather 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時間
マージ済み PR(30日)
80

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenHands/docs のほかの issue

OpenHands/docs の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。