ailiteracynepal 🇳🇵
Text size

Chapter 01 · Section III · 10 min read

1.3 Two ways to build a loop

Every loop you build sits somewhere on a spectrum from batteries-included agent tool to assemble-your-own from primitives. Both work. Choosing the wrong one costs weeks.

You do not build a loop from atoms. You pick a starting point on a spectrum: one end gives you a full agent tool where trigger, sandbox, tools, and verifier are already wired together and you configure them; the other end gives you primitives — a model API, a shell, some scripts — and you assemble the loop yourself. Both work. Which one you should reach for depends on how bespoke the job is.

The batteries-included end

Batteries-included tools ship as a single product where the six parts are pre-assembled. You bring the intent (system prompt, task description, tool config) and the tool brings the loop machinery (session, sandbox, tool router, verifier, logging).

Concrete examples: an agentic coding CLI, an in-editor autonomous-agent extension, a hosted “autonomous employee” platform.

Good for: the common shape. If your job is “read a repository, make changes, run tests, propose a PR” — that’s the shape these tools were built for. You’ll be running in an afternoon.

Bad for: anything that fights the tool’s assumptions. If the tool expects a git repo and you have a database, you’ll spend more time bending it than a from-scratch build would take.

The assemble-your-own end

At the other end, you write the loop yourself. A shell script, a small Python program, a Node service. It calls a model API when it needs judgement, calls other APIs when it needs data, writes to a file or a database for memory, and re-runs on a trigger you wire up (cron, a webhook, a manual command).

Good for: anything the batteries-included tools weren’t designed for — pipelines that touch three different systems, workflows tied to your specific vendor stack, jobs where “the shape of the work” changes over time.

Bad for: any of the batteries-included cases. If you’re rebuilding a session, a sandbox, and a tool router from scratch when a tool already gives you all three, you’re paying for tuition, not shipping.

The spectrum, not the binary

Most real systems sit somewhere in between. You might use an agent CLI for the “code” part and a scheduled cron job for the “trigger” part. You might use a hosted agent for the day-to-day and drop into a custom script when a special job comes up. The spectrum is not a wall — you can and should mix.

How to choose the first time

Two questions to ask in order:

1. Does an existing tool already do 80% of my job? If yes, start there. Ship. Iterate. When you hit the wall of the last 20%, you’ll know exactly what’s missing and whether it’s worth building yourself.

2. If no, what part of my job is unusual? Whichever part is unusual, that’s the part you’ll be writing custom code for. The other parts should still be handled by the closest off-the-shelf piece you can find.

The failure mode both directions is the same: you paid to build (or bend) something that a smaller commitment would have handled.

What each end optimises for

Batteries-included tools optimise for time to first working loop. You get a running system in an hour. The trade is that some choices are made for you — the sandbox model, the memory format, the tool interface — and if any of those don’t fit your job, you fight the tool.

Assemble-your-own optimises for fit to a specific job. Every part is yours. Nothing is imposed. The trade is that you’re building all of it yourself, including the boring parts (logging, retries, error handling) that a mature tool already handles.

Neither is more “engineered.” Both are engineering choices. What separates the good practitioners is knowing which they picked and why.

For the rest of this course

We’ll keep both flavours in mind. When we say “the trigger” (Chapter 2), we mean it whether you configure a scheduler inside an agent CLI or write a cron entry that runs a Python script. When we say “the sandbox” (Chapter 3), we mean it whether the tool creates a scratch worktree for you or you spin up a container yourself. Chapter 5 walks the same job through both flavours side by side to make the equivalence concrete.

Check your understanding

Quick check

You need a loop that pulls new invoice PDFs from an S3 bucket, extracts fields, writes rows to a Google Sheet, and Slacks the finance team a daily summary. Which starting point is likely the right first move?