{"record":{"id":"2c3ec678597a68ce","repo":"deepset-ai/haystack","slug":"type-self-chat-generator-name-does-not-acce","errorCode":null,"errorMessage":"{type(self.chat_generator).__name__} does not accept tools parameter in its run method. The Agent component requires a chat generator that supports tools when tools are provided.","messagePattern":"(.+?) does not accept tools parameter in its run method\\. The Agent component requires a chat generator that supports tools when tools are provided\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"haystack/components/agents/agent.py","lineNumber":756,"sourceCode":"            messages = messages + user_messages\n\n        if self._system_chat_prompt_builder is not None:\n            system_messages = _render_prompt_messages(\n                prompt_builder=self._system_chat_prompt_builder,\n                expected_role=ChatRole.SYSTEM,\n                prompt_label=\"system_prompt\",\n                kwargs=kwargs,\n            )\n            messages = system_messages + messages\n\n        if all(m.is_from(ChatRole.SYSTEM) for m in messages):\n            logger.warning(\"All messages provided to the Agent component are system messages. This is not recommended.\")\n\n        selected_tools = self._select_tools(tools=tools)\n        flat_tools = flatten_tools_or_toolsets(tools=selected_tools)\n        # Validate tool support once for the run (covers both init-time and runtime tools)\n        if flat_tools and not self._chat_generator_supports_tools:\n            raise TypeError(\n                f\"{type(self.chat_generator).__name__} does not accept tools parameter in its run method. \"\n                \"The Agent component requires a chat generator that supports tools when tools are provided.\"\n            )\n\n        state_kwargs: dict[str, Any] = {key: kwargs[key] for key in self.resolved_state_schema.keys() if key in kwargs}\n        state = State(schema=self.resolved_state_schema, data=state_kwargs)\n        state.set(\"messages\", messages)\n        state.set(\"step_count\", 0)\n        state.set(\"token_usage\", {})\n        state.set(\"context_tokens\", 0)\n        state.set(\"tool_call_counts\", {tool.name: 0 for tool in flat_tools})\n        state.set(\"exit_reason\", None)\n        state.set(\"continue_run\", False)\n        state.set(\"tools\", flat_tools)\n        state.set(\"hook_context\", hook_context or {})\n\n        streaming_callback = select_streaming_callback(  # type: ignore[call-overload]\n            init_callback=self.streaming_callback, runtime_callback=streaming_callback, requires_async=requires_async","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/agents/agent.py#L738-L774","documentation":"While building telemetry for a running pipeline, haystack/_telemetry.py calls each component's _get_telemetry_data() and requires it to return a dict. This TypeError is raised when a component's _get_telemetry_data returns another type (list, string, None, custom object), since the data is spread into a per-component dict entry. It indicates a custom/broken component implementation, not bad user input.","triggerScenarios":"pipeline.run() / run_async_generator() walking a pipeline containing a component whose _get_telemetry_data is overridden to return a non-dict (or a Mock in tests); triggered inside pipeline_running() during telemetry emission when telemetry is enabled.","commonSituations":"Custom components overriding _get_telemetry_data incorrectly; test doubles/Mocks replacing components without dict-returning stubs (hence test names like test_pipeline_running_with_non_serializable_component); version mismatch where a component's telemetry hook signature changed.","solutions":["Fix the component class named in the error so its _get_telemetry_data returns a dict[str, Any].","If it's a Mock/test double, set it with _get_telemetry_data returning {} (e.g. Mock(_get_telemetry_data=lambda: {})).","As a workaround, disable telemetry (HAYSTACK_TELEMETRY_ENABLED=False) or remove/replace the offending component from the pipeline."],"exampleFix":"// before\nclass MyComponent:\n    def _get_telemetry_data(self):\n        return [self.init_parameters]\n// after\nclass MyComponent:\n    def _get_telemetry_data(self):\n        return {\"init_parameters\": self.init_parameters}","handlingStrategy":"type-guard","validationCode":"def telemetry_data_is_dict(component) -> bool:\n    getter = getattr(component, \"_get_telemetry_data\", None)\n    if getter is None:\n        return True  # component is skipped by telemetry\n    result = getter()\n    return isinstance(result, dict)","typeGuard":"def is_valid_telemetry_data(data) -> bool:\n    return isinstance(data, dict)","tryCatchPattern":"try:\n    result = pipeline.run(...)\nexcept TypeError as e:\n    if \"must be a dictionary\" in str(e):\n        logger.error(\"Component _get_telemetry_data must return a dict: %s\", e)\n        raise\n    raise","preventionTips":["Always return a dict from custom components' _get_telemetry_data overrides","In tests, configure Mocks with _get_telemetry_data returning {} (e.g. Mock(_get_telemetry_data=Mock(return_value={})))","Add a unit test asserting each component's telemetry payload is a dict","Keep haystack and component libraries on compatible versions so telemetry hook contracts match"],"tags":["telemetry","pipeline","type-error","component"],"backgroundTag":"invalid-telemetry-data-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}