rumman.ahmed
All writing

ai / ai / myai

Where the Agent Stops: Three Patterns for Dividing the Work on a New Project

Three small projects started from the same template in one week, and each one turned on a different answer to the same question: what is the agent's job here? A phone-drawn shared wall that survives hostile networks, a lightweight work-board planned before it was built, and guardrails that keep agents out of the code a human is there to write.

The last post was about plumbing inside myAI: who holds the master role, how mail gets routed, and why the gateway stopped coming back after the lid closed. This one is about what the plumbing is for. In the same few days, three small projects went from an empty folder to working software, all started from the same template.

The projects themselves matter less than the decision at the centre of each. Every time, the useful question wasn't "how fast can the agents build this?" It was "what exactly is the agent's job here, and where does it stop?" I got three different answers, and I think all three carry over to other projects.

The template should be the boring part

Every new project starts from the same blueprint, and the blueprint is boring on purpose:

  • One frontend stack, the same on every project.
  • Everything runs in containers. Nothing gets installed on the host.
  • CI runs on pull requests only, on a self-hosted runner, so a push to the review branch costs nothing.
  • Preview deploys are off by default. A preview exists only when someone asks for one.
  • Any project with an API ships a machine-readable spec and interactive docs from day one.

Registering a new project with the rest of the system (the morning boot report, the task runner, the mail router) takes two small changes. A day-old project gets the same treatment as a year-old one.

One detail is worth copying. I have a personal design rule that colour palettes contain no blue. Each project has a unit test that walks the palette and fails if any colour has more blue than red. It's a matter of taste, not correctness, and that's exactly why it's a test: no agent has to remember the rule, and none can quietly break it. If you have a rule you're tired of repeating to agents, make it a test.

Pattern 1: build fast, but behind an interface

The first project was a shared drawing wall. A big screen shows a canvas and a short join code. People scan a QR code with their phones, get a drawing pad, and their strokes appear on the wall in real time. There are no accounts and no free text, and nothing is stored. A line is the only thing a phone can send.

The first version used peer-to-peer WebRTC: the screen acts as the host, phones connect to it directly, and a public broker only introduces them. Strokes travel as normalised coordinates, batched every few tens of milliseconds and drawn by a single render loop. Every incoming message is validated and clamped, then rate-limited per phone, so one enthusiastic thumb can't flood the wall.

It passed every automated test. Then it failed on my own phone, even on a personal hotspot.

"Can't connect" is a different bug on every network

Two things saved it, and both depended on one early decision: all realtime code sat behind a small host/client transport interface from the first commit. A second network path meant a second implementation, not a rewrite.

flowchart LR
    A["App code<br/>screen + phones"] --> I{{"Transport interface<br/>host / client"}}
    I --> C{"Browser can do<br/>peer-to-peer?"}
    C -->|"yes, try briefly"| P["Peer-to-peer<br/>implementation"]
    C -->|"no, or timed out"| R["Same-origin HTTPS relay<br/>implementation"]
    I -.-> N["Next implementation<br/>when the next network breaks"]

Add a path that can only be blocked if the page is. The fallback is a plain HTTPS relay on the app's own origin: no WebSocket, no WebRTC, no third-party host. If the page loaded, the relay can reach the same host. The screen listens on both paths under one code, so a phone on either one finds it. A phone tries peer-to-peer briefly, then falls back, and a small on-screen note says which path is live. When it fails, it shows the real error instead of a generic "couldn't connect". That one choice is what made the next bug findable.

Don't wait for something that can't work. A headless test browser connected, and my real phone didn't, on the same network. So the network wasn't the problem. The browser was: WebRTC had been switched off by a policy or an extension. The fix checks that the browser can do WebRTC at all before trying, remembers a "not supported" answer, and goes straight to the relay. When the automated browser and the real one disagree, the difference between them is the bug.

Make the room survive a reload

Two later changes turned the demo into something you could put on a real screen:

  • One code, one screen. Reloading the screen used to create a fresh code and strand every phone. Now the code lives in the URL, the host keeps a per-tab secret, and a reload reclaims the same room. A forged reclaim is refused, and a second screen on the same code is offered a link to join instead.
  • Everyone sees the whole wall. Phones show the full wall behind their own pad. The screen broadcasts small deltas plus a chunked snapshot for late joiners, and phones apply updates idempotently, so a replayed chunk can't draw a stroke twice. An end-to-end test drives a screen and several phones, one of them joining late, over both paths.

The agent's job here was to build quickly, and the interface is what made quick safe. When the real world broke the first design twice, each fix was a new implementation, not a rewrite.

Pattern 2: pick a direction before anything gets built

The second project was a lightweight work-board: boards hold groups, groups hold items, and every item has typed columns (status, person, date, text, number). It has a dense table view, a kanban, a per-item updates thread with mentions, roles, private boards, one automation rule and CSV import. All the demo data is made up.

What I'd copy is the order of work. In my setup, anything big enough to burn real tokens goes through a visual plan before any code: two or three UI directions, one architecture diagram, an idea-to-product flow, and a phase table with token estimates. A human picks. Here the directions were table first (a dense grid with inline editing), board first (kanban up front) and list and panel (for work that runs on conversation). I picked table first. The pick was recorded as a locked decision, and only then did a build lane start.

Some design choices from the plan held up in the build, and they apply to any tool like this:

  • Store an item's values keyed by column id, and keep column definitions on the board. Adding a column then changes one document and needs no migration.
  • Keep an append-only event log. The activity feed, the automation and the audit trail all read the same history.
  • A private resource should return 404, not 403. "Not found" doesn't leak that the thing exists.
  • Ship an honest "what's left" list. No realtime push yet, one automation shape, no email, no rate limiting. A proof of concept that admits its gaps is much easier to pick up again than one that hides them.

The agent's job here was to build one direction, the one a human chose from pictures. The cheapest tokens are the ones you never spend building the wrong screen.

Pattern 3: guardrails on what agents may write

The third project turns the usual arrangement around. It's a tiny language model, written from scratch to learn how one works, and compiled to run in a browser. Each stage of the build becomes a short public lesson.

The rule is blunt: the model's core is written by hand, by me. Agents build everything around it (the build, containers, CI, the website, the lessons), but never the core logic. That only works if the build enforces it rather than a note asking nicely:

  • Each stage starts as a stub plus one failing test.
  • The failing test is marked as ignored, so CI stays green while the work is in progress, and one command lists what's still open.
  • A stage is done when its test passes with code a human wrote.
flowchart LR
    W["Agent wants to write"] --> G{"Guard: which<br/>part of the repo?"}
    G -->|"build, CI, site, lessons"| OK["Allowed"]
    G -->|"hand-written core"| NO["Blocked"]
    G -->|"open core stage"| H["Needs a human<br/>stub + ignored failing test"]
    H --> T{"Stage test passes<br/>with human code?"}
    T -->|yes| D["Stage done"]
    T -->|"not yet"| H

The lessons follow a matching rule I like a lot: names come last. You build an idea by hand first (a "letter-to-number book", a "what comes next" tally), watch it work, rebuild it from a blank page, and only then learn its real name: tokenizer, bigram, gradient descent, attention. A lint check fails the site build if a term appears before the stage that earns it, and that check has its own tests, so it can't quietly stop working.

After a year of getting agents to write more of my code, this was the first project where the main design job was deciding what they shouldn't touch, and then making the test suite hold that line.

The pattern behind the patterns

Three projects, three answers to "what's the agent's job here?":

  • Build fast behind an interface, so that when reality breaks the first design, the fix is a new implementation and not a rewrite.
  • Don't build until a human has picked a direction from a visual plan. Agent time is cheap, but building the wrong thing well is still waste.
  • Mark off what the human is there to learn or own, and put that line in the tests, not in a document.

The boring template is what makes all three affordable. When the shell, CI, deploy gate and taste rules come for free, the first day's attention goes to the one decision that's actually specific to the project.

If you build with agents and have your own rules for where they stop, I'd like to compare notes. Get in touch.