Introduction
Arcana’s Agent module provides a composable, pipeline-based approach to agentic RAG (Retrieval-Augmented Generation). Build sophisticated question-answering systems by chaining modular steps together.Basic Pipeline
Architecture
Context Flow
TheArcana.Agent.Context struct flows through the pipeline, accumulating results at each step:
Pipeline Steps
Each step transforms the context and passes it forward:- gate/2 - Decide if retrieval is needed
- rewrite/2 - Clean conversational input
- select/2 - Choose which collections to search
- expand/2 - Add synonyms and related terms
- decompose/2 - Break complex questions into sub-questions
- search/2 - Execute retrieval
- reason/2 - Multi-hop reasoning with additional searches
- rerank/2 - Re-score and re-order results
- answer/2 - Generate final answer
Complete Pipeline Example
Configuration
Set defaults in your application config::repo and :llm to every pipeline.
Query Transformation Chain
Queries are transformed through the pipeline in this priority order:expanded_query(from expand/2) - highest priorityrewritten_query(from rewrite/2)question(original) - fallback
Error Handling
If any step setsctx.error, subsequent steps are skipped:
Telemetry Events
Every step emits telemetry events for observability:[:arcana, :agent, :gate][:arcana, :agent, :rewrite][:arcana, :agent, :select][:arcana, :agent, :expand][:arcana, :agent, :decompose][:arcana, :agent, :search][:arcana, :agent, :reason][:arcana, :agent, :rerank][:arcana, :agent, :answer][:arcana, :agent, :self_correct]
Next Steps
gate/2
Decide if retrieval is needed
rewrite/2
Clean conversational input
select/2
Choose collections to search
search/2
Execute retrieval