Pattern Library
Linear Flow
The simplest pattern—sequential steps with clear dependencies.
Document Summarization
<- document summary
<= summarize this text
<- clean text
<= extract main content, removing headers
<- raw document
LLM calls: 2 (extract, summarize)
Legal Risk Assessment
<- risk assessment
<= evaluate legal exposure based on the extracted clauses
<- relevant clauses
<= extract clauses related to liability and indemnification
<- classified sections
<= identify and classify document sections
<- full contract
LLM calls: 3 (classify, extract, assess)
Key: The risk assessment never sees the full contract. Only the extracted clauses. This eliminates hallucination of clause numbers.
Multi-Input Operations
Actions that need multiple data sources—they see all listed inputs, but nothing else.
Sentiment Analysis with Context
<- user sentiment
<= determine sentiment level based on user experience
<- support ticket
<- conversation history
LLM calls: 1 (determine sentiment)
Quarterly Report Generation
<- quarterly report
<= compile findings into executive summary
<- analyzed data
<= identify trends and anomalies
<- raw metrics
<- previous quarter report
LLM calls: 2 (identify trends, compile)
Iteration Over Collections
Process each item in a collection and aggregate results.
Batch Document Summarization
<- all summaries
<= for every document in the list return the document summary
<= select document summary to return
<- document summary
<= summarize this document
<- document to process now
<- documents
<* document to process now
LLM calls: N (one per document)
Key components:
• <- documents — Base collection (value concept)
• <* document to process now — Current element marker (context concept)
• <= select document summary to return — Selects output per iteration
Research Paper Synthesis
<- final synthesis
<= synthesize insights across all themes
<- major themes
<= identify common themes
<- all findings
<= for every paper return the key findings
<= select key findings
<- key findings
<= extract main findings
<- current paper
<- research papers
<* current paper
LLM calls: N + 2 (N papers + theme identification + synthesis)
Conditional Execution
Execute steps only when conditions are met.
Review Workflow
<- final output
<= select reviewed output if available otherwise use draft
<- draft needs review?
<= check if draft requires review
<- draft output
<- reviewed output
<= perform human review and corrections
<= if draft needs review
<* draft needs review?
<- draft output
<- draft output
LLM calls: 1-2 (check + optional review)
Error Recovery with Fallback
<- final answer
<= select the first valid result
<- complex reasoning failed?
<= check if primary answer is valid
<- primary answer
<- fallback answer
<= use simple approach as fallback
<= if complex reasoning failed
<* complex reasoning failed?
<- input data
<- primary answer
<= attempt complex reasoning
<- input data
LLM calls: 2-3 (primary + check + optional fallback)
Data Collection
Gather and group data from multiple sources.
Simple Collection (Free)
<- all inputs
<= collect these items together as one group
<- user query
<- system context
<- retrieved documents
LLM calls: 0 (syntactic grouping)
Parallel Analysis Collection
<- analysis results
<= gather results from all analyses as one info unit
<- sentiment analysis
<= analyze sentiment
<- text
<- entity extraction
<= extract entities
<- text
<- topic classification
<= classify topics
<- text
LLM calls: 3 (can run in parallel)
Parallel execution: Since all three analyses use the same input and don't depend on each other, they can run simultaneously.
Real-World Applications
Complete examples from production use cases.
Email Triage System
<- triage decision
<= assign priority and route to appropriate team
<- email metadata
<= extract sender, subject, keywords
<- raw email
<- urgency assessment
<= determine urgency level
<- email content
<= extract body text
<- raw email
<- historical context
<= look up previous conversations
<- sender info
Code Review Assistant
<- review summary
<= generate comprehensive review report
<- code issues
<= identify bugs and anti-patterns
<- code diff
<- security concerns
<= check for security vulnerabilities
<- code diff
<- style suggestions
<= evaluate code style and readability
<- code diff
Best Practices
Start Simple
Begin with linear flows. Add complexity only when needed.
One Action Per Inference
Each inference has exactly one <= line. Nest for multiple steps.
Explicit Dependencies
Make data flow obvious. Show what each step receives.
Descriptive Names
Use clear names like "risk assessment" instead of "result".
Isolate Expensive Ops
Group free syntactic operations, isolate costly LLM calls.
Test Incrementally
Use breakpoints to test each step before adding more.