refactor(tools): derive native tools from functions and bound methods - #198
Open
wilburx813 wants to merge 7 commits into
Open
wilburx813 wants to merge 7 commits into
wilburx813 wants to merge 7 commits into
Conversation
Documentation build overview
9 files changed ·
|
Documentation build overview
11 files changed ·
|
qurakchin
reviewed
Sep 17, 2026
| return handler | ||
|
|
||
|
|
||
| def tool(function: Callable[ParamsT, ToolResult], /) -> Tool[ParamsT]: |
Collaborator
Collaborator
| from rpent.tools.common_tools import COMMON_TOOLS | ||
| from rpent.utils.logging import get_logger | ||
|
|
||
| logger = get_logger("tools") |
Collaborator
There was a problem hiding this comment.
better to use the same name as the filename
| from rpent.session import EnvState | ||
|
|
||
| ParamsT = ParamSpec("ParamsT") | ||
| RobotT = TypeVar("RobotT") |
Collaborator
There was a problem hiding this comment.
better use RuntimeT or RobotRuntimeT
Co-authored-by: ye shengjie <184427520+ye1457@users.noreply.github.com> Co-authored-by: Chao Yu <zoeyuchao@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tool definitions currently duplicate Python signatures in handwritten schemas and adapt results through provider-specific content blocks. This change derives native
Tooldeclarations from typed functions and instance methods, and returnsToolResult(data, images, error)across robots, planners/MCP, and Dashboard.iter_tools/add_tool; usewith_handlerfor resource binding and execution guards.Fieldconstraints, and Google-style docstrings. Support@tool,@tool(), and@tool(readonly=True).MemoryManagerand update the English/Chinese extension guides.Compatibility
Custom integrations must register native declarations with
add_tool/add_tools, discover them throughlist_tools(), and returnToolResultfrom handlers and observation capture. Direct Python callers use.dataor.to_dict()instead of indexing the old result dictionary. Images are an ordered PNG byte list; errors use the expliciterrorfield.Historical schema snapshots cover common tools and all five robots (67 tools), retaining their published input schemas. Runtime validation rejects unknown arguments and non-finite numbers and applies declared constraints. Tool calls remain serialized.
readonlycontrols automatic observation capture, including for file tools.Adds
docstring-parserand removes the directjsonschemadependency.