The lab notebook
Field notes on AI engineering
824 articles · page 4 of 28
Handling Tool Timeouts in AI Agents
A practical guide to detecting, surviving, and recovering from agent tool timeout failures, with runnable Python patterns for retries, circuit breakers, and graceful degradation.
Prompt Templates for AI Agents
A hands-on guide to building, versioning, and testing agent prompt templates, with runnable Python examples for ReAct loops, tool-calling agents, and RAG agents.
Agent Observability with Langfuse
A hands-on guide to instrumenting AI agents with Langfuse: traces, spans, sessions, scores, and cost tracking, so you can debug multi-step agent runs instead of guessing what went wrong.
Agent Memory with a Vector Store
Learn how to give an LLM agent persistent memory using a vector store, from chunking and embedding to retrieval, write-back, and pruning, with runnable Python code.
Implementing Guardrails for AI Agents
A practical walkthrough of building input validation, tool allowlists, output checks, and human-in-the-loop approval into an AI agent, with runnable Python code you can adapt today.
Fallback Models for AI Agents
Learn how to design and implement fallback models for AI agents so a single provider outage, rate limit, or bad response never takes your agent offline.
Evaluation Metrics for AI Agents
A practical breakdown of the agent evaluation metrics that actually predict production behavior, task completion rate, tool call accuracy, trajectory scoring, cost per task, and how to wire them into a runnable regression harness.
Deploying AI Agents on Serverless
A hands-on guide to agent serverless deployment: how to package, invoke, and scale LLM agents on Lambda, Cloudflare Workers, and Modal without falling over on cold starts or timeouts.
Agent Cost Budgeting: How to Stop AI Agents From Burning Your Token Budget
Learn how to set real spending limits on autonomous AI agents, track token usage per task, and stop runaway tool-call loops before they empty your API budget.
Building Graph RAG with Neo4j
How to build graph RAG on Neo4j for multi-hop retrieval.
Zapier AI Actions for LLM Workflows: A Practical Guide
Learn how Zapier AI Actions let LLMs like Claude and ChatGPT trigger real work in your existing apps, with setup steps, code, and the tradeoffs versus native function calling.
A Guide to Vision-Language Models
A practical, code-first walkthrough of how vision-language models work, how to call one through an API, how to run one locally, and how to fine-tune one on your own images.
Tuning HNSW Vector Indexes
A hands-on guide to HNSW tuning for engineers: what m, ef_construction, and ef_search actually do, how to measure recall, and how to trade latency for accuracy without guesswork.
Sharding and Scaling Vector Databases
A working engineer's guide to vector database sharding: how to split billions of embeddings across nodes, when to shard by ID versus by cluster, and how to keep recall high while queries fan out.
Hybrid Search in Vector Databases
Vector hybrid search combines keyword scoring with dense embeddings so your RAG retrieval stops missing exact terms and product codes. Here is how to wire it up with real code.
Structured Data Extraction with LLMs: A Practical Engineering Guide
A hands-on guide to structured extraction with LLMs: schema design, function calling, validation, chunking, and the production pitfalls that break pipelines in week two.
Choosing a Vector Database for RAG
A practical decision framework for picking a vector database for rag, with real tradeoffs between pgvector, Pinecone, Qdrant, Weaviate, and Milvus, plus runnable code to test each one.
Time-Aware RAG: Ranking Retrieval by Recency
Plain cosine similarity keeps surfacing a stale doc from three years ago over the update from last week. Here is how to build time-aware RAG that ranks retrieval by recency without breaking evergreen content.
RAG Reranking Compared: Cohere, BGE, and Jina
A hands-on comparison of Cohere Rerank, BGE reranker, and Jina reranker for RAG pipelines, with code, latency and cost tradeoffs, and a decision guide for picking one.
Multi-Hop RAG: Answering Questions That Need Several Documents
Standard RAG breaks the moment an answer needs facts from two or more documents chained together. Here is how multi-hop RAG actually works, with runnable code for decomposition, iterative retrieval, and graph-based hops.
Hybrid Search with Reciprocal Rank Fusion: Combining Vector and Keyword Search in RAG
Reciprocal rank fusion merges vector and keyword search results without tuning a single weight, and it is the simplest fix for the queries your embedding-only RAG pipeline keeps getting wrong.
Closing the Loop: Feedback Signals in RAG
Most RAG systems ship and then go quiet, no signal on which retrievals were wrong or which answers users trusted. Here is how to build rag feedback loops that turn thumbs, clicks, and corrections into better retrieval and generation.
Contextual Compression in RAG Pipelines: A Practical Guide
Contextual compression in RAG strips retrieved chunks down to the sentences that actually answer the query, cutting noise, token cost, and hallucination risk before generation. Here is how to build it, tune it, and know when it is worth the extra hop.
Adding Citations and Source Attribution to RAG
A concrete, code-first guide to attaching real citations to RAG answers, so every claim links back to a passage a user can actually verify.
Tuning RAG Chunk Size and Overlap
Your RAG chunk size choice quietly caps retrieval quality before a single embedding gets computed. Here is how to pick a starting point, tune it with real evals, and stop guessing.
Qdrant vs Weaviate: Choosing a Vector Database
A hands-on Qdrant vs Weaviate comparison for engineers building RAG and semantic search: real client code, filtering, hybrid search, and how to pick.
Prompt Token Optimization: A Practical Guide for Engineers Cutting LLM Costs
Prompt token optimization is the difference between a $200 monthly API bill and a $2,000 one at the same traffic. Here is how to measure, trim, and cache your way to leaner prompts without breaking output quality.
Prompt Testing Frameworks for LLM Apps: A Practical Guide
Your prompts will break in production if you never test them. Here's how to build a real prompt testing framework with promptfoo, DeepEval, and pytest, plus how to wire it into CI.
Prompt Templates with Jinja: A Practical Guide for LLM Apps
Learn how to use prompt templates with Jinja to build reusable, testable, version-controlled prompts instead of tangled f-strings, with runnable Python examples for the Claude API.
Self-Consistency Prompting for Better Answers
Self consistency prompting fixes flaky LLM answers by sampling multiple reasoning paths and voting on the result. Here's how to implement it, when it's worth the extra cost, and where it breaks down.