Skip to content

Build a RAG agent

Add retrievers so the composed user message is enriched before the model runs.

When to use: you need search, Confluence, Jira, or custom retrieval on every agent run.
When not to: one-off context is enough — use Context or an ad-hoc abt run -s <agent> -p "…" prompt instead.

Agent sketch

A retriever, an agent that uses it, a prompt and a workflow. Running it needs the confluence extra and an atlassian entry under credentials: in profiles.yaml. See confluence_search. Compile needs neither.

# retrievers/docs.yaml
name: docs
type: confluence_search
credentials: atlassian
config: { spaces: "DOCS" }          # comma-separated space keys; config is not var()-rendered
query: "{{ var('question') }}"

Save this as agents/support-bot.md:

---
name: support-bot
description: Answers support questions from the team docs.
retrievers: [docs]
---
Answer the question, using the retrieved Confluence context.

Save this as prompts/rag_question.md:

{{ var('question') }}
# workflows/support_bot.yaml
edges:
  - [START, rag_question]
  - [rag_question, support-bot]
  - [support-bot, END]

The prompt reads {{ var('question') }}, which has no default, so pass the question when you compile:

abt compile --vars '{"question":"How do I reset my password?"}'
  Manifest ready (1 agents).
Compiled 1 agent(s).
...

Without --vars, compile stops with Missing required template variable(s) 'question'.

Flow: sources (optional workflow node) → prompt node → retrievers (parallel, on the agent) → agent → transformers (on the agent) → exposures (optional workflow sink node).

Prompt transforms (rewrite query before retrieve): Prompt transforms.
Post-agent shaping: Transformers.

Web search example (no credentials needed)

uv pip install "abt-core[web-search]"
# retrievers/web_context.yaml
name: web_context
type: web_search
config:
  max_results: 5

Save this as agents/my-agent.md:

---
name: my-agent
description: Answers questions with web search when needed.
retrievers: [web_context]
---
Answer the question, using web search for anything you don't already know.

Save this as prompts/web_rag_question.md:

{{ var('question') }}
# workflows/my_agent_rag.yaml
edges:
  - [START, web_rag_question]
  - [web_rag_question, my-agent]
  - [my-agent, END]

Check that it compiles. Here too the prompt needs question:

abt compile --vars '{"question":"What is LangGraph?"}'
  Manifest ready (1 agents).
Compiled 1 agent(s).
...

Run it. This calls the model and the search backend, so it needs a real model key:

abt dispatch -s my_agent_rag --vars '{"question":"What is LangGraph?"}'

See also: Tutorial 3: Incident Response — a complete example with Jira/Confluence retrievers and prompt transforms.