Beyond the Agentic Loop, in TypeScript: building a shopping agent with the Orchestrator pattern
This post is a TypeScript implementation of the pattern described in "Beyond the Agentic Loop: The Orchestrator Pattern for Multi-Agent Systems" by Amogh Ubale (Stackademic). The original is Python with generic agents; here we keep the idea intact and re-theme it as a shopping assistant so the three execution modes have something concrete to chew on. All the design credit goes to that article — go read it first. The cast: a handful of shopping agents Before the pattern, the scene. The demo is a small storefront assistant backed by a few single-purpose agents: Catalog — list the categories on offer, or search products by keyword and price. Inventory — check stock and availability for a product. Pricing — look up the current price and any active promotions. Reviews — fetch a product's rating and review highlights. Order — place an order for a product. A customer request might need just one of these, several of them at once, or a few in a strict order — and deciding which of those shapes a request calls for is exactly what the orchestrator is for. The problem: the LLM as a while loop The default way to build a multi-agent system is the agentic loop : you hand the model a bag of tools and let it drive. think → call a tool → observe the result → think again → call another tool → … The LLM is both the brain and the control flow. That's wonderfully flexible, and it's the right tool when the task is open-ended and you genuinely don't know the steps in advance. But in production it has three nasty properties: Unpredictable shape. Every "think" step is another LLM round-trip, so a three-agent task might take 3 calls or 9 — you don't know until it runs, and latency swings with it. (The article clocks a representative three-agent query at ~7 calls through the loop; the wall-clock and spend follow, but the unpredictability is the part that actually bites.) Non-determinism. The same question can take a different path each time, which makes behavior hard to reason about and hard t