Designing Prompt Injection Defenses for AI Agents: Implementation Patterns for Separating Trust Boundaries and Handling External Content

I have stopped trying to sanitize prompts perfectly. Perfect sanitization is impossible: external content can be obfuscated, quoted, encoded, or phrased in ways a filter does not anticipate. The more reliable approach is to design the trust boundary around the agent. Make trust explicit, enforce it in software, and keep external content out of the … Read more

Human-in-the-Loop for AI Agents: Implementation Patterns for Pausing Before Execution, Awaiting Approval or Rejection, and Resuming with State Preserved

The first time an agent tried to send an email on my behalf, I realized that autonomy is not a single feature. It is a spectrum, and one of its most useful control points is the moment before an irreversible action. A mistaken email, a production data deletion, or an unintended payment can cost far … Read more

Making AI Agent Plans Resilient: Implementation Patterns for Replanning Under Uncertain Tool Results

An agent plan is a bet. It bets that a search will return useful results, an API will respond with a success code, a file will exist and be available, a payment will settle, and a human will approve the expected option. In demonstrations, these bets almost always win because the environment is carefully controlled. … Read more

Sandboxing AI Agents with Least-Privilege Capabilities: Patterns for Restricting Tool Execution

Why This Matters More Than You Think AI agents are moving beyond conversation. They orchestrate workflows, retrieve documents, execute code, write files, call external APIs, and sometimes initiate financial transactions. The security model has not kept pace with that expansion. A conventional service usually follows a predictable path: a request enters, validated code runs, and … Read more

Designing Observability for AI Agents — Tracing Tool Calls and Visualizing Failures with OpenTelemetry

Traditional applications usually fail at identifiable boundaries. An HTTP request returns 500, a database query times out, or a worker crashes and emits an exception. AI agents fail differently. An agent can return HTTP 200, complete every tool call, and still produce the wrong result. It may search the wrong database, call the same tool … Read more

Designing Deterministic Tests for AI Agent Outputs — Automatically Detecting Hallucinations and Regressions with eval-gate

“Looks Good” Is Not a Test Traditional software gives us a reassuring property: for a known input, we can usually predict the output. add(2, 3) -> 5 AI agents break that assumption. Ask an agent to investigate a repository twice and you may receive different wording, different tool calls, or a different ordering of findings. … Read more

Designing Safe Retries for AI Agent Tool Calls: Idempotency, Timeouts, and Recovery from Partial Failures

Retries look simple until an AI agent starts touching the real world. If a model calls a weather API twice, the result is usually harmless. If it sends an email twice, creates two calendar events, charges a payment card twice, or executes the same deployment twice, a retry can turn a transient network problem into … Read more

The Problem Nobody Talks About Until It Breaks Production

The Problem Nobody Talks About Until It Breaks Production You have shipped an AI agent that calls a dozen tools: search APIs, databases, email providers, payment processors, and deployment systems. In development, every call succeeds. Then, at 2 AM, a tool call times out halfway through. Should the agent retry? If it does, will it … Read more

How to Implement Memory Compression for AI Agents: Merging Old Memories When the Count Exceeds 60

AI agents get forgetful in a very specific way. They do not forget like humans do. They run out of usable context. In my agent framework, Spark, the long-term memory store became noticeably less useful after reaching approximately 60 records. Retrieval latency increased, prompts contained more irrelevant material, and the agent occasionally asked questions it … Read more