Skip to content

feat: update Agent tutorial to use PipelineTool instead of ComponentTool + SuperComponent#449

Merged
kacperlukawski merged 3 commits into
mainfrom
update-tool-calling-agent
May 12, 2026
Merged

feat: update Agent tutorial to use PipelineTool instead of ComponentTool + SuperComponent#449
kacperlukawski merged 3 commits into
mainfrom
update-tool-calling-agent

Conversation

@sjrl
Copy link
Copy Markdown
Contributor

@sjrl sjrl commented May 12, 2026

update two Agent tutorials to use PipelineTool instead of ComponentTool + SuperComponent

@sjrl sjrl requested a review from a team as a code owner May 12, 2026 09:23
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@sjrl sjrl self-assigned this May 12, 2026
@sjrl sjrl requested a review from kacperlukawski May 12, 2026 09:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

  • Purpose: Update the agent tutorials to expose pipelines as LLM-callable tools via PipelineTool, replacing the older ComponentTool + SuperComponent pattern for pipeline-based tools.
  • Changes:
    • Swap the pipeline-tooling example in 43_Building_a_Tool_Calling_Agent.ipynb to use PipelineTool and update the surrounding explanation.
    • Swap the document-store writer tool in 45_Creating_a_Multi_Agent_System.ipynb to use PipelineTool and update the tutorial guidance accordingly.
    • Minor text/serialization tweaks in notebook cells and captured outputs.

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.

Comment thread tutorials/43_Building_a_Tool_Calling_Agent.ipynb Outdated
@@ -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>
Copy link
Copy Markdown
Member

@kacperlukawski kacperlukawski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied one change, as suggested by Copilot. Other than that, it's looking good!

@kacperlukawski kacperlukawski merged commit 8994294 into main May 12, 2026
6 checks passed
@kacperlukawski kacperlukawski deleted the update-tool-calling-agent branch May 12, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants