Bauhaus-style geometric illustration: tangled black lines on the left resolve into three orderly red, yellow and blue routes on the right.

AI agents can write almost anything. That is impressive when exploring a new problem, but surprisingly inconvenient when running the same process ten thousand times. The next useful step in agent engineering may be to stop asking models to perform every task and start asking them to build smaller, safer systems that perform those tasks without them.

We have spent the last few years making AI agents more capable.

Better reasoning.

More tools.

Longer context windows.

More programming languages.

Access to terminals, browsers, databases, APIs, and entire repositories.

The objective seems obvious: give the agent everything it needs to solve the problem.

And for open-ended work, that makes perfect sense.

If I ask a coding agent to investigate a mysterious bug, I want it to inspect the system, form hypotheses, run tests, and use whatever appropriate tools the investigation requires.

But what if the task is not mysterious?

What if the agent is supposed to extract event information from a website?

Or process a batch of invoices?

Or transform a document into a predefined format?

Or perform the same integration every hour?

In that situation, allowing the agent to write and execute arbitrary code may be less of an advantage.

It means more possible mistakes.

More security considerations.

More things to test.

More tokens spent deciding how to do something whose basic structure is already known.

And more opportunities to discover, at three in the morning, that the system has interpreted a familiar business rule in a creative new way.

Perhaps we've been asking the wrong question.

Instead of asking how much freedom an agent needs to solve a task, we should sometimes ask:

How much freedom can we remove without reducing its ability to solve the task correctly?

This leads to an old programming concept that is becoming newly relevant in the age of AI.

Domain-specific languages.

Or, more simply, giving the agent a smaller language in which to work.

A General-Purpose Language Is Not Always a Gift

A coding agent can generate TypeScript, Python, JavaScript, SQL, Bash, and various combinations of all four.

Wonderful.

But consider an agent whose only job is to define how an events website should be parsed.

It needs to identify event cards.

Extract titles.

Read dates and locations.

Follow relevant links.

Handle pagination.

Normalise the result.

There is no obvious reason it should also be able to install arbitrary packages, launch shell commands, access unrelated files, or create its own network clients.

Those capabilities do not make the parser better.

They make the parser's possible behaviour harder to predict.

And the difference matters when the output will execute thousands of times.

General-purpose programming languages are designed to support an enormous range of activities.

That flexibility is valuable.

But a specialised production system benefits from a much narrower contract.

For example:

Find these elements.

Extract these attributes.

Convert this date.

Follow this approved link.

Return an event object matching this schema.

Nothing else.

The smaller contract is easier to validate.

Easier to review.

Easier to test.

And easier to keep compatible as the surrounding system evolves.

The agent can still perform substantial intellectual work.

It just doesn't need access to every capability of a general-purpose programming environment to express the result.

The Old Idea of a Domain-Specific Language

Domain-specific languages, or DSLs, have existed for decades.

SQL is a familiar example.

Regular expressions are another.

A spreadsheet formula is effectively a small language for a particular class of calculations.

Infrastructure configuration systems often provide specialised ways to express deployment and networking rules.

The point of a DSL is not necessarily to invent an entirely new syntax.

It is to restrict the available operations to those that make sense within a particular domain.

Sometimes a JSON file is enough.

A simple parser might be described through selectors and field names.

A workflow might be represented as a list of steps with predefined transitions.

A document transformation might use a schema and a small set of supported operations.

There is no need to build a new programming language when ordinary configuration already expresses the task.

But there is a point where configuration becomes awkward.

You need branching.

Conditional extraction.

Fallbacks.

Date transformations.

Exceptions.

Different page structures.

You start putting expressions inside JSON strings.

Then you invent a mini-language for those expressions.

Then you add another rule for escaping quotes.

Then a special function for dates.

Then a special syntax for loops.

Before long, you have created a programming language that is less familiar, less expressive, and probably less well understood by language models than JavaScript.

Congratulations.

You have reinvented programming, but made the documentation worse.

There is a more practical alternative.

Start with a language the model already knows.

Then remove the capabilities your application does not need.

A Parser Should Not Need to Think Every Time

A particularly interesting practical example comes from Refat Ametov, who writes the technology channel Refat Talks: Tech & AI.

In November 2026, he described work on an event aggregation system collecting information from thousands of source websites.

The challenge is familiar to anyone who has worked with web data.

Every site is different.

HTML structures vary.

Dates appear in inconsistent formats.

Some sources contain multiple event types.

Others change their layouts with little warning.

One approach is to give each page to a language model and ask it to extract the relevant information.

This is flexible.

You don't need to write a parser for every website.

The model examines the page and attempts to return structured data.

But the economics become less attractive when the same sources are processed repeatedly.

Every extraction requires another model call.

Every call incurs latency and token costs.

And the resulting data still needs validation.

Ametov reported that live LLM extraction in his use case was not only expensive at scale but also substantially less accurate than manually written parsers.

The reported quality difference was approximately 1.5 times, although the public account does not provide enough detail to treat that figure as an independently reproduced benchmark.

The team changed its architecture.

Instead of asking the model to extract every event, they asked it to write a reusable parser.

The model examines a source, produces the parser configuration, and helps verify the result.

Then the parser runs without the LLM.

The intelligence is used during construction.

The repetitive work is handled by ordinary software.

This is a small architectural change with potentially large consequences.

Almost 500 Parsers, Around One Dollar Each

According to Ametov's account, the system generated nearly 500 production parser configurations over approximately two months.

He reported an AI generation cost of roughly one dollar per configuration.

That is a striking number.

Not because a dollar is inherently the correct price for a parser.

But because the cost is incurred during development rather than every time the source is processed.

A parser may extract events thousands of times after it has been created.

The model does not have to rediscover the same HTML structure on every run.

The reported figures are a case study, not an independently audited industry benchmark. They also do not include every possible infrastructure, maintenance, and operational expense.

A parser still consumes computing resources.

Websites change.

Selectors break.

Dates are misinterpreted.

Some sources require authenticated access or JavaScript rendering.

But the economics of repeated execution can change dramatically.

Consider two architectures.

In the first, every page is sent to an LLM.

The cost grows approximately with the number of extraction requests.

In the second, an LLM generates a parser, and the parser is executed repeatedly.

The initial development cost may be higher than one extraction request, but each subsequent run can be much cheaper.

The break-even point depends on several variables:

  • The cost of direct model extraction
  • The cost of generating and validating the parser
  • The cost of ordinary parser execution
  • How often the source is processed
  • How frequently the source structure changes
  • The ongoing cost of detecting and repairing failures

If the source is processed once, generating a parser may be wasteful.

If it is processed every hour for several years, the difference can be enormous.

The architecture is particularly attractive when the work is repetitive but the configuration of that work requires intelligence.

That is a distinction worth remembering.

AI may be most valuable when it creates reusable procedures, not when it repeatedly performs work that has already been understood.

Why They Didn't Just Generate Python

There is a reasonable question.

Why bother with a DSL?

Why not let the model write a Python or TypeScript parser for each website?

It can already do that.

And sometimes this is the correct approach.

But arbitrary code introduces operational complexity.

One parser imports a library.

Another makes network requests directly.

Another uses an unexpected date package.

Another handles errors differently.

One developer writes a helper.

The next agent produces a new implementation of the same helper.

A minor change to a common policy now requires modifying hundreds of individually written programs.

Each parser may work.

But the collection becomes difficult to maintain.

Ametov's team reportedly tried the general-purpose approach and found it slower, more expensive, and harder to control than constrained parser generation.

Their earlier configuration design also became too complicated.

It used JSON with embedded logic, creating a custom expression system that agents frequently misunderstood.

So they changed direction.

The eventual design used a restricted subset of JavaScript.

No arbitrary imports.

No eval.

A controlled network-access boundary.

Strict validation of extracted data.

And a library of approved functions for common operations.

This is the useful middle ground.

The agent gets a syntax it already understands.

The application gets a bounded set of operations.

And the runtime owns the dangerous capabilities.

The agent is not inventing the entire application.

It is filling in the specific logic required to process one source.

There is an important security caveat here.

Removing import and eval does not automatically make JavaScript safe.

Executable code must still run inside an appropriately isolated environment with resource limits, restricted network access, controlled data access, and protection against malicious input.

The goal is to design an enforceable execution boundary, not merely ask the model to behave.

The Third Option Between Agents and Workflows

The parser example points toward a larger architectural idea.

There are two popular approaches to AI automation.

One is workflow-first.

The process is defined in advance.

Receive an input.

Validate it.

Call an API.

Apply a rule.

Store the result.

Notify the appropriate person.

Finish.

Some steps may use language models, but the overall execution path is governed by a predefined structure.

Tools such as n8n, Airflow, Dify, and workflow frameworks provide different versions of this idea.

The second approach is agent-first.

Give the agent a goal.

Provide tools.

Let it decide which operations to perform, in which order, and how to recover when something unexpected happens.

This is useful when the process cannot be completely specified in advance.

But it introduces variability.

The agent may take different paths.

Make unnecessary tool calls.

Repeat a failed approach.

Misinterpret an instruction.

Or continue working after it should have stopped.

There is nothing inherently wrong with autonomy.

The question is whether autonomy provides enough value to justify its cost for the particular task.

And this suggests a third approach.

Let the agent design the workflow. Then let the workflow perform the work.

The agent becomes a developer rather than the permanent runtime.

It investigates the task.

Writes the automation.

Creates tests.

Runs examples.

Examines failures.

Updates the implementation.

And submits the result for review.

Once approved, the automation executes through a more predictable system.

The agent returns when the process needs to change.

Not necessarily every time the process runs.

This combines the flexibility of agentic development with the operational discipline of conventional software.

The Difference Between Development-Time and Runtime Intelligence

This is perhaps the most useful distinction in the entire discussion.

We often treat AI automation as though the model must remain involved in every execution.

But many problems only require substantial intelligence while the procedure is being discovered.

A human developer faces the same distinction.

An engineer may spend days implementing a data transformation.

Once deployed, the transformation does not require the engineer to sit beside the server and reconsider the logic for every input.

Software exists precisely so that decisions can be made once and applied repeatedly.

AI agents can participate in that process.

They can produce code.

They can generate configurations.

They can build tests.

They can propose corrections.

But if the resulting procedure is stable, there may be no reason to repeat the entire reasoning process during every production run.

This suggests a useful architecture.

Development phase: An agent explores, proposes, writes, tests, and revises.

Review phase: Humans or controlled verification systems check the result.

Production phase: Approved code or workflows execute under bounded permissions.

Maintenance phase: Failures, changed requirements, or new inputs trigger another development cycle.

The important feature is the separation of roles.

The agent has broad freedom where exploration is valuable.

The production system has narrow permissions where reliability matters.

And changes move between the two through an explicit validation process.

This is closer to traditional software engineering than the popular image of an autonomous AI employee running every business process indefinitely.

That is not a weakness.

It may be exactly what many organisations need.

Mastra and Workflows as Code

A concrete example of the workflow approach is Mastra.

Mastra provides TypeScript-based workflows with typed steps, input and output schemas, explicit control flow, and support for agents and tools inside those steps.

Its documentation describes workflows as a way to define structured task sequences instead of relying on one agent to reason through the entire process dynamically.

The workflow can include branches, parallel operations, loops, and suspend/resume behaviour.

And Mastra Studio can display the execution graph, inputs, outputs, and traces.

That last feature matters.

A nontechnical domain expert should not need to understand every line of TypeScript to inspect the actual flow of a business process.

They should be able to see which step ran.

What information it received.

What it returned.

Where a failure occurred.

And which part of the workflow needs attention.

Meanwhile, the coding agent works with the same workflow through files.

It can inspect the definitions, change logic, add tests, and validate the result.

The production workflow remains versioned and reviewable.

This is an attractive arrangement for recurring business automation.

The workflow is code.

The agent is the editor.

The domain expert provides the business requirements.

And ordinary development controls govern deployment.

It also avoids a common problem with visual workflow builders.

A process can become difficult to manage when the visual graph is treated as the primary programming interface.

Code-based workflows preserve normal software-development practices.

Version control.

Code review.

Automated tests.

Deployment pipelines.

The visual representation remains useful for understanding and debugging execution.

Not necessarily for writing every branch by dragging boxes across a screen.

A Workflow Can Contain AI Without Becoming an Uncontrolled Agent

There is an important nuance.

A deterministic workflow does not mean that every step must produce an identical output.

It may contain LLM calls.

It may use a classifier.

It may summarise documents.

It may request human approval.

Those operations may still be probabilistic or depend on external systems.

What becomes predictable is the orchestration.

The order of operations.

The conditions under which each step is called.

The permitted transitions.

The validation requirements.

The retry policies.

And the circumstances under which the process stops.

That distinction is essential.

An AI-enabled workflow can remain flexible at designated points while keeping the overall business process bounded.

For example, an invoice-processing workflow might use a model to extract information from a document.

But ordinary code checks the invoice identifier, amount, supplier, and purchase-order reference.

A mismatch triggers review.

The model does not independently decide to approve an unfamiliar payment just because the invoice looks convincing.

If a human approval is required above a certain threshold, that requirement is part of the workflow.

It is not merely a sentence in a prompt that the agent might reinterpret later.

This architecture does not eliminate risk.

But it makes the boundaries explicit.

And in enterprise automation, explicit boundaries are often more valuable than an additional degree of cleverness.

Framer's Harness 2 Makes the Same Point From Another Direction

A more recent example comes from Framer.

In November 2026, the company published a technical explanation of Harness 2, its redesigned agent execution environment.

Framer's earlier harness relied on a specialised command language for modifying design documents.

The agent generated operations such as inserting elements and changing properties.

This worked, but it became inefficient for complex edits.

Imagine changing a property across hundreds of elements.

With an overly granular command interface, the agent may need to issue repeated operations.

Each round trip adds latency and token overhead.

Framer replaced much of that approach with JavaScript programs operating through controlled document methods.

The agent can traverse the document, inspect values, apply changes, and express conditional logic in one program.

The runtime can also begin executing complete statements while the model is still generating the rest.

According to Framer's published measurements, the new architecture roughly halved tool steps and reduced cached input tokens per message by 39%, with no measured reduction in task quality.

These figures describe Framer's own environment, not a universal benchmark.

But the architectural lesson is relevant.

Sometimes a custom language is too restrictive.

Sometimes a general-purpose language is too permissive.

The useful design lies between the two.

Familiar syntax.

A specialised API.

A controlled execution environment.

And enough expressive power to complete meaningful work without constant model round trips.

Framer did not simply give its agent unrestricted JavaScript access to the entire computer.

It gave the agent a better way to express operations over a specific domain.

That is the difference.

Claude Code's Dynamic Workflows Show Another Variation

Claude Code's dynamic workflows provide a related example.

The workflow system allows JavaScript scripts to orchestrate specialised subagents through functions including agent(), parallel(), and pipeline().

The scripts can use familiar JavaScript structures.

But the execution environment restricts capabilities that would undermine the workflow's guarantees.

In Ametov's description of the environment, arbitrary imports are restricted and Date.now() throws an error.

This helps make interrupted workflows reproducible.

These details come from his account; the linked Claude Code introduction confirms the orchestration model and resumable execution.

The result is again a deliberately limited programming environment.

The agent can describe complex orchestration using familiar syntax.

But it cannot treat the orchestrator as an unrestricted Node.js process.

There is an important difference from the parser and scheduled-workflow examples, however.

Claude Code's dynamic workflows can still launch models and make agentic decisions during execution.

They are not necessarily deterministic business automations.

The common principle is narrower.

A specialised agent environment does not need the full capabilities of a general-purpose programming language.

It needs the capabilities that serve its intended job.

And those capabilities should be explicit.

The Security Boundary Is the Product

This architecture introduces a difficult engineering responsibility.

Once an agent begins generating executable programs, the runtime becomes part of the product's security model.

It is not enough to say:

The model has been instructed not to do anything dangerous.

It is not enough to remove a few obvious functions.

And it is certainly not enough to assume that a parser is harmless because its intended output is a list of events.

A web parser processes untrusted data.

That data may contain malicious content.

The agent that generated the parser may have misunderstood the source.

A page may include instructions designed to manipulate an LLM during parser construction.

Generated selectors may follow unexpected URLs.

And code may enter paths that were never exercised by the examples used during development.

A serious implementation therefore needs boundaries.

The parser should receive only the data and capabilities it requires.

Network access should be mediated through a controlled interface with domain and address restrictions.

Execution should have limits on time, memory, recursion, and output size.

Input and output schemas should be enforced.

Secrets should not be available to untrusted generated code.

And the deployment process should keep generation separate from production approval.

Even with these controls, a sandbox is not a magical guarantee of safety.

Its implementation and surrounding infrastructure matter.

The point is that the agent's freedom should be constrained by architecture, not merely by politeness.

A specialised agent is easier to trust when the system makes entire categories of unwanted behaviour impossible or at least substantially harder.

What Happens When the Website Changes?

There is another practical challenge with generated parsers.

Websites change.

A source may redesign its event cards.

Replace an HTML table with a JavaScript-rendered component.

Move dates into a new attribute.

Change pagination.

Or begin requiring a different access method.

The parser that worked yesterday may silently produce incomplete data tomorrow.

This is why generating the parser is only part of the architecture.

The system also needs a way to detect failure.

Schema validation can identify missing required fields.

But structurally valid data may still be wrong.

A date might be parsed in the wrong timezone.

An event title might be extracted from a navigation link.

A location might belong to a different event on the page.

So validation should include more than checking whether the JSON contains the expected keys.

Useful controls include known test fixtures, source-specific sanity checks, extraction counts, date-range checks, duplicate detection, and periodic comparison against independently inspected examples.

When the system detects a possible change, the agent can return.

It can inspect the updated source, propose a revised parser, run tests, and submit the modification for review.

This is a better role for an agent than forcing it to inspect every page from scratch indefinitely.

It intervenes when intelligence is needed.

The routine pipeline remains routine.

And if the source changes too frequently or unpredictably, direct model extraction may still be the better choice.

There is no reason to force every problem into the same architecture.

The Cost Equation Is More Important Than the Demo

Agent demonstrations are often impressive.

A model opens a browser.

Clicks through a website.

Finds information.

Makes decisions.

Calls several tools.

And produces a finished result.

The entire process looks wonderfully autonomous.

But production economics depend on repetition.

If the workflow runs once, an autonomous agent may be an excellent choice.

If it runs a thousand times every day, the cost of repeatedly reasoning through an established process becomes more important.

A useful comparison is:

Total cost of direct extraction

Number of runs × cost per model-driven extraction

Total cost of generated automation

Generation + validation + maintenance + number of runs × ordinary execution cost

The comparison needs to include accuracy and failure costs, not only token prices.

A cheap parser that silently misses half the events is not a bargain.

A model-driven extractor that succeeds on unusual edge cases may justify its higher cost.

And a workflow whose maintenance requires constant repairs may be more expensive than expected.

But when the task is stable and repeated frequently, moving reasoning from runtime to development time can produce substantial savings.

The stronger economic claim is not that DSLs are always cheaper.

It is that we should stop paying for open-ended reasoning every time we execute a problem that has already been reduced to a reliable procedure.

That seems like a fairly reasonable principle.

It is also one that the excitement around autonomous agents sometimes causes us to forget.

When You Should Keep the Full Agent

None of this is an argument for replacing every agent with a workflow.

Some work is genuinely open-ended.

Investigating a novel software failure.

Reviewing an unfamiliar codebase.

Conducting research where the next step depends on unexpected findings.

Navigating an unfamiliar graphical application.

Resolving a new integration problem.

Designing a product that has not yet been specified.

These tasks benefit from the freedom to explore.

A predefined workflow may become an obstacle.

And a narrow DSL may force the agent to express a new problem through operations that were designed for something else.

The result can be worse than allowing ordinary code.

This suggests an architectural progression.

Begin with exploration.

Let an agent investigate the task.

Observe what it does.

Identify recurring steps.

Separate genuine uncertainty from repeated mechanics.

Then decide which parts can become ordinary code or controlled workflows.

Not every task will reach that stage.

But many recurring business processes will.

The important transition occurs when the uncertainty has moved.

Initially, the system does not know what procedure to use.

Later, it knows the procedure but must execute it repeatedly.

At that point, continuing to use a fully autonomous agent for every execution may be unnecessary.

It is like asking an experienced software engineer to manually calculate every invoice after they have already written the accounting system.

Possible, perhaps.

But a strange use of expertise.

The Architecture I'd Bet On

The most promising pattern for specialised AI automation is not agent-first or workflow-first in isolation.

It is a division of labour.

Agents discover and modify procedures.

Constrained languages express domain-specific logic.

Workflows organise repeatable execution.

Deterministic code handles operations that do not require model reasoning.

LLMs remain available for specific steps where interpretation is genuinely necessary.

Tests, traces, and human review determine whether changes are safe to deploy.

And production permissions remain narrower than development permissions.

This creates a useful separation between creativity and reliability.

During development, flexibility is an advantage.

During repeated execution, unnecessary flexibility becomes a liability.

The better the agent becomes at writing code, the more practical it becomes to have that agent produce software that no longer needs the agent for every operation.

There is something slightly ironic about this.

For years, we have tried to make AI agents more autonomous.

But some of the best uses of that autonomy may involve creating systems in which the model has much less freedom.

Or is not involved at all.

A specialised parser doesn't need a personality.

An invoice validator doesn't need curiosity.

A scheduled data transformation doesn't need to reconsider its purpose every morning.

It needs to work.

And when it stops working, that is a good time to bring the intelligence back.

Give the Agent a Smaller World

A good programming abstraction does not necessarily increase the number of things a system can do.

Sometimes it deliberately decreases them.

And that reduction can make the remaining capabilities easier to understand, verify, and maintain.

This is what makes domain-specific languages interesting for AI agents.

The model can still use its general intelligence to produce the solution.

But the solution must fit within a smaller, well-defined space.

A parser can parse.

A workflow can coordinate approved steps.

A document transformation can produce validated output.

And none of those components needs permission to do everything else.

The practical lesson is not to invent a new programming language for every application.

Start with configuration.

Move to a familiar language with a limited API when the domain requires more expressiveness.

Introduce a custom DSL only when there is a clear reason that simpler alternatives cannot satisfy.

And separate the ability to generate or change the automation from the authority to deploy and run it.

Most importantly, recognise when the agent has finished its real job.

If it has discovered a repeatable solution, tested it, and expressed it as reliable software, there is no special virtue in making it rediscover the same solution every hour.

The agent has created something valuable.

Let that thing work.

This may become one of the more important shifts in practical AI engineering.

Not increasingly autonomous agents performing every operation forever.

But agents that turn uncertain work into explicit, testable systems.

Systems that are cheaper to run.

Easier to inspect.

More predictable.

And less dependent on a model making the right decision at precisely the wrong moment.

Sometimes the most intelligent thing we can do with an AI agent is give it less to do.

And a much smaller language in which to do it.

Sources

Keep reading

Explore the writing archive →

Stay in touch

More essays and updates on ABVX Substack.

Read and subscribe on Substack →