Run a Haystack Agent with chat generators and tools
Answer: A Haystack AI agent uses an LLM as its core, plus tools, memory, and planning, to retrieve information and take actions. You pass messages into Agent. It can execute tools, and exit_conditions can stop execution.
What an agent is
An AI agent in Haystack can retrieve information, generate responses, and take actions using Haystack components. It can understand user input, retrieve relevant information, generate responses using LLMs such as OpenAI or Hugging Face models, and perform actions such as calling APIs. Agents rely on large language models when they make decisions and solve tasks. They use tools, memory, and reasoning to interact with their environment. The LLM is the brain: it understands context and processes natural language. Tools connect the agent to external APIs and databases. Memory keeps conversation context.
The Agent component
The Agent component calls chat-based LLMs and tools in a loop until it can solve a query. It runs iteratively. It can execute external tools, keep state across LLM calls, and stop when configurable exit_conditions say so. Its most common position in a pipeline is after a ChatPromptBuilder or user input. Mandatory init variables include chat_generator, an instance of a Chat Generator that supports tools. Mandatory run variables include messages, a list of ChatMessage values. Outputs include messages, last_message, and metadata such as step_count, token_usage, tool_call_counts, and exit_reason.
| Agent | tools | |---|---| | LLM | core of the agent, processes language | | chat_generator | mandatory init that must support tools | | messages | ChatMessage list passed to run | | exit_conditions | when the iterative tool loop stops |
See also
Claims
- id: C1 claim: A Haystack agent uses tools, memory, and reasoning around an LLM that acts as its core. source: S1 evidence: "They interact with their environment using tools, memory, and reasoning"
- id: C2 claim: The Agent component iterates with chat-based LLMs and tools and can stop on exit_conditions. source: S2 evidence: "tool-using agent that interacts with chat-based LLMs and tools"
- id: C3 claim: Agent requires a tools-capable chat_generator and a messages list at run time. source: S2 evidence: "chat_generator`: An instance of a Chat Generator that supports tools"
Sources
- [S1] Agents. Haystack. https://docs.haystack.deepset.ai/docs/agents . License: Apache-2.0. Accessed 2026-11-19.
- [S2] Agent. deepset-ai/haystack (GitHub). https://github.com/deepset-ai/haystack/blob/main/docs-website/docs/pipeline-components/agents-1/agent.mdx . License: Apache-2.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Haystack, Agents; deepset-ai/haystack (GitHub), Agent. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Haystack, Agents; deepset-ai/haystack (GitHub), Agent. Apache-2.0; Apache-2.0.
Cite this
iinventedlight. 2026. "Run a Haystack Agent with chat generators and tools." iinventedlight Library, iil:note:3jc71fbx, version of 2026-11-19. https://iinventedlight.com/library/notes/haystack-agents/. License: CC-BY-4.0.
@misc{iil_note_3jc71fbx,
author = {{iinventedlight}},
title = {{Run a Haystack Agent with chat generators and tools}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/haystack-agents/},
note = {Permanent ID iil:note:3jc71fbx. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- haystack-agents.table.json (table; CC-BY-4.0)
- haystack-agents.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/haystack-agents.md.