Menu

1 / 6

Agent loops for product features: budgets, errors, stops and checkpoints

DEV Community: typescript·Ahmad Dogar·10 days ago
#d687UGFa
#devtotypescript#devto#dev#call#model
Reading 0:00
15s threshold

The tutorial version of an agent is ten lines: call the model, run whatever tools it asks for, append the results, repeat until it stops. That loop is fine in a notebook. Inside a product it is a while (true) that spends money on every pass, can take actions on a customer's data, and has no idea that a person is waiting for an answer.

Most of the code I write for an agent feature is not the loop. It is the fence around it. This post walks through that fence using a teaching example: an assistant inside a roofing company's scheduling app that can find a job, look up open inspection slots and move an inspection when a customer asks.

Every exit from the loop is a decision I made, not one the model made.

The code uses the Anthropic TypeScript SDK with a hand-written loop. The SDK also ships a tool runner that drives the loop for you and has hooks for approvals.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.