fix: ComponentTool description should not be truncated (#8870)

* fix: description should not be truncated

* chore: add release note
This commit is contained in:
mathislucka 2025-02-18 11:23:26 +01:00 committed by GitHub
parent 0409e5da8f
commit cd7c68372b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -0,0 +1,4 @@
---
fixes:
- |
ComponentTool does not truncate 'description' anymore.

View File

@ -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()