haystack icon indicating copy to clipboard operation
haystack copied to clipboard

ComponentTool should validate `inputs_from_state`, `outputs_to_state`

Open julian-risch opened this issue 7 months ago • 1 comments

Currently users who are new to ComponentTool and State, might pass wrong values to inputs_from_state and they do not receive an error or a warning. We should raise an error if wrong values are passed to inputs_from_state, for example {"documents": {"source": "documents"}} and show the expected format to the user, for example {"documents": "documents"}. Similarly, we should validate outputs_to_state input values.

@bilgeyucel @sjrl and I came across this issue when debugging a notebook.

summarization_tool = ComponentTool(
    component=summarization_super_component,
    name="summarization_super_component",
    description="Writes a concise 200-word summary about the topic.",
    inputs_from_state={"documents": "documents"}  # correct
    # inputs_from_state={"documents": {"source": "documents"}}  # incorrect
)
search_tool = ComponentTool(
    component=websearch,
    name="web_search",
    description="Search the web for current information on any topic",
    outputs_to_state={"documents": {"source": "documents"}}
)

julian-risch avatar May 22 '25 08:05 julian-risch

or support both, meaning we also support outputs_to_state={"documents": "documents"} and also accept inputs_from_state={"documents": {"source": "documents"}}

julian-risch avatar May 23 '25 07:05 julian-risch