Context windows are not memory
A million tokens of context does not give a model memory. It gives it a very large short-term working set — and confusing the two is why your agent forgets what it decided twenty minutes ago.
Measuring retrieval: recall@k, MRR, and a golden set you'll maintain
Build the harness that tells you whether a change helped. Bootstrap a golden set from your own corpus, separate retrieval failures from generation failures, and stop shipping on vibes.
Hybrid retrieval: fuse keyword and vector search
Vector search alone misses exact identifiers and rare terms. Add Postgres full-text search, fuse the rankings with RRF, and rerank the top slice.
Chunking that survives contact with real documents
Build the ingestion half of a retrieval pipeline: structure-aware splitting, contextual headers, and a schema that lets you re-chunk without re-embedding the world.
Write the eval first
Prompt engineering without an eval is just vibes with extra steps. Here's how to build a scoring harness in an afternoon, and why twenty examples beat two thousand.
Build a streaming tool loop with the Claude API
A production-shaped agent loop in TypeScript: typed tools, streamed output, human approval gates, and the pause_turn case that silently truncates answers.
Streaming is a state machine, not a string
The token loop is the easy part. Reconnects, partial JSON, backpressure, and the abandoned-request problem are where streaming implementations actually break.