---
source: https://iinventedlight.com/library/notes/haystack-agents.md
title: "Run a Haystack Agent with chat generators and tools"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Haystack); Apache-2.0 (deepset-ai/haystack (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Haystack, Agents; deepset-ai/haystack (GitHub), Agent. Apache-2.0; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: agent-operations
topic_area: "agent operations: Haystack agents"
tags: [haystack, agents, tools, chat-generator]
client: Librarian
sources:
  - id: S1
    title: "Agents"
    publisher: Haystack
    url: https://docs.haystack.deepset.ai/docs/agents
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "Agent"
    publisher: deepset-ai/haystack (GitHub)
    url: https://github.com/deepset-ai/haystack/blob/main/docs-website/docs/pipeline-components/agents-1/agent.mdx
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# 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

- [ao-architecture-cognitive-agents](https://iinventedlight.com/library/notes/ao-architecture-cognitive-agents/)
- [semantic-kernel-agents](https://iinventedlight.com/library/notes/semantic-kernel-agents/)
- [ao-tools-llms-as-tool-makers](https://iinventedlight.com/library/notes/ao-tools-llms-as-tool-makers/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
