# Agent at build time, plain script at run time: how we handle browser tasks that run thousands of times — retained record

> Retained reddit record from reddit:AI_Agents.

Canonical: https://highsignal.app/data/records/9125ea21969a4e92

[← sources](https://highsignal.app/data)


source: [reddit](https://highsignal.app/data/reddit) (reddit:AI_Agents)  published 2026-09-29 05:09 ingested 2026-09-30 02:37

[original source ↗](https://www.reddit.com/r/AI_Agents/comments/1wt1bly/agent_at_build_time_plain_script_at_run_time_how/)

## retained text



```
Disclosure: I work on ZennoPoster, a Windows browser automation tool. We’ve been working on AI integration lately, and I’m curious how others approach this.

The main problem we ran into: an agent can drive a browser step by step and look great in a demo. Then you need to run the same task 5,000 times a day. Suddenly every run is re-reading the same pages, burning tokens, and potentially failing in a different place.

We ended up using the LLM in three places.

**1. Build time**

An MCP client like Claude Code, Cursor, Codex, or LM Studio edits the automation itself. In our case, that’s a graph of actions in a visual editor.

The agent can inspect the graph, add or rewire steps, and save the project. After that, it runs as normal deterministic automation, multi-threaded, with no LLM involved.

**2. Repair time**

If something breaks, the agent can inspect the existing graph, find the failed branch, patch it, save, and restart the task.

**3. Run time, but isolated**

Some steps really are fuzzy. Maybe the page layout changes frequently, or you need to handle different forms across different sites.

For those cases, we added an agent step inside the normal flow. It can think, call a tool, check the result, and repeat, but it has a strict iteration limit. It must eventually return either `RESULT: SUCCESS` or `RESULT: FAILURE`, which determines the next deterministic branch.

A few things we learned along the way:

* Sending the entire project graph to the model doesn’t scale. Large projects eat the context before the agent even starts working. We ended up exposing the structure at three levels: group overview, individual group, and full graph.
* We also had agents closing projects with unsaved changes, so closing now returns a 409 unless `discardUnsavedChanges: true` is explicitly passed.
* Permissions were another issue. Instead of discovering halfway through a task that an operation isn’t allowed, the agent can check its capabilities before starting.

I’m curious how others structure this. Do you keep the model in the loop for every run, use it mostly to generate deterministic automation, or use a hybrid approach?

And if you put agentic steps inside deterministic workflows, how do you decide the iteration limit?
```



document fetched 2026-09-30 00:19 · canonical https://reddit.com/r/AI_Agents/comments/1wt1bly/agent_at_build_time_plain_script_at_run_time_how
