We Replaced a Manual Workflow With an AI Agent: The Architecture

Xperiencify is a gamified course platform for coaches. Coaching Genie is a coaching platform we've worked on with Milana Leshinsky for five years. On both, content-idea research used to be manual work. Now it runs end to end without anyone copying and pasting.
Manual content research looks much the same wherever you find it. Someone reads the coach's material and checks what the audience keeps asking. They draft a list of ideas, rewrite the weak ones, format the result and paste it where the coach will see it. Every step moves text from one document to another, and next week it starts over.
When we automated it, we gave the model the smallest job we could. It isn't one program. It's a few pipelines across the two products, and they share one shape. This post is that shape, with the line between what the model does and what code does. If you read AI agent vs n8n vs custom code, this is the same argument running in production.
The rule we built by
Code does every step that has one right answer: fetching, parsing, matching, checking, saving, charging. The model does the steps that need judgment, like reading a transcript for the useful part or writing a draft. When a step could go either way, it goes to code. Code is cheaper, and when it fails, it fails the same way twice.
1. Intake: a form, not a chat box
The pipeline starts from what the coach already has: answers to a short set of questions about their audience and offer, plus their own documents and videos. Documents become text through plain extraction or OCR. Videos go through a speech-to-text model, which is the first model call in the pipeline and a narrow one.
We skipped the chat box on purpose. A chat box gets whatever the coach remembers to type that day. A form gets the same fields every time, and every later step depends on that.
2. Context: a fact sheet built by code
Before the model writes anything, code assembles what it's allowed to use. Names, prices and durations are pulled from the coach's answers with plain pattern matching. Empty sections are dropped, so the model never sees a heading with nothing under it and fills the gap on its own.
Source material is split into pieces and stored in a searchable index. When the pipeline needs material for the next item, code searches the index and skips anything an earlier item already used. That's how the list avoids repeating itself without asking the model to remember what it wrote.
3. Research: code fetches, the model reads
Sometimes the coach's material doesn't cover a topic. Then code calls a search API and, once the results are ready, hands them to a summarizing step. Sending the query and keeping track of what came back are code. Reading the results is the only part that needs a model.
Split your own workflow
Describe a manual workflow step by step and get a first cut of which steps need a model and which are plain code.
“|”
4. Generation: small model steps, checked by code
Depending on the job, the model writes in one call or in stages: plan the list, then draft and revise each item. Then code checks every item against rules, such as required markers and keyword lists. Only the items that fail go back to the model, and each section gets at most two rewrites.
A rule check costs nothing. A full regeneration costs a whole call and can break the items that were already fine.
5. Approval: the coach stays the editor
The output is a draft, and the coach decides what gets used. They can keep an idea, rewrite it, regenerate one item or ask for more. When they ask for more, the earlier results go along with an instruction not to repeat them. Ratings and saved items are stored with each result.
6. Log and cost: every call leaves a record
Every model call logs its token usage. Where coaches pay per generation, the credit is reserved before the call and refunded if the call fails, so nobody pays for an error. Output length is capped. The stable part of each prompt goes first, so the provider's prompt cache can reuse it.
7. Retry path: assume every step fails sometimes
Long steps run as background jobs with a status record. A scheduled job restarts any task that has been stuck for 15 minutes, up to three times. Model responses are validated against a fixed schema before anything is saved, so a malformed answer never turns into a half-saved record.
The split, step by step
| Step | Model or code |
|---|---|
| Turn documents into text | code |
| Turn video into text | speech-to-text model |
| Build the fact sheet | code |
| Find source material, skip what's used | code, over a search index |
| Search the web when material runs out | code fetches, a model summarizes |
| Plan and draft the ideas | model |
| Check each item against rules | code |
| Rewrite the items that failed, at most twice | model |
| Log usage, reserve or refund credits, save | code |
| Keep, edit, regenerate | the coach |
What we'd add from day one next time
None of these pipelines has a fallback model. When the provider has a bad afternoon, jobs wait and retry instead of switching. That's acceptable for content research. For anything a customer waits on, I'd put a second model behind a gateway in week one.
We'd also make the research step fail loudly. A web search that fails quietly produces a list that looks complete and isn't.
Is someone on your team still copying between documents every week?
We map the workflow, split it into code steps and model steps, and ship it with approval and a retry path built in. Flat price, one senior engineer, your repo and your cloud account. Send your email and we'll set up a 30-minute call within 24 hours.
Is your workflow a candidate?
The workflows worth automating first share a few traits. Count how many fit yours.
- It runs every week or more often.
- Its inputs are digital and already exist somewhere.
- A person can check the output in a couple of minutes.
- Most steps have one right answer, and only a few need judgment.
- A mistake costs a rewrite, not a refund.
- Someone owns the result and will review it.
Five or six: build it. Three or four: automate the code steps first and leave the judgment to a person. Fewer than that: keep doing it by hand for now.
What a first version looks like
- Week 1: write the manual workflow down step by step, mark each step as code, model or person, and collect 20 real examples of good output.
- Weeks 2 and 3: intake and the fact sheet with its rule checks, then the model steps, tested against the 20 examples.
- Week 4: the approval screen and the retry path, then real users.
Related reading
- AI agent vs n8n vs custom code: what should you actually build?: the decision behind the split above
- The $5K AI agent: what fits in 30 days and what does not: what a one-month build can hold
- How Start Matter helped Milana Leshinsky build her dream product: five years of building Coaching Genie
The service: AI Product Development. The products: Coaching Genie and Xperiencify.
Enjoyed this article? Share it with others
Related Posts

How Much Will Your AI Feature Cost at 1,000 Active Users?
Your AI prototype costs a few dollars a week, so the feature looks cheap. At 1,000 active users, context growth, tool steps, retries, background jobs and evals multiply that. Here is the illustrative math, line by line, and the five levers that bring it down.

The AI Feature Scorecard: Which Idea Should Your SaaS Build First?
Every SaaS has an AI backlog now, and most of it was ranked by how good the demo looked. Score each idea on five lines instead: how often the job happens, whether the data is ready, whether a right answer can be checked, what a wrong one costs, and which number it moves.

Shopify or WooCommerce With AI vs Headless Commerce With AI
Headless commerce won't make your AI smarter. What it changes is who can reach your data and your rules. If the AI you want already lives inside your platform, stay. If it needs your own data across several systems, the platform becomes the limit.