You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Agent Composer is a framework for building custom RAG agents as computational graphs. Instead of using a fixed pipeline, you compose workflows from pre-built nodes that handle search, generation, transformation, and logic.
Two Ways to Build
Method
Description
Access
YAML Configuration
Define workflows in structured YAML files
Enterprise
Visual Workflow Builder
Drag-and-drop GUI that generates YAML
Enterprise
Templates
Pre-built workflows (Basic, Agentic Search)
Self-serve
Key Terminology
Term
Definition
Node
A single operation (search, generate, transform, etc.)
Input Mapping
How data flows between nodes (node#output)
Config
Parameters passed to a node's constructor
Subgraph
A reusable workflow that can be nested
Conditional Node
Branches execution based on runtime conditions
UI Stream Types
What data streams to the user during execution
2. Architecture & Execution Model
How It Works
Agent Composer executes workflows as Directed Acyclic Graphs (DAGs):
salesforce:
type: SalesforceSOSLStepconfig:
sosl_query: "FIND {$search_term} IN ALL FIELDS RETURNING Account, Contact"result_limit: 250timeout: 30# OAuth authclient_id: "${SF_CLIENT_ID}"client_secret: "${SF_CLIENT_SECRET}"
9. Retrieval Configuration
Search Parameters
Parameter
Range
Default
Description
top_k / top_k_retrieved_chunks
1-200
100
Max chunks to retrieve
semantic_alpha
0-1
0.9
Semantic search weight
lexical_alpha
0-1
0.1
Keyword search weight (must sum to 1 with semantic)
enable_query_expansion
bool
false
Rewrite query with terminology
enable_query_decomposition
bool
false
Break complex queries into sub-queries
Reranking Parameters
Parameter
Range
Default
Description
reranker
string
ctxl-rerank-v2-instruct-multilingual-FP8
Reranker model
rerank_top_k / top_k_reranked_chunks
1-200
—
Max chunks after reranking
reranker_score_filter_threshold
0-1
—
Min score to keep
rerank_instructions
string
—
Natural language ranking preferences
Rerank Instructions Examples
rerank_instructions: | Prioritize: - Recent content (last 6 months) for fast-moving topics - High-citation papers for established techniques - Highly-upvoted posts for practical advice Deprioritize: - Surveys and literature reviews - Low-effort posts without technical detail - Outdated information (>2 years old)
Chunking Strategies
Strategy
Best For
Description
Hierarchy Depth (default)
Academic papers, manuals
Uses document structure (sections, subsections)
Hierarchy Heading
Contracts, chat logs
Segments by headings, ignores depth
Static Length
Baseline testing
Fixed token intervals
Page Level
Slide decks, summaries
Each page = one chunk
10. Generation Configuration
Generation Parameters
Parameter
Range
Default
Description
temperature
0-1
—
Randomness (lower = more deterministic)
top_p
0-1
—
Nucleus sampling
max_new_tokens
—
—
Max output length
frequency_penalty
—
—
Reduce repetition
random_seed
—
—
Reproducibility
System Prompt
generate:
type: ResponseGenerationStepconfig:
system_prompt: | You are a technical research assistant. Guidelines: - Only use information from provided documentation - Use exact terminology from sources - Keep answers concise and relevant - Use markdown for lists, tables, code - Answer directly, then stop - If information is missing, say so clearly
Groundedness & Attribution
generate:
type: ResponseGenerationStepconfig:
enable_groundedness_check: true # Score how grounded in sourcesenable_attribution: true # Extract citation metadata
Outputs:
response — Generated text
attribution_result — Citation metadata
groundedness_scores — How well grounded in sources
11. UI Streaming
Stream Types
Type
Description
RETRIEVALS
Search results and citations
GENERATION
LLM response as it generates
QUERY_REFORMULATION
Query transformations
ATTRIBUTION
Citation metadata
GROUNDEDNESS
Grounding scores
Configuration
generate:
type: ResponseGenerationStepui_stream_types:
generation: true # Stream response textretrievals: true # Show retrieved chunksattribution: true # Show citationsgroundedness: true # Show grounding scores
Multiple Outputs
When your graph has multiple outputs, designate which one streams to UI:
outputs:
response: strdebug_info: object__outputs__:
type: outputui_output: true # Requiredinput_mapping:
response: generate#response # This one streamsdebug_info: debug#info
12. Evaluation with LMUnit
What is LMUnit?
LMUnit evaluates LLM outputs through natural language unit tests. Instead of generic metrics, you define specific testable criteria.
Writing Unit Tests
Good tests are:
Specific (one criterion)
Clear (unambiguous)
Measurable (consistent scoring)
Positively framed (assess qualities, not flaws)
Examples
unit_tests= [
"Does the response cite specific arXiv paper IDs?",
"Does the response distinguish between research findings and community opinions?",
"Are potential limitations or caveats acknowledged?",
"Is the response grounded in the retrieved sources?",
"Does the response provide actionable next steps?",
]
Scoring Rubric
Create detailed rubrics for nuanced scoring:
unit_test="""Does the response provide specific metrics?Scoring Scale:1: No metrics provided2: Limited metrics without context3: Basic metrics with some analysis4: Clear metrics with detailed analysis5: Comprehensive metrics with contextual analysis"""
API Usage
fromcontextualimportContextualAIclient=ContextualAI(api_key="...")
result=client.lmunit.create(
query="What is speculative decoding?",
response="Speculative decoding is...",
unit_test="Does the response explain the core mechanism?"
)
print(result.score) # 1-5 scale