Guides
In-depth how-to guides for every feature of lauren-ai.
Core
Use LLMService for direct completions, streaming, and embeddings without
the full agentic loop.
• Tools
Decorate functions and classes with @tool() to expose them to agents.
Covers schema generation, ToolContext, DI injection, and caching.
• Agents
Build agents with @agent(), @use_tools(), lifecycle hooks, delegation,
and full DI integration via AgentRunner.
🗄 Memory
Four-tier memory architecture: short-term window, conversation history, per-user long-term facts, and vector store for RAG.
Multi-agent & orchestration
Persist facts about individual users across conversations with
@remember(), UserMemoryStore, and MemoryFact.
Delegate between agents via tool-based handoff — every transition is
visible in the tool-call log and composes with run_stream().
Compose specialist agents with @team() in coordinator or collaborate
mode. Stream TeamEvent instances as workers produce results.
Load documents, chunk them, embed them into InMemoryVectorStore, and
inject relevant context into agents automatically.
Input & output
Build reusable, composable prompts with PromptTemplate,
ChatPromptTemplate, and FewShotPromptTemplate.
Transform raw LLM text into typed Python objects with StrOutputParser,
JSONOutputParser, and PydanticOutputParser.
Guarantee every completion matches a Pydantic schema using StructuredLLM
and llm_service.with_structured_output(Model).
Send images, audio, and documents to the LLM using ImageContent,
AudioContent, and DocumentContent alongside text messages.
Route natural-language queries to named handlers using embedding-based
similarity with SemanticRouter and Route.
Stream tokens, tool results, and agent turns via run_stream() and
CompletionChunk — with SSE controller integration.
Production & quality
Block prompt injection, redact PII, enforce topic and length constraints, and build custom LLM-evaluated guardrails.
Compose templates, LLM calls, and parsers into typed pipelines with
Chain, RunnableLambda, and | operator chaining.
Track token usage and USD cost per model and conversation with
CostTracker, TokenBudget, and RateLimiter.
Record structured spans with @traced(), export to OpenTelemetry or
a custom TraceStore, and inspect the full agent execution tree.
• Testing
Write deterministic, zero-network tests with MockTransport,
AgentTestClient, and queued mock responses.
Score agent outputs against expected answers using built-in evaluators
and the EvalSuite runner.
Enable chain-of-thought reasoning in supporting models by passing
thinking=True to the transport or AgentConfig.