Most solo operators waste weeks trying to stitch together prompts, APIs, and cheap hosting only to watch their agent hallucinate or crash after a few hours. You can avoid that by learning the exact pieces that make an AI agent reliable, then deciding whether to build it yourself or grab a ready‑made blueprint. By the end of this guide you’ll have a working agent that can scrape leads, send follow‑ups, and log every step for under $30 a month.
What most guides get wrong about agent memory
Many tutorials treat memory as an afterthought, suggesting you just feed the whole chat history into each call. That works for a toy demo but blows up costs and latency fast. I think most people overestimate how much memory an agent actually needs—a belief that can lead you to pay for unnecessary tokens.
The real issue is not how much you store, but how you retrieve it. If you keep every turn, the model spends half its budget on irrelevant chatter. A better approach is to compress the conversation into a short summary and keep only the last few raw turns for context.
Gripe: I once spent an afternoon debugging why my agent kept forgetting the user’s email address, only to discover the platform’s “memory” feature was actually a fixed‑size buffer that dropped the earliest message without any warning—no logs, no error.
Love: The ability to export the internal summary as plain text and re‑import it later saved me when I had to migrate from a test environment to production; I could restore the agent’s knowledge in seconds.
Here’s a quick pattern that works well for most operators:
- After each user turn, run a summarization prompt (see example below).
- Store the summary in a key‑value store (Redis, DynamoDB, or even a JSON file).
- When building the next prompt, prepend the summary and attach the last two raw user‑assistant pairs.
- Trim the summary if it grows beyond 200 tokens.
That keeps token usage predictable and cost under control.
How do you stop an agent from looping forever?
Loops happen when the agent’s decision logic lacks a clear exit condition. A common pattern is to let the model decide whether to call another tool or to finish, but without a hard stop it can keep calling the same tool over and over.
One concrete fix is to add a step counter that forces a break after a set number of iterations. Another is to ask the model to output a special “DONE” token when it believes the task is complete.
Opinion that could be wrong: I believe a simple step counter is enough for 90 % of use cases, and adding complex planning layers is overkill.
Here’s a numbered step‑list you can drop into any agent framework:
- Initialize a variable
steps = 0. - At the start of each loop, increment
steps. - If
steps > MAX_STEPS, return a final answer and break. - Otherwise, let the model choose the next action.
- When the model returns the special token
[[DONE]], treat the task as finished regardless of step count.
Setting MAX_STEPS to five works for most lead‑gen flows; you’ll rarely hit the limit unless something is truly stuck.
A concrete named example: building a lead‑gen scraper with AgentBuilder and Puppeteer
Let’s walk through a real scenario: you need to pull contact info from a directory site, enrich it with LinkedIn profiles, and push the results into a Google Sheet.
First, we define the agent’s goal in a prompt:
You are a lead‑generation agent. Your job is to visit the URL provided, extract every entry that contains a name and an email address, then for each entry search LinkedIn for a matching profile and capture the profile URL. Output a JSON array where each object has
name,
We’ll use AgentBuilder (the no‑code AI agent framework) to orchestrate the steps and Puppeteer for the browser work.
Concrete gripe: AgentBuilder’s UI hides the timeout setting for each node inside a collapsible “Advanced” panel; I missed it once and my scraper kept hanging on a slow site, wasting ten minutes of compute time.
Concrete love: The built‑in retry node lets you specify exponential back‑off with a single dropdown—no custom code needed.
Here’s the flow in plain steps (you can replicate it in AgentBuilder’s visual editor):
- Start node: receive the seed URL.
- Puppeteer node: load the page, wait for network idle.
- Extract node: run a JavaScript snippet to pull
nameandemailfrom each listing. - Loop node: for each extracted entry, call a LinkedIn search Puppeteer node.
- Merge node: combine the original data with the LinkedIn URL.
- Google Sheets node: append the row.
- Counter node: increment a processed‑count variable; if it reaches 20, go to End.
- End node: return the collected array.
Cost breakdown for a solo operator running this twice a day:
- AgentBuilder hosted plan: $19/mo (includes 10 000 task runs).
- Puppeteer via Browserless.io: $9/mo for 5 000 minutes.
- Google Sheets API: free within generous limits.
- Total: $28/mo, which I think is fair for the automation saved.
If you self‑host AgentBuilder on a cheap VPS ($5/mo) and run Puppeteer locally, you can drop the recurring cost to under $15/mo, but you lose the managed UI and built‑in logging.
