Haystack Agents
~2 min read
Concept & How It Works
Why Does It Exist?
Teams already running Haystack for RAG can add agentic behavior — tool use, routing, multi-hop retrieval — without migrating to a new framework.
Real-World Analogy
Haystack Agents turn a library search desk into a research librarian who not only finds books but also calls external databases and synthesizes answers.
Visual Workflows
What is Haystack Agents?
Example
Scenario
Enterprise search agent: user query → agent decides between Confluence retriever, Jira tool, or Slack search → synthesizes unified answer.
Solution
In Agent Frameworks, apply Haystack Agents to this scenario: Enterprise search agent: user query → agent decides between Confluence retriever, Jira tool, or Slack search → synthesizes unified answer. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Do this before moving to the next module — reading alone is not enough.
Open the Code Walkthrough below and run it locally. Change one parameter related to Haystack Agents (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Haystack Agents happens in the code.
1from haystack.components.agents import Agent # import dependencies2from haystack.tools import Tool # import dependencies3
4search_tool = Tool(name="search_docs", description="Search internal wiki",5 function=wiki_search, parameters={"query": {"type": "string"}})6agent = Agent(chat_generator=generator, tools=[search_tool])7result = agent.run(messages=[{"role": "user", "content": "PTO policy 2026"}])Commands to Remember
Commands to Remember
pip install langgraph langchain-openai # LangGraph agent frameworkpip install openai-agents # OpenAI Agents SDKpip install crewai # multi-agent CrewAI framework
Common Mistakes
- Treating Haystack Agents as a black box without evaluation
- Ignoring cost and latency in production
- Skipping error handling for haystack agents
Cheat Sheet
Quick recap — the most important points from this module.
Cheat Sheet
quick ref- •Haystack Agents
- •Pipeline
- •Toolset
- •ChatGenerator