# Stanley Yang > Stanley Yang turns complex workflows into clear, dependable full-stack products built for real-world demand. ## About - [Homepage](https://stanleycyang.com/): Overview of Stanley Yang's engineering work and current focus. - [About](https://stanleycyang.com/about): Background, working principles, and areas of expertise. - [Work](https://stanleycyang.com/work): Selected product engineering experience and case studies. - [Writing](https://stanleycyang.com/writing): Index of source-checked technical tutorials. - [Editorial standards](https://stanleycyang.com/editorial): Research, testing, AI-assistance, safety, correction, and disclosure standards. - [Privacy](https://stanleycyang.com/privacy): Current site data practices and visitor choices. ## Start here A small selection of representative technical guides. - [Agent Swarms: When Multiple AI Agents Help—and When They Make Things Worse](https://stanleycyang.com/writing/agent-swarms-when-multiple-agents-help): A practical decision framework for choosing a multi-agent architecture, plus a minimal coordinator that keeps concurrency, budgets, and failure handling explicit. Topics: AI agents, Multi-agent systems, Architecture. Updated: 2026-07-18. - [AI Agent Memory with Postgres and pgvector: Schema, Retrieval, and Forgetting](https://stanleycyang.com/writing/ai-agent-memory-postgres-pgvector): Design tenant-safe agent memory with provenance, hybrid search, retention, deletion, and pgvector indexing that does not mistake every transcript for knowledge. Topics: AI agent memory, PostgreSQL, pgvector. Updated: 2026-07-18. - [Build a Safe MCP Server in TypeScript: Tools, Validation, and Transports](https://stanleycyang.com/writing/build-mcp-server-typescript): Build and test a real MCP stdio server, then make the transport, validation, error, and authorization decisions required for a remote deployment. Topics: Model Context Protocol, TypeScript, AI agents. Updated: 2026-07-18. ## Optional The complete writing archive. Articles use inline sources, visible update dates, and explicit testing labels. - [Accessible Agent Interfaces for Keyboard, Screen Reader, and Voice Users](https://stanleycyang.com/writing/accessible-agent-interfaces): Design streaming conversations, tool progress, approvals, errors, and voice controls that preserve focus, user control, and understandable status. Topics: Accessibility, AI agents, User experience. Updated: 2026-07-18. - [Adopting OpenTelemetry GenAI Semantic Conventions Without Breaking Observability](https://stanleycyang.com/writing/opentelemetry-genai-semantic-conventions): A migration playbook for adopting the evolving OpenTelemetry GenAI span, metric, and event schema safely. Topics: OpenTelemetry, AI observability, Semantic conventions. Updated: 2026-07-18. - [AI Agent Evals in CI: A Release Gate for Prompts, Models, and Tools](https://stanleycyang.com/writing/ai-agent-evals-ci): Build a provider-neutral agent evaluation suite with deterministic checks, repeated trials, safety cases, uncertainty, and a CI policy that catches regressions. Topics: AI agent evaluation, Continuous integration, AI testing. Updated: 2026-07-18. - [AI Agent Memory Poisoning: Threat Model, Detection, and Recovery](https://stanleycyang.com/writing/agent-memory-poisoning-defense): Protect persistent agent memory with source trust, write gates, quarantine, contradiction checks, provenance, and complete recovery procedures. Topics: AI security, AI agent memory, Prompt injection. Updated: 2026-07-18. - [Automatic Prefix Caching for Agent Workloads](https://stanleycyang.com/writing/automatic-prefix-caching-agent-workloads): Make repeated agent prompts cacheable in vLLM without crossing tenant boundaries, and measure whether cache hits actually improve latency. Topics: vLLM, Prefix caching, AI agents. Updated: 2026-07-18. - [Backpressure for AI Agent Systems](https://stanleycyang.com/writing/backpressure-agent-systems): Design admission control, bounded queues, concurrency limits, deadlines, and graceful degradation for agent workloads. Topics: AI agents, Reliability, Distributed systems. Updated: 2026-07-18. - [Benchmark PostgreSQL 18 Async I/O for RAG Workloads](https://stanleycyang.com/writing/postgres-18-async-io-rag-benchmark): A reproducible protocol for testing PostgreSQL 18 AIO across vector search, filtered retrieval, ingestion, vacuum, and cache states. Topics: PostgreSQL, RAG, Benchmarking. Updated: 2026-07-18. - [Benchmark Quantized Agent Models for Quality, Memory, and Speed](https://stanleycyang.com/writing/quantization-agent-models-quality-memory-speed): A reproducible protocol for comparing weight, activation, and KV-cache quantization without inventing savings or hiding quality regressions. Topics: Quantization, LLM inference, Benchmarking. Updated: 2026-07-18. - [Benchmark Speculative Decoding Reproducibly](https://stanleycyang.com/writing/speculative-decoding-reproducible-benchmark): Measure speculative decoding against a target-only baseline across load, prompt types, acceptance rates, memory, latency, throughput, and output equivalence. Topics: Speculative decoding, vLLM, Benchmarking. Updated: 2026-07-18. - [Benchmark Structured-Output Reliability in Open Models](https://stanleycyang.com/writing/structured-output-reliability-open-models): A reproducible protocol for measuring JSON validity, schema compliance, semantic accuracy, latency, and failure recovery across open models. Topics: Structured outputs, Open models, Evaluation. Updated: 2026-07-18. - [Build a Budget Controller for Agent Workflows](https://stanleycyang.com/writing/agent-workflow-budget-controller): Enforce token, tool-call, latency, concurrency, and monetary ceilings across nested agent work without relying on prompt instructions. Topics: AI agents, Cost control, Reliability. Updated: 2026-07-18. - [Build a Citation-Aware Document Agent for PDFs, Scans, Tables, and Images](https://stanleycyang.com/writing/citation-aware-multimodal-document-agent): Preserve page regions, reading order, tables, OCR alternatives, and source versions so every document answer can resolve to visible evidence. Topics: Multimodal AI, Document AI, Retrieval-augmented generation. Updated: 2026-07-18. - [Build a Citation-First RAG System That Rejects Unsupported Claims](https://stanleycyang.com/writing/citation-first-rag-system): Represent evidence at span level, require citations for verifiable claims, and abstain when retrieval cannot support a grounded answer. Topics: Retrieval-augmented generation, AI safety, Evaluation. Updated: 2026-07-18. - [Build a Coding-Agent Harness with Hard Execution Boundaries](https://stanleycyang.com/writing/build-coding-agent-harness): Wrap any coding model in a reproducible harness that controls workspaces, commands, credentials, budgets, evidence, and verification. Topics: Coding agents, AI agents, Security. Updated: 2026-07-18. - [Build a GPU Capacity Planner for LLM Inference](https://stanleycyang.com/writing/gpu-capacity-planner-llm-inference): Estimate weights, KV cache, runtime overhead, context concurrency, and replica demand—then replace assumptions with measured service curves. Topics: GPU capacity planning, LLM inference, vLLM. Updated: 2026-07-18. - [Build a Multi-Tenant MCP Gateway Without Collapsing Trust Boundaries](https://stanleycyang.com/writing/multi-tenant-mcp-gateway): Route remote MCP traffic by authenticated tenant while isolating tokens, sessions, discovery, quotas, results, and audit records. Topics: Model Context Protocol, Multi-tenancy, Security. Updated: 2026-07-18. - [Build a Plan–Execute–Review Agent Without Infinite Loops](https://stanleycyang.com/writing/plan-execute-review-agent): Implement an agent loop with typed plans, evidence-based review, bounded revision, explicit stop states, and safe tool execution. Topics: AI agents, Architecture, TypeScript. Updated: 2026-07-18. - [Build a Production RAG Ingestion Pipeline: Parse, Version, Embed, and Delete Correctly](https://stanleycyang.com/writing/production-rag-ingestion-pipeline): Design a restartable RAG ingestion pipeline that preserves provenance, detects changes, avoids duplicate work, and removes stale chunks from retrieval. Topics: Retrieval-augmented generation, Data engineering, AI agents. Updated: 2026-07-18. - [Build a Real-Time Voice Agent over WebRTC](https://stanleycyang.com/writing/realtime-voice-agent-webrtc): Design a reconnectable browser voice agent with explicit signaling, ephemeral authorization, audio lifecycle, interruption, and observable session state. Topics: Voice agents, WebRTC, Real-time applications. Updated: 2026-07-18. - [Build a Simulated World for AI Agent Testing](https://stanleycyang.com/writing/simulated-world-agent-testing): Create resettable, observable email, calendar, browser, and database environments that test agent effects without touching real systems. Topics: AI agent testing, Simulation, Test environments. Updated: 2026-07-18. - [Build a Single-GPU RAG Stack](https://stanleycyang.com/writing/single-gpu-rag-stack): Reserve one GPU for generation, run embeddings and retrieval on CPU, store cited chunks in Postgres with pgvector, and evaluate retrieval before answers. Topics: RAG, vLLM, pgvector. Updated: 2026-07-18. - [Build a Visual Browser-Agent Benchmark That Measures Real Task Success](https://stanleycyang.com/writing/visual-browser-agent-benchmark): Create resettable visual web tasks with programmatic outcome validators, layout perturbations, safety checks, and reproducible multimodal traces. Topics: Computer-use agents, Evaluation, Browser automation. Updated: 2026-07-18. - [Build AI Agent Tools as WebAssembly Components](https://stanleycyang.com/writing/webassembly-components-agent-tools): Define typed WIT contracts, explicit capabilities, resource limits, provenance, and conformance tests for portable agent tools. Topics: WebAssembly, AI agents, Sandboxing. Updated: 2026-07-18. - [Build an Evidence-First Code Review Agent](https://stanleycyang.com/writing/evidence-first-code-review-agent): Design a review agent that reports reproducible defects with precise evidence instead of producing noisy summaries and style opinions. Topics: Coding agents, Code review, AI agents. Updated: 2026-07-18. - [Build an Interactive MCP App with a Sandboxed Tool UI](https://stanleycyang.com/writing/build-interactive-mcp-app): Design an MCP tool that serves an interactive UI resource, receives structured results, and stays safe across hosts with different extension support. Topics: Model Context Protocol, Web development, AI agents. Updated: 2026-07-18. - [Build an MCP Client in TypeScript: Discovery, Tool Calls, and Trust Boundaries](https://stanleycyang.com/writing/build-mcp-client-typescript): Connect to a local MCP server, verify capability discovery, call a typed tool, and handle remote transports without confusing discovery with authorization. Topics: Model Context Protocol, TypeScript, AI agents. Updated: 2026-07-18. - [Build an OWASP Agent Security Test Harness](https://stanleycyang.com/writing/owasp-agent-security-test-harness): Turn the OWASP Top 10 for Agentic Applications into safe, repeatable abuse cases with simulated tools, hard invariants, evidence, and CI gates. Topics: AI agents, Security testing, OWASP. Updated: 2026-07-18. - [Build Forensic Audit Logs for AI Agents](https://stanleycyang.com/writing/forensic-audit-logs-ai-agents): Capture actor chains, policy decisions, approvals, tool effects, and evidence so investigators can reconstruct an agent incident without logging hidden reasoning or secrets. Topics: AI agents, Observability, Security. Updated: 2026-07-18. - [Build Long-Running MCP Tools with the Experimental Tasks Utility](https://stanleycyang.com/writing/mcp-tasks-long-running-tools): Design a durable MCP tool call with polling, deferred results, input-required handling, cancellation, and tenant-safe retention. Topics: Model Context Protocol, AI agents, Distributed systems. Updated: 2026-07-18. - [Build Streaming Agent Interfaces in Next.js](https://stanleycyang.com/writing/streaming-agent-interfaces-nextjs): Stream agent UI and typed run events with Suspense, Route Handlers, cancellation, backpressure, and accessible status updates. Topics: Next.js, AI agents, Streaming. Updated: 2026-07-18. - [Build Two Agents That Collaborate over A2A 1.0](https://stanleycyang.com/writing/build-a2a-agents-v1): Connect a coordinator to an independently operated report agent using an Agent Card, SendMessage, task state, typed artifacts, and strict authorization. Topics: Agent2Agent, AI agents, Distributed systems. Updated: 2026-07-18. - [Caching AI Applications: Prompts, Prefixes, Retrieval, and Tools](https://stanleycyang.com/writing/caching-ai-applications): A correctness-first guide to caching model prefixes, retrieval results, tool calls, and final AI outputs safely. Topics: AI applications, Caching, Security. Updated: 2026-07-18. - [Capability-Based Security for AI Agent Tools](https://stanleycyang.com/writing/capability-based-security-agent-tools): Replace broad ambient credentials with narrow, expiring, attenuable grants bound to one agent task, tenant, operation, and resource set. Topics: AI agents, Authorization, Security. Updated: 2026-07-18. - [Choose an Open Model with an Evaluation Suite](https://stanleycyang.com/writing/choose-open-model-evaluation-suite): Select open weights with a reproducible, product-specific suite covering capability, tool use, safety, latency, memory, and operational fit. Topics: Open models, Evaluation, Model selection. Updated: 2026-07-18. - [Computer Use vs DOM Automation vs APIs: Choose the Most Reliable Agent Interface](https://stanleycyang.com/writing/computer-use-vs-dom-automation-vs-apis): Choose between APIs, structured browser automation, accessibility trees, and visual computer use using reliability, coverage, security, and cost. Topics: Computer-use agents, Browser automation, AI agents. Updated: 2026-07-18. - [Context Engineering for AI Agents: Build a Context Assembler](https://stanleycyang.com/writing/context-engineering-ai-agents): Design a context pipeline that selects trusted instructions, relevant evidence, tool definitions, and recent state within an explicit token budget. Topics: AI agents, Context engineering, Architecture. Updated: 2026-07-18. - [Contract Testing for AI Agent Tools](https://stanleycyang.com/writing/contract-testing-agent-tools): Test agent tool schemas, transport behavior, authorization, retries, and compatibility with valid, invalid, and adversarial requests. Topics: AI agent tools, Contract testing, JSON Schema. Updated: 2026-07-18. - [Cost Attribution for Multi-Agent Systems](https://stanleycyang.com/writing/multi-agent-cost-attribution): A practical ledger for attributing model, tool, compute, retry, and shared costs to successful multi-agent outcomes. Topics: Multi-agent systems, FinOps, AI observability. Updated: 2026-07-18. - [Delegated Authorization for AI Agents Acting on Behalf of Users](https://stanleycyang.com/writing/delegated-authorization-ai-agents): Preserve user intent and actor identity across agent-to-service and agent-to-agent calls with narrow audiences, scopes, consent, and delegation chains. Topics: AI agents, OAuth, Authorization. Updated: 2026-07-18. - [Design an Async Sandboxed Agent Tool Runner with WASI 0.3](https://stanleycyang.com/writing/wasi-0-3-async-sandboxed-tool-runner): Use ratified WASI 0.3 async components with pinned runtime support, explicit capabilities, deadlines, backpressure, and safe cancellation. Topics: WASI, AI agents, Sandboxing. Updated: 2026-07-18. - [Design Approval UX for High-Risk Agent Actions](https://stanleycyang.com/writing/approval-ux-high-risk-agent-actions): Turn human approval into a real security control by previewing exact effects, binding approval to immutable action data, and preventing replay or substitution. Topics: AI agents, Human in the loop, Security. Updated: 2026-07-18. - [Design-to-Code with Visual Regression That Developers Can Trust](https://stanleycyang.com/writing/design-to-code-visual-regression): Turn design states into deterministic Playwright checks that combine semantic assertions, visual baselines, accessibility, and human-reviewed diffs. Topics: Design engineering, Playwright, Testing. Updated: 2026-07-18. - [Deterministic Replay for Nondeterministic AI Agents](https://stanleycyang.com/writing/deterministic-replay-ai-agents): Record model, tool, time, randomness, configuration, and state dependencies so agent failures can be replayed without repeating real-world effects. Topics: AI agents, Deterministic replay, Agent debugging. Updated: 2026-07-18. - [Disaggregate Prefill and Decode for Long-Context Agents](https://stanleycyang.com/writing/disaggregated-prefill-decode-long-context-agents): Separate prefill and decoding only when independent scaling and latency isolation beat KV-transfer cost, duplicated weights, and operational complexity. Topics: LLM inference, Disaggregated serving, Long context. Updated: 2026-07-18. - [Do Repository Instruction Files Help Coding Agents? A Benchmark Protocol](https://stanleycyang.com/writing/benchmark-repository-instruction-files): Measure absent, concise human-written, generated, and noisy repository instructions with paired tasks, fixed agent settings, and no invented results. Topics: Coding agents, Evaluation, AGENTS.md. Updated: 2026-07-18. - [Durable AI Agents: Retries, Idempotency, Human Approval, and Resume](https://stanleycyang.com/writing/durable-ai-agents): Design long-running agent workflows that survive crashes, retry only safe work, bind approvals to exact actions, and reconcile ambiguous side effects. Topics: Durable execution, AI agents, Workflow orchestration. Updated: 2026-07-18. - [Edge vs. Node vs. GPU Backends for AI Applications](https://stanleycyang.com/writing/edge-vs-node-vs-gpu-ai-backends): Choose AI backend placement with a reproducible latency, quality, capacity, cost, security, and failure benchmark. Topics: AI infrastructure, Benchmarking, Backend architecture. Updated: 2026-07-18. - [Enforce Coding-Agent Policy with Lifecycle Hooks](https://stanleycyang.com/writing/coding-agent-policy-lifecycle-hooks): Design deterministic before-and-after hooks that deny unsafe agent actions, require approval, verify patches, and create an auditable policy trail. Topics: Coding agents, Security, Policy as code. Updated: 2026-07-18. - [Event-Sourced AI Agents: Replay, Debug, and Resume Any Run](https://stanleycyang.com/writing/event-sourced-ai-agents): Store immutable agent events, build deterministic projections, preserve model and tool outcomes, and recover safely after failures. Topics: AI agents, Event sourcing, Reliability. Updated: 2026-07-18. - [Generate and Heal Playwright Tests with Agents—Without Hiding Bugs](https://stanleycyang.com/writing/generate-heal-playwright-tests-agents): Use planner, generator, and healer agents under explicit evidence, security, and review gates so test maintenance does not weaken assertions. Topics: Playwright, Coding agents, Testing. Updated: 2026-07-18. - [GraphRAG vs Vector RAG: A Reproducible Benchmark Protocol](https://stanleycyang.com/writing/graphrag-vs-vector-rag-benchmark): Compare graph and vector retrieval on local facts, multi-hop relationships, corpus-wide themes, latency, cost, freshness, and citation support. Topics: GraphRAG, Retrieval-augmented generation, Evaluation. Updated: 2026-07-18. - [Ground Computer-Use Agents with Screenshots and Accessibility Trees](https://stanleycyang.com/writing/ground-computer-use-screenshots-accessibility-trees): Fuse pixels with roles, names, states, geometry, and postcondition checks while detecting disagreement between visual and semantic UI representations. Topics: Computer-use agents, Accessibility, Browser automation. Updated: 2026-07-18. - [How to Benchmark a Multi-Model Router](https://stanleycyang.com/writing/benchmark-multi-model-router): A reproducible protocol for measuring a model router's quality, cost, latency, abstention, and resilience without cherry-picking. Topics: LLM routing, AI evaluation, Benchmarking. Updated: 2026-07-18. - [How to Bisect an AI Agent Regression](https://stanleycyang.com/writing/bisect-agent-regressions): Find the prompt, model, tool, data, or code change that caused an agent regression despite stochastic outcomes and external drift. Topics: AI agent evaluation, Regression testing, Git bisect. Updated: 2026-07-18. - [How to Build a High-Quality Agent Evaluation Dataset](https://stanleycyang.com/writing/build-agent-evaluation-dataset): Turn real agent tasks and failures into a versioned, reviewable evaluation dataset with defensible labels, provenance, and release coverage. Topics: AI agent evaluation, Evaluation datasets, AI testing. Updated: 2026-07-18. - [How to Build a Latency Budget for an AI Agent](https://stanleycyang.com/writing/ai-agent-latency-budget): Turn an end-to-end response target into measurable queue, model, tool, orchestration, and streaming budgets. Topics: AI agents, Performance, SRE. Updated: 2026-07-18. - [How to Debug a Production AI Agent Incident](https://stanleycyang.com/writing/debug-production-agent-incident): A containment-first incident playbook for agent models, tools, prompts, memory, retries, and ambiguous side effects. Topics: AI agents, Incident response, Production reliability. Updated: 2026-07-18. - [How to Define SLOs for AI Agents](https://stanleycyang.com/writing/slos-for-ai-agents): Define measurable reliability, latency, quality, safety, and cost objectives around user outcomes—not model uptime. Topics: AI agents, SRE, AI evaluation. Updated: 2026-07-18. - [How to Evaluate a Voice Agent: Recognition, Turn Taking, Audio, and Task Success](https://stanleycyang.com/writing/evaluate-voice-agent): Build a voice-agent evaluation suite that measures task outcomes, transcript errors, turn behavior, interruptions, audio delivery, safety, and user control. Topics: Voice agents, Evaluation, Speech interfaces. Updated: 2026-07-18. - [How to Load Test Tool-Using AI Agents Safely](https://stanleycyang.com/writing/load-testing-tool-using-agents): A reproducible load-testing protocol for agent queues, models, tools, retries, side effects, quality, and recovery. Topics: AI agents, Load testing, Reliability. Updated: 2026-07-18. - [Human Approval for AI Agents: Bind Approval to the Exact Action](https://stanleycyang.com/writing/human-approval-for-ai-agents): Design approval previews, cryptographic action binding, expiry, authorization, execution, and audit trails for consequential agent actions. Topics: AI agents, Human oversight, Security. Updated: 2026-07-18. - [Hybrid Search with PostgreSQL and pgvector: Full Text, Vectors, and Rank Fusion](https://stanleycyang.com/writing/hybrid-search-postgres-pgvector): Combine PostgreSQL lexical search with pgvector semantic retrieval using reproducible ranking, tenant-safe filters, and measured relevance. Topics: PostgreSQL, pgvector, Retrieval-augmented generation. Updated: 2026-07-18. - [LLM-as-a-Judge: How to Calibrate It Against Humans](https://stanleycyang.com/writing/calibrate-llm-as-a-judge): Calibrate a model grader with blinded human labels, bias probes, agreement diagnostics, and explicit rules for when automation must abstain. Topics: LLM as a judge, AI agent evaluation, Human evaluation. Updated: 2026-07-18. - [Make Agent Swarms Faster and Cheaper with Bounded Parallelism](https://stanleycyang.com/writing/agent-swarm-bounded-parallelism): Use dependency graphs, a tested worker pool, cancellation, deduplication, and budgets to reduce multi-agent latency without creating rate-limit and cost failures. Topics: Multi-agent systems, Performance, TypeScript. Updated: 2026-07-18. - [MCP Elicitation: Ask Users for Input Without Asking for Secrets](https://stanleycyang.com/writing/mcp-elicitation-user-input): Implement form- and URL-mode MCP elicitation with explicit navigation approval, schema validation, identity binding, and safe resume behavior. Topics: Model Context Protocol, User experience, Security. Updated: 2026-07-18. - [MCP Sampling with Tools: Build a Bounded Server-Initiated Model Loop](https://stanleycyang.com/writing/mcp-sampling-with-tools): Let an MCP server request model work through its client while enforcing tool capability checks, iteration budgets, approvals, and message balance. Topics: Model Context Protocol, AI agents, Security. Updated: 2026-07-18. - [MCP stdio vs. Streamable HTTP: How to Choose and Benchmark the Transport](https://stanleycyang.com/writing/mcp-stdio-vs-streamable-http): Compare MCP's two standard transports and run a fair benchmark covering startup, latency, concurrency, streaming, recovery, and security. Topics: Model Context Protocol, Performance, Distributed systems. Updated: 2026-07-18. - [MCP Tools vs. Resources vs. Prompts: A Practical Decision Guide](https://stanleycyang.com/writing/mcp-tools-vs-resources-vs-prompts): Choose the right MCP primitive for actions, application-selected context, and user-invoked workflows, then design each contract safely. Topics: Model Context Protocol, API design, AI agents. Updated: 2026-07-18. - [MCP vs. A2A: Which Agent Protocol Do You Need?](https://stanleycyang.com/writing/mcp-vs-a2a): A practical architecture guide to using MCP for tools and context, A2A for peer-agent work, and both without collapsing their trust boundaries. Topics: Model Context Protocol, Agent2Agent, AI architecture. Updated: 2026-07-18. - [Measure Voice-Agent Latency Correctly: From Speech End to Audible Response](https://stanleycyang.com/writing/measure-voice-agent-latency): Instrument a voice agent with one clock model, turn-level milestones, WebRTC media statistics, and latency budgets that expose the real bottleneck. Topics: Voice agents, Performance, Observability. Updated: 2026-07-18. - [Memory Consolidation for Long-Running AI Agents](https://stanleycyang.com/writing/agent-memory-consolidation-decay): Turn raw agent events into reviewable memories with provenance, deduplication, contradiction handling, decay, and safe forgetting. Topics: AI agent memory, AI agents, Retrieval-augmented generation. Updated: 2026-07-18. - [Migrate an AI Monorepo to TypeScript 6 Without Hiding Breakage](https://stanleycyang.com/writing/typescript-6-ai-monorepo-migration): A package-by-package migration plan for TypeScript 6 defaults, deprecations, type environments, project references, and the TypeScript 7 transition. Topics: TypeScript, Monorepos, AI engineering. Updated: 2026-07-18. - [Migrate Coding-Agent Frameworks Without Losing Behavioral Guarantees](https://stanleycyang.com/writing/coding-agent-framework-migration): Move a coding agent to a new framework through contract inventory, compatibility tests, dual runs, staged rollout, and a defined rollback. Topics: Coding agents, AI agents, Software architecture. Updated: 2026-07-18. - [Multi-Model Routing for AI Agents: Design and Evaluate a Router](https://stanleycyang.com/writing/multi-model-routing-for-agents): Route agent calls by capability, quality, latency, cost, privacy, and availability using an evaluated policy with safe fallbacks. Topics: AI agents, Model routing, Evaluation. Updated: 2026-07-18. - [Multi-Tenant RAG with PostgreSQL Row-Level Security](https://stanleycyang.com/writing/multi-tenant-rag-postgres-row-level-security): Enforce tenant isolation across documents, chunks, vector retrieval, citations, caches, background jobs, and database roles. Topics: PostgreSQL, Retrieval-augmented generation, Security. Updated: 2026-07-18. - [Next.js 16 Cache Components for AI Applications](https://stanleycyang.com/writing/nextjs-16-cache-components-ai-apps): Adopt Cache Components without leaking sessions, serving stale agent state, or invalidating more data than necessary. Topics: Next.js, AI applications, Caching. Updated: 2026-07-18. - [OAuth for Remote MCP Servers: Discovery, Scopes, and Token Validation](https://stanleycyang.com/writing/oauth-remote-mcp-servers): Implement the MCP 2025-11-25 authorization boundary for an HTTP server without token passthrough, audience confusion, or excessive scopes. Topics: Model Context Protocol, OAuth, Security. Updated: 2026-07-18. - [Prevent Runaway Agent Delegation](https://stanleycyang.com/writing/prevent-runaway-agent-delegation): Control delegation depth, fan-out, duplicate work, cycles, authority propagation, and result synthesis in multi-agent systems. Topics: AI agents, Multi-agent systems, Reliability. Updated: 2026-07-18. - [Prevent SSRF in AI Agent Tools](https://stanleycyang.com/writing/prevent-ssrf-agent-tools): Build an outbound-request broker that stops agents from reaching internal services, cloud metadata, redirected targets, and DNS-rebinding destinations. Topics: AI agents, SSRF, Security. Updated: 2026-07-18. - [Privacy-Aware Multimodal Agents: Minimize Audio, Images, Documents, and Traces](https://stanleycyang.com/writing/privacy-safe-multimodal-agents): Map multimodal data flows, collect only necessary regions and intervals, redact before model access, constrain retention, and verify deletion. Topics: Privacy, Multimodal AI, AI security. Updated: 2026-07-18. - [Prompt Injection Defense in Depth for Tool-Using Agents](https://stanleycyang.com/writing/prompt-injection-defense-in-depth): Contain direct and indirect prompt injection with provenance, privilege separation, constrained tools, output validation, egress controls, and bound approvals. Topics: Prompt injection, AI agents, Security. Updated: 2026-07-18. - [RAG Chunking Strategies: How to Compare Fixed, Structural, Semantic, and Parent-Child Retrieval](https://stanleycyang.com/writing/rag-chunking-strategies-benchmark): Choose a RAG chunking strategy with a held-out benchmark that measures retrieval, answer evidence, citation quality, latency, and index cost. Topics: Retrieval-augmented generation, Evaluation, Information retrieval. Updated: 2026-07-18. - [Red-Team an AI Agent with Adversarial Tool Results](https://stanleycyang.com/writing/red-team-agent-adversarial-tool-results): Test whether malicious search, document, email, and tool outputs can trigger unauthorized actions, memory poisoning, or data exfiltration. Topics: AI agent security, Red teaming, Prompt injection. Updated: 2026-07-18. - [Run Parallel Coding Agents Safely with Git Worktrees](https://stanleycyang.com/writing/parallel-coding-agents-git-worktrees): Give each coding agent an isolated branch and working directory, then integrate changes through explicit ownership, verification, and cleanup. Topics: Coding agents, Git, Multi-agent systems. Updated: 2026-07-18. - [Sandbox Untrusted Agent Code: Containers vs. WebAssembly](https://stanleycyang.com/writing/sandbox-untrusted-agent-code): Choose and harden an isolation boundary for generated code using explicit filesystem, network, process, syscall, resource, and output controls. Topics: Sandboxing, WebAssembly, Containers. Updated: 2026-07-18. - [Secrets Management for AI Agents Without Putting Secrets in Context](https://stanleycyang.com/writing/secrets-management-ai-agents): Give agent tools short-lived credential handles while keeping passwords, tokens, keys, and connection strings out of prompts, memory, traces, and results. Topics: AI agents, Secrets management, Security. Updated: 2026-07-18. - [Secure Browser Agents with Playwright: Isolation, Network Policy, and Approval](https://stanleycyang.com/writing/secure-browser-agents-playwright): Build a browser-worker boundary that treats webpages as hostile, isolates credentials, blocks unapproved network destinations, and requires approval for consequential actions. Topics: Browser agents, Playwright, AI security. Updated: 2026-07-18. - [Secure Next.js Server Actions for AI Agent Operations](https://stanleycyang.com/writing/secure-server-actions-ai-agents): Authenticate, authorize, validate, rate-limit, and make high-risk agent mutations idempotent in Next.js 16. Topics: Next.js, AI security, Server Actions. Updated: 2026-07-18. - [Serve a Tool-Calling Model with vLLM](https://stanleycyang.com/writing/serve-tool-calling-model-vllm): Configure vLLM's OpenAI-compatible server, model-specific parser, strict schemas, and a safe execution loop for local tool calling. Topics: vLLM, Tool calling, Open models. Updated: 2026-07-18. - [Serve Multiple LoRA Adapters with vLLM](https://stanleycyang.com/writing/serve-multiple-lora-adapters): Share one pinned base model across reviewed LoRA adapters while preserving lineage, tenant routing, cache isolation, memory limits, and measurable quality. Topics: LoRA, vLLM, Model serving. Updated: 2026-07-18. - [Shadow Testing AI Agents in Production](https://stanleycyang.com/writing/shadow-testing-ai-agents-production): Compare a candidate agent on representative production inputs while suppressing side effects, protecting user data, and avoiding misleading metrics. Topics: AI agent evaluation, Shadow testing, Production reliability. Updated: 2026-07-18. - [Statistical Confidence for AI Agent Evaluations](https://stanleycyang.com/writing/statistical-confidence-agent-evals): Choose estimands, experimental units, paired comparisons, confidence intervals, power, and release thresholds that match stochastic agent evaluations. Topics: AI agent evaluation, Statistics, Experiment design. Updated: 2026-07-18. - [Supervisor vs. Handoffs vs. Agent Graphs: A Reproducible Comparison](https://stanleycyang.com/writing/supervisor-vs-handoffs-vs-agent-graphs): Choose a multi-agent topology using a benchmark protocol that measures task success, coordination cost, latency, and unsafe actions. Topics: AI agents, Multi-agent systems, Evaluation. Updated: 2026-07-18. - [Tail Sampling and Redaction for AI Agent Traces](https://stanleycyang.com/writing/tail-sampling-redaction-agent-traces): A privacy-first OpenTelemetry Collector pipeline for retaining useful agent traces without exporting sensitive prompts by default. Topics: OpenTelemetry, AI observability, Privacy. Updated: 2026-07-18. - [Temporal RAG: Answer Questions Using the Correct Historical Version](https://stanleycyang.com/writing/temporal-rag-versioned-knowledge): Build version-aware retrieval with valid-time ranges, immutable sources, time-filtered ranking, and citations that preserve what was known when. Topics: Retrieval-augmented generation, PostgreSQL, Data modeling. Updated: 2026-07-18. - [Threat Model an AI Agent System from First Principles](https://stanleycyang.com/writing/threat-modeling-ai-agent-system): Turn an agent architecture into a data-flow model, identify attacker paths across tools and memory, and convert the highest risks into testable controls. Topics: AI agents, Threat modeling, Security. Updated: 2026-07-18. - [Trace AI Agents with OpenTelemetry: Spans, Tokens, Tools, and Redaction](https://stanleycyang.com/writing/trace-ai-agents-opentelemetry): Instrument agent, model, retrieval, and tool work in one trace using current OpenTelemetry GenAI conventions without exporting prompts or secrets by accident. Topics: OpenTelemetry, AI observability, Multi-agent systems. Updated: 2026-07-18. - [Trajectory Evaluation for Tool-Using AI Agents](https://stanleycyang.com/writing/trajectory-evaluation-tool-using-agents): Evaluate agent tool selection, arguments, ordering, evidence, side effects, and efficiency without requiring one brittle golden path. Topics: AI agent evaluation, Tool-using agents, Trajectory evaluation. Updated: 2026-07-18. - [Tune pgvector HNSW for Recall, Latency, Filtering, and Memory](https://stanleycyang.com/writing/tune-pgvector-hnsw-recall-latency): Use an exact-search baseline and a repeatable benchmark to tune pgvector HNSW construction, query, filtering, and memory parameters. Topics: pgvector, PostgreSQL, Vector search. Updated: 2026-07-18. - [Turn-Taking for Voice Agents: Endpointing, Interruption, and Backchannels](https://stanleycyang.com/writing/voice-agent-turn-taking-interruption): Design and evaluate voice-agent turn taking without treating every silence as completion or every sound as an interruption. Topics: Voice agents, Speech interfaces, Evaluation. Updated: 2026-07-18. - [Typed Agent Artifacts with JSON Schema and TypeScript](https://stanleycyang.com/writing/typed-agent-artifacts-json-schema): Create versioned plans, reports, patches, and decisions that are validated at runtime instead of trusting model-generated prose. Topics: AI agents, JSON Schema, TypeScript. Updated: 2026-07-18. - [Use Coding Agents Safely for Database Schema Changes](https://stanleycyang.com/writing/coding-agents-database-schema-changes): Have coding agents plan and verify expand-migrate-contract changes without granting them unsupervised production database access. Topics: Coding agents, PostgreSQL, Database migrations. Updated: 2026-07-18. - [Use PostgreSQL 18 UUIDv7 for AI Agent Event IDs](https://stanleycyang.com/writing/postgres-18-uuidv7-agent-events): Design time-ordered, idempotent agent-event tables with PostgreSQL 18 uuidv7 without confusing identity, time, and sequence. Topics: PostgreSQL, AI agents, Event sourcing. Updated: 2026-07-18. - [Use React 19.2 Activity for Multi-Session Agent Interfaces](https://stanleycyang.com/writing/react-19-2-activity-agent-sessions): Preserve agent-session UI state across tabs while correctly stopping effects, controlling memory, and protecting sensitive sessions. Topics: React, AI agents, Interface architecture. Updated: 2026-07-18. - [Version an MCP Server Without Breaking Clients](https://stanleycyang.com/writing/version-mcp-server-without-breaking-clients): Evolve tools, resources, prompts, transports, and experimental features using protocol negotiation, additive contracts, compatibility tests, and staged removal. Topics: Model Context Protocol, API design, Testing. Updated: 2026-07-18. - [When Should an AI Agent Ask for Help?](https://stanleycyang.com/writing/when-ai-agent-should-ask-for-help): Implement escalation rules for ambiguity, missing authority, weak evidence, uncertain side effects, and high-impact decisions. Topics: AI agents, Human oversight, Safety. Updated: 2026-07-18. - [Write an AGENTS.md File That Actually Helps Coding Agents](https://stanleycyang.com/writing/write-effective-agents-md): Create concise repository instructions that expose non-obvious commands, boundaries, architecture, and verification without duplicating discoverable documentation. Topics: Coding agents, AGENTS.md, Developer experience. Updated: 2026-07-18.