feat: update Agent tutorial to use PipelineTool instead of ComponentTool + SuperComponent#449
Merged
Merged
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
There was a problem hiding this comment.
Pull request overview
- Purpose: Update the agent tutorials to expose pipelines as LLM-callable tools via
PipelineTool, replacing the olderComponentTool+SuperComponentpattern for pipeline-based tools. - Changes:
- Swap the pipeline-tooling example in
43_Building_a_Tool_Calling_Agent.ipynbto usePipelineTooland update the surrounding explanation. - Swap the document-store writer tool in
45_Creating_a_Multi_Agent_System.ipynbto usePipelineTooland update the tutorial guidance accordingly. - Minor text/serialization tweaks in notebook cells and captured outputs.
- Swap the pipeline-tooling example in
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
tutorials/43_Building_a_Tool_Calling_Agent.ipynb |
Replaces pipeline tool creation with PipelineTool; updates narrative around pipeline-as-tool usage. |
tutorials/45_Creating_a_Multi_Agent_System.ipynb |
Updates the “Document Store Writer Tool” section to wrap the writer pipeline as a PipelineTool. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -320,7 +266,6 @@ | |||
| "query = \"What are the latest updates on the Artemis moon mission?\"\n", | |||
| "messages = [ChatMessage.from_user(query)]\n", | |||
| "\n", | |||
| "\n", | ||
| "> 💡 Learn alternative ways of creating tools in [`Tool`](https://docs.haystack.deepset.ai/docs/tool) and [`MCPTool`](https://docs.haystack.deepset.ai/docs/mcptool) documentation pages." | ||
| ] | ||
| "source": "### Creating a Tool from a Pipeline\n\nNext, wrap the `search_pipeline` in a [`PipelineTool`](https://docs.haystack.deepset.ai/docs/pipelinetool). `PipelineTool` directly exposes a pipeline as an LLM-callable tool, replacing the older pattern of wrapping a pipeline in a `SuperComponent` and then passing it to `ComponentTool`.\n\nUse `input_mapping` and `output_mapping` to control which pipeline inputs and outputs are exposed. Here, `input_mapping` ensures only `\"query\"` is surfaced in the tool schema, and `output_mapping` extracts the formatted string produced by `output_adapter`.\n\nFinally, you can initialize the Agent with the resulting `search_tool`.\n\n> 💡 Learn alternative ways of creating tools in [`Tool`](https://docs.haystack.deepset.ai/docs/tool) and [`MCPTool`](https://docs.haystack.deepset.ai/docs/mcptool) documentation pages." |
| ")\n", | ||
| "doc_store_writer.parameters" | ||
| ] | ||
| "source": "from haystack import Pipeline, component, Document\nfrom haystack.components.writers import DocumentWriter\nfrom haystack.document_stores.in_memory import InMemoryDocumentStore\nfrom haystack.tools import PipelineTool\nfrom typing import List\n\n\n@component\nclass DocumentAdapter:\n @component.output_types(documents=List[Document])\n def run(self, content: str, title: str):\n return {\"documents\": [Document(content=content, meta={\"title\": title})]}\n\n\ndocument_store = InMemoryDocumentStore()\n\ndoc_store_writer_pipeline = Pipeline()\ndoc_store_writer_pipeline.add_component(\"adapter\", DocumentAdapter())\ndoc_store_writer_pipeline.add_component(\"writer\", DocumentWriter(document_store=document_store))\ndoc_store_writer_pipeline.connect(\"adapter\", \"writer\")\n\ndoc_store_writer = PipelineTool(\n pipeline=doc_store_writer_pipeline,\n name=\"doc_store_writer\",\n description=\"Use this tool to write/save content to document store\",\n parameters={\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\"type\": \"string\", \"description\": \"The title of the Document\"},\n \"content\": {\"type\": \"string\", \"description\": \"The content of the Document\"},\n },\n \"required\": [\"title\", \"content\"],\n },\n)\ndoc_store_writer.parameters" |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kacperlukawski
approved these changes
May 12, 2026
Member
kacperlukawski
left a comment
There was a problem hiding this comment.
I applied one change, as suggested by Copilot. Other than that, it's looking good!
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.
update two Agent tutorials to use PipelineTool instead of ComponentTool + SuperComponent