diff --git a/haystack/tools/component_tool.py b/haystack/tools/component_tool.py index cc77ceca0..93e384c37 100644 --- a/haystack/tools/component_tool.py +++ b/haystack/tools/component_tool.py @@ -152,9 +152,7 @@ class ComponentTool(Tool): ] ).lstrip("_") - # Generate a description for the tool if not provided and truncate to 512 characters - # as most LLMs have a limit for the description length - description = (description or component.__doc__ or name)[:512] + description = description or component.__doc__ or name # Create the Tool instance with the component invoker as the function to be called and the schema super().__init__(name, description, tool_schema, component_invoker) diff --git a/releasenotes/notes/fix-tool-description-truncation-011e8275fea4ccb0.yaml b/releasenotes/notes/fix-tool-description-truncation-011e8275fea4ccb0.yaml new file mode 100644 index 000000000..7e09c17c2 --- /dev/null +++ b/releasenotes/notes/fix-tool-description-truncation-011e8275fea4ccb0.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + ComponentTool does not truncate 'description' anymore. diff --git a/test/tools/test_component_tool.py b/test/tools/test_component_tool.py index 38f4e2046..4c0033e04 100644 --- a/test/tools/test_component_tool.py +++ b/test/tools/test_component_tool.py @@ -142,6 +142,12 @@ class TestToolComponent: assert "reply" in result assert result["reply"] == "Hello, world!" + def test_from_component_long_description(self): + component = SimpleComponent() + tool = ComponentTool(component=component, description="".join(["A"] * 1024)) + + assert len(tool.description) == 1024 + def test_from_component_with_dataclass(self): component = UserGreeter()