Arrange Act Assert

Jag Reehals thinking on things, mostly product development

Agent: The Sugar Syntax of streamText

19 Sep 2025

For most of us, AI still feels like a black box. We send it a prompt and we get back a blob of text. Maybe we write some code to call a tool; maybe we juggle a few callbacks. We tell ourselves that this is just how things work: a model can only generate tokens, and tools can only run in our code.

But what if this mental model is the problem?

In this post I want to argue that the Agent pattern in the AI SDK is as revolutionary for AI development as useState and useEffect were for React. Just like React's client/server directives annotate where code runs across the network, the Agent API annotates where logic runs across the AI/model boundary.

Agent

Read More →

Build Safer, Faster, and More Reliable AI Apps with AI SDK Middleware

27 Aug 2025

Having recently built an AI Guardrails library for the AI SDK, I wanted to share what I learned along the way. This post will walk you through how you can write your own middleware, and why it's such a game-changer for building robust AI applications.

Design AI features that are safer, faster, and easier to evolve by layering language model middleware. This guide explains how to use AI SDK middleware to transform inputs, post-process outputs, enforce safety rules, cache results, observe performance, and handle streaming using a clean, composable approach aligned with official guidance.

Read More →

Hannah Hampton. A proper comeback story.

27 Jul 2025
Hannah Hampton
Photo by Katie Chan (KTC), licensed under CC BY-SA 4.0.

⚽️ Dropped by then and current manager Sarina Wiegman from the England squad in 2022 amid concerns over her attitude and conduct, she remained outside the national setup for almost two years.

⚽️ Born with strabismus and challenged by depth‑perception issues, she was told by doctors she should not play football.

⚽️ Rebuilt her career at Chelsea, playing an integral role in winning the treble last season.

⚽️ Chosen as England's first-choice goalkeeper ahead of the great and brilliant Mary Earps.

⚽️ Delivered under pressure in the quarter‑final versus Sweden, even with a bloody nose. Named Player of the Match.

Tonight, she starts in a European final for England.

Even when things don’t go your way, never give up.

Read More →

Building Reliable AI Agents Series: A 12-Factor Methodology

14 Jul 2025

After building production AI systems over the past few years, thanks to HumanLayer, I’ve learned that most agent failures aren’t about the LLM, they’re about architecture.

That’s why I’m creating a series of posts sharing the 12-Factor Agents methodology using Mastra.

In each part, I’ll break down one principle that transforms fragile prototypes into robust, production-ready AI agents.

Read More →

Demystifying MCP: Coaching Colleagues Through the New AI Protocol

30 Jun 2025

Last month, I had the fantastic opportunity to run a hands-on Model Context Protocol (MCP) workshop. It was a chance to mentor and coach colleagues, from engineers and testers to product owners, as we explored what MCP is, how it works, and why it is generating so much momentum across AI and developer communities.

My goal was not just to share knowledge. It was to guide the learning journey and build a shared, foundational understanding of this powerful emerging standard.

Workshop Highlights

We covered everything from core protocol basics and prompt crafting to real world patterns such as:

  • Simple MCP client and servers
  • Tools
  • Resources
  • Prompts
  • Authentication flows
  • Session context handling
  • Composing multiple MCP servers
Read More →

Understanding Commands & Events with Orchestration & Choreography

18 Jun 2025

Designing distributed systems has never been more challenging. As teams embrace microservices and event‑driven architectures, a persistent myth has arisen: commands equal orchestration, and events equal choreography. This tidy equivalence often becomes a mental shortcut but conceals the deeper truth of control‑flow patterns versus messaging semantics. As many practitioners have observed, collapsing these separate dimensions can restrict your system's flexibility and resilience.

Person thinking about the difference between commands and events.

In this article, we'll demystify these concepts and show how to apply them independently. You'll discover how separating semantics (commands vs. events) from control flow (orchestration vs. choreography) grants you greater architectural freedom and clearer, more maintainable workflows.

Read More →

From Gatekeeper to Enabler: Rethinking Engineering in the Age of the Citizen Developer

09 Jun 2025

Last month, our company hackathon became a vivid illustration of a broader shift in how software gets built. Across teams, from sales to support, product to engineering, domain experts huddled around laptops, experimenting with AI powered platforms such as V0, Lovable and Bolt. Within hours, they'd fashioned interactive prototypes complete with navigation flows and validation rules, all without writing a single line of traditional code.

Although these early demos relied on mock data, the fact that non-engineers could conjure usable software unaided was striking.

As a full-stack engineer accustomed to crafting CRUD apps from the ground up, I found myself asking a new question: How might we empower these citizen developers to build more often, more securely, and with live data? Their deep problem domain knowledge meant they moved swiftly, iterated boldly and learned faster than any handoff-laden process could permit.

An isometric illustration of a futuristic highway under construction, where software engineers in hard hats are laying down glowing code-shaped road segments. An isometric illustration of a futuristic highway under construction, where software engineers in hard hats are laying down glowing code-shaped road segments.

Over my two decades in software, I've discovered my highest leverage isn't in writing every screen or endpoint myself, but in architecting robust APIs, infrastructure and tooling so that others can deliver user value. In this two-part series, I'll share how engineers can transition from gatekeeping code to enabling creation at scale. In this first instalment, we'll explore the mindset shifts and guiding principles. Part 2 will dive into concrete patterns and architectural strategies for secure, sustainable enablement.

Read More →

Dual-Layer Locking: Redis for Speed, PostgreSQL for Reliability

02 Jun 2025

Two users withdraw money from the same account at exactly the same moment. Your system processes both requests, your database balance goes negative, and you wake up to an incident report. Sound familiar?

What if you could combine Redis's millisecond response times with PostgreSQL's bulletproof consistency? This dual-layer locking pattern does exactly that, giving you both speed and safety.

Redis and PostgreSQL logos side by side.

In this post, we'll explore a pattern that combines Redis's speed with PostgreSQL's reliability to prevent race conditions at scale.

Read More →