Real-World Application Patterns
The questions every production LLM application meets - how agents work together, how retrieval scales, how failures are survived, what to monitor, how to secure keys and data - and the LLM4S component that answers each. Each page is short: when to use the pattern, the shipped component, a minimal example, and links to the full guide and a runnable sample.
The patterns
| Challenge | Page | Shipped components |
|---|---|---|
| Several agents need to work together | Multi-Agent Orchestration | Handoff.to / Handoff.toId, withSubagents and TypedAgent, GraphBuilder |
| Answering over a large document set | RAG for Enterprise | RAG with withPgHybrid, loaders and sync, reranking, permission-based RAG, RAGAS evaluation |
| Seeing what production is doing | Production Monitoring | Langfuse and OpenTelemetry tracing, PrometheusMetrics, MicrometerMetrics, MeteredCheckpointer, CostTracker |
| Handling more traffic for less money | Scaling Strategies | CachingLLMClient, CachedEmbeddingClient, RateLimitConfig, AgentWorker and the run queue |
| Surviving provider failures | Error Recovery | ReliableClient, RetryPolicy, CircuitBreakerConfig, provider fallback, agent.recover |
| Protecting keys and data | Security Best Practices | apiKeyFile, VaultApiKeyProvider, AwsSecretsManagerApiKeyProvider, guardrails, encrypted checkpoints, the workspace sandbox |
Combining them
- A support desk with departments. A triage agent hands off to department agents
(handoffs), each answering from its own documents
(RAG), every client wrapped in
ReliableClientwith a fallback provider (Error Recovery). - An internal knowledge assistant. A hybrid PostgreSQL pipeline kept current with
sync, retrieval filtered by the asking user (permission-based RAG), PII masked on the way in and out (guardrails), and RAGAS scores tracked over time. - An agent service behind an API. Agents on a shared PostgreSQL store with a run queue and a worker on every instance (scaling), checkpoints encrypted per tenant (security), runs traced and run queue metrics scraped (monitoring).
Start from a running example
- The Cookbook recipes run with no API key: fallback between providers, caching, a multi-agent graph, document Q&A, guardrails, memory.
- The example agent service is a deployable agent service with a run queue, a worker and server-sent events.
- Production Deployment covers configuration, secrets, containers and Kubernetes.
- Reference Architecture puts llm4s behind an AI gateway: secret injection, egress policy, failover, quotas and spend.