← All notes

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

Sources

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

Permanent ID: iil:note:3jc71fbx

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.},
}

Markdown

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.

All artifact files (JSON index)

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.