TOOL WIKI · AGENT SDKS

Haystack

Builds component-based pipelines for retrieval, generation, and agent applications.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Retrieve the correct store’s return policy

A developer needs a small, observable agent or retrieval step before connecting real business services.

Input
Three policy/shipping documents, query returns and a tenant filter.
Expected output
The 30-day tenant-a document rather than tenant-b’s 90-day policy.
  • Success check: The first document describes the 30-day policy and belongs to tenant a.
  • Try a failure: Remove the tenant filter and see why relevance is not an access-control rule.

Example scope: Runnable BM25 retriever baseline; no generation model or agent loop.

Official reference · Haystack

WHAT IT ISPipeline framework
WHERE IT FITSAgent SDKs
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
taskinvokedecisiontool callresultstatemeasureApplicationTask + identityHaystackPipeline frameworkModel providerConfigured API modelTool serviceAuthorization + executionState storageRun and thread progressEvaluationOutcome + evidence
  1. Authenticate the request and define the goal before calling the framework.

  2. A system that benefits from explicit data-processing components. Measure each pipeline stage using representative source documents.

  3. The application supplies provider credentials, model selection, and budgets.

  4. Validate each operation and return authoritative observations.

  5. Choose the checkpoint or session store and its retention policy deliberately.

    Result or stopping point
  6. Check completion, cost, latency, and tool behavior against fixtures.

    Result or stopping point
Haystack

A system that benefits from explicit data-processing components. Measure each pipeline stage using representative source documents.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • A system that benefits from explicit data-processing components.

A design decision to make

  • Measure each pipeline stage using representative source documents.

Prerequisites and setup

  • Python 3.11+. This retrieval component example does not need a model or API key.
Shell
python3 -m venv .venv
source .venv/bin/activate
pip install haystack-ai

Try a small integration

example.py

Python · example.py
from haystack import Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever

store = InMemoryDocumentStore()
store.write_documents([
    Document(content="Returns are accepted within 30 days.", meta={"tenant":"a"}),
    Document(content="Shipping normally takes 5 days.", meta={"tenant":"a"}),
    Document(content="Returns are accepted within 90 days.", meta={"tenant":"b"}),
])
retriever = InMemoryBM25Retriever(document_store=store)
result = retriever.run(query="returns", top_k=1,
    filters={"field":"meta.tenant", "operator":"==", "value":"a"})
print(result["documents"][0].content)
assert result["documents"][0].meta["tenant"] == "a"

Run and check the result

Shell
python example.py
  • The first document describes the 30-day policy and belongs to tenant a.
  • A BM25 retriever ranks text; attach a generator and evaluate grounded answers as a separate pipeline step.

Common failures

  • Do not install the unrelated legacy haystack package in place of haystack-ai.
  • A missing filter can retrieve another tenant. Enforce scope in application code, not in the question.

Production decisions

  • Bind tool execution to the authenticated user and resource permissions. Keep keys in server environment variables.
  • Add deadlines, a turn budget, redacted traces, regression fixtures and explicit handling for refused or incomplete runs.

Keep exploring

Workflow, single agent, or multiple agents?Build an explicit agent loop with LangGraph

Explore the same layer

OpenAI Agents SDKClaude Agent SDKGoogle ADKLangGraph

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.