Repository navigation
Conversation
…tionsTool Call model_rebuild() after a guarded import so Pydantic can resolve the annotation. Fixes RobotecAI#870.
Regression test for RobotecAI#870.
Author
|
Verified on ROS 2 Humble with With Note the test is skipped when |
This branch has not been deployed
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.
Purpose
Fix
PydanticUserError: GetObjectPositionsTool is not fully definedraised when constructingGetObjectPositionsToolor generating its schema (for example when binding the tool to an LLM).Proposed Changes
GetObjectPositionsTooldeclaresget_grabbing_point_tool: "GetGrabbingPointTool", butGetGrabbingPointToolis only imported underTYPE_CHECKING(moved there to avoid a circular import). Pydantic can never resolve that forward reference at runtime, and nothing callsmodel_rebuild().This adds a guarded import of
GetGrabbingPointToolat the end ofrai/tools/ros2/manipulation/custom.py, followed byGetObjectPositionsTool.model_rebuild(). Ifrai_perceptionis not installed, the import is skipped and behavior is unchanged.The existing tests build this tool with
model_construct(), which skips the "fully defined" check, so they could not catch the problem. A regression test now assertsGetObjectPositionsTool.__pydantic_complete__is true.Issues
Fixes #870
Testing
test_get_object_positions_tool_model_is_fully_definedintests/tools/ros2/test_manipulation_custom.py. It is skipped whenrai_perceptionis not installed.